All use cases
OpenAI SDK
Keep the OpenAI SDK, change two fields
Override baseURL and apiKey. Model ids are owner/model strings across 209+ models.
01
The problem
What this is for
The official openai package looks vendor-locked. It is not — it only needs a compatible base URL.
02
What to do
Three steps, then copy
- 1.Keep openai installed.
- 2.Set baseURL to https://anyrouter.dev/api/v1 and apiKey to your sk-ar key.
- 3.Use model "anyrouter/free" or "anyrouter/auto" for the first call.
OpenAI SDK
ts
import OpenAI from "openai"
const client = new OpenAI({
baseURL: "https://anyrouter.dev/api/v1",
apiKey: process.env.ANYROUTER_API_KEY,
})
const res = await client.chat.completions.create({
model: "anyrouter/free",
messages: [{ role: "user", content: "Say hello in one sentence." }],
})
console.log(res.choices[0]?.message.content)Ready to try it
The guide has the full walkthrough. Sign up if you still need a key.
Related
Next playbooks
One AI SDK provider for the whole catalog
Install @anyr/ai-sdk-provider. generateText and streamText take a catalog id — including anyrouter/free.
OpenOne API in front of every provider dialect
OpenAI /chat/completions, Anthropic /messages, and a Responses API — same key, same catalog.
OpenAUTO
Start on anyrouter/free or anyrouter/auto
Two built-in virtual models: Go+ free failover (anyrouter/free) and stable paid failover (anyrouter/auto). Do not pick a flaky SKU for your first request.
Open