固定的模型 ID 会失效
如果代码里固定了 google/gemini-3.5-flash,每次发布更新的 Flash 模型都要改代码,而且该模型下线或故障的那天就会出错。
latest 别名指向一个模型家族。发送 google/gemini-flash-latest,AnyRouter 会调用当前能处理请求的最新 Gemini Flash 模型;如果它不可用,会自动尝试家族中下一个最新的模型。
你看到什么、付多少钱
响应中的 model 字段是实际作答的具体模型,例如 google/gemini-3.8-flash,因此日志和评测保持真实。计费按该模型的价格。
共有 19 个别名: google/gemini-flash-latest, google/gemini-flash-lite-latest, google/gemini-pro-latest, google/gemma-latest, deepseek/deepseek-latest, deepseek/deepseek-flash-latest, anthropic/claude-opus-latest, anthropic/claude-sonnet-latest, anthropic/claude-haiku-latest, openai/gpt-latest, openai/gpt-mini-latest, openai/gpt-nano-latest, qwen/qwen-max-latest, qwen/qwen-plus-latest, qwen/qwen-flash-latest, z-ai/glm-latest, z-ai/glm-flash-latest, moonshotai/kimi-latest 和 x-ai/grok-latest.
别名可能在不通知的情况下指向更新的模型,这可能改变输出风格、价格或支持的参数。需要稳定行为的场景请固定具体 ID。你自己发送的 models 回退列表优先。
试一试
import { createAnyRouter } from "@anyr/ai-sdk-provider"
import { generateText } from "ai"
const anyrouter = createAnyRouter()
const { text, response } = await generateText({
model: anyrouter("anthropic/claude-sonnet-latest"),
prompt: "用三个要点总结这次 diff。",
})
console.log(text, response.modelId)curl -fsSL https://anyrouter.dev/setup.sh | bash
anyr login
anyr claude --model "anthropic/claude-sonnet-latest"没有终端?打开 Playground 发送第一条消息。
在 Playground 中试用相关文章
Use AnyRouter with the Vercel AI SDK
@anyr/ai-sdk-provider wraps the AnyRouter gateway as a standard Vercel AI SDK provider. Call createAnyRouter(), pass a provider/model id, and generateText, streamText, and generateObject work unchanged — switching models is a one-string edit.
Run coding agents through one gateway
Point Claude Code, Codex, OpenCode, Cursor, or any OpenAI-compatible tool at AnyRouter and get one key for every model, unified billing, per-request audit logs, and app attribution. Two environment variables — or one npx command with the anyr CLI launcher.
Use the OpenAI SDK with any model
The official openai package for Python and TypeScript doesn't have to mean OpenAI models. Override base_url and api_key, keep every other call the same, and address 170+ models across 28+ providers as provider/model strings — including OpenAI's own.