SDKs
The official SDKs work with indoRouter once you change the base URL and the key. Keep the key in INDOROUTER_API_KEY (create one).
OpenAI SDK
Section titled “OpenAI SDK”The base URL ends in /v1.
import osfrom openai import OpenAI
client = OpenAI( base_url="https://api.indorouter.ai/v1", api_key=os.environ["INDOROUTER_API_KEY"],)
reply = client.chat.completions.create( model="openai/gpt-4o-mini", messages=[{"role": "user", "content": "hello"}],)print(reply.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.indorouter.ai/v1", apiKey: process.env.INDOROUTER_API_KEY,});
const reply = await client.chat.completions.create({ model: "openai/gpt-4o-mini", messages: [{ role: "user", content: "hello" }],});console.log(reply.choices[0].message.content);Anthropic SDK
Section titled “Anthropic SDK”The base URL has no /v1, because the SDK adds /v1/messages itself. This endpoint supports every chat model in the catalog, including models from vendors other than Anthropic. See Messages.
import osfrom anthropic import Anthropic
client = Anthropic( base_url="https://api.indorouter.ai", api_key=os.environ["INDOROUTER_API_KEY"],)
message = client.messages.create( model="anthropic/claude-haiku-5.5", max_tokens=1024, messages=[{"role": "user", "content": "hello"}],)print(message.content[0].text)import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({ baseURL: "https://api.indorouter.ai", apiKey: process.env.INDOROUTER_API_KEY,});
const message = await client.messages.create({ model: "anthropic/claude-haiku-5.5", max_tokens: 1024, messages: [{ role: "user", content: "hello" }],});console.log(message.content[0].text);Frameworks
Section titled “Frameworks”Frameworks that build on the OpenAI API take the same base URL and key through their OpenAI-compatible provider.
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";import { generateText } from "ai";
const indorouter = createOpenAICompatible({ name: "indorouter", baseURL: "https://api.indorouter.ai/v1", apiKey: process.env.INDOROUTER_API_KEY,});
const { text } = await generateText({ model: indorouter("openai/gpt-4o-mini"), prompt: "hello",});console.log(text);import osfrom langchain_openai import ChatOpenAI
llm = ChatOpenAI( base_url="https://api.indorouter.ai/v1", api_key=os.environ["INDOROUTER_API_KEY"], model="openai/gpt-4o-mini",)print(llm.invoke("hello").content)Troubleshooting
Section titled “Troubleshooting”- 404: the OpenAI SDK needs
/v1at the end of the base URL; the Anthropic SDK must not have it. model_not_found: the model ID needs its vendor, as inopenai/gpt-4o-mini.