Skip to content

SDKs

OpenAI Python/TypeScript, Vercel AI SDK, LangChain.

We do not ship our own SDK. Any client that speaks the OpenAI Chat Completions API works by setting the base URL to https://api.aimodelsrouter.ai/v1 and the API key to your sk-amr-v1-… key.

OpenAI SDKs

# pip install openai
import os
from openai import OpenAI

client = OpenAI(base_url="https://api.aimodelsrouter.ai/v1", api_key=os.environ["AMR_API_KEY"])
reply = client.chat.completions.create(
    model="deepseek/deepseek-v4-flash",
    messages=[{"role": "user", "content": "Hello"}],
)
print(reply.choices[0].message.content)

Vercel AI SDK

Use the OpenAI-compatible provider and point it at our base URL:

// npm install ai @ai-sdk/openai-compatible
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText, streamText } from "ai";

const amr = createOpenAICompatible({
  name: "aimodelsrouter",
  baseURL: "https://api.aimodelsrouter.ai/v1",
  apiKey: process.env.AMR_API_KEY,
});

const { text } = await generateText({
  model: amr("deepseek/deepseek-v4-flash"),
  prompt: "Write a haiku about routers.",
});

const result = streamText({ model: amr("deepseek/deepseek-v4-flash"), prompt: "Count to five." });
for await (const delta of result.textStream) process.stdout.write(delta);

LangChain

# pip install langchain-openai
import os
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="deepseek/deepseek-v4-flash",
    base_url="https://api.aimodelsrouter.ai/v1",
    api_key=os.environ["AMR_API_KEY"],
)
print(llm.invoke("Summarize the CAP theorem in one sentence.").content)

Other clients

Tools that let you set an "OpenAI base URL" or "OpenAI-compatible endpoint" work the same way: set the base URL, the key, and use a model slug from the directory as the model name.