All use cases
Vercel AI SDK
One AI SDK provider for the whole catalog
Install @anyr/ai-sdk-provider. generateText and streamText take a catalog id — including anyrouter/free.
What this is for
Vercel AI SDK providers are usually one-vendor. Switching models should not mean a new client or a new key.
Steps, then copy
- 1.npm install @anyr/ai-sdk-provider ai
- 2.createAnyRouter() reads ANYROUTER_API_KEY when you omit the key.
- 3.Call anyrouter("anyrouter/free") or anyrouter("anyrouter/auto").
generateText
ts
import { createAnyRouter } from "@anyr/ai-sdk-provider"
import { generateText } from "ai"
const anyrouter = createAnyRouter()
const { text } = await generateText({
model: anyrouter("anyrouter/free"),
prompt: "What is AnyRouter?",
})
console.log(text)Ready to try it
The guide has the full walkthrough. Sign up if you still need a key.
Next playbooks
- Keep the OpenAI SDK, change two fieldsOverride baseURL and apiKey. Model ids are owner/model strings across 271+ models.
- Start on anyrouter/free or anyrouter/autoTwo built-in virtual models: free failover on every plan (anyrouter/free) and stable paid failover (anyrouter/auto). Do not pick a flaky SKU for your first request.
- One API in front of every provider dialectOpenAI /chat/completions, Anthropic /messages, and a Responses API — same key, same catalog.