Skip to content

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).

The base URL ends in /v1.

import os
from 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)

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 os
from 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)

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);
  • 404: the OpenAI SDK needs /v1 at the end of the base URL; the Anthropic SDK must not have it.
  • model_not_found: the model ID needs its vendor, as in openai/gpt-4o-mini.