Unify API
Keep the Responses API. Reach every model.Giữ Responses API. Dùng mọi model.保留 Responses API,调用所有模型。
Use the OpenAI Responses API with typed output items and stored, continuable responses across every model.Dùng OpenAI Responses API với output có kiểu và response được lưu, nối tiếp được, trên mọi model.在所有模型上使用 OpenAI Responses API:类型化输出项,响应可存储、可续接。
diff --git a/app.py b/app.pyimport osfrom openai import OpenAIclient = OpenAI(removed: api_key=os.environ["OPENAI_API_KEY"],added: base_url="https://anyrouter.dev/api/v1",added: api_key=os.environ["ANYROUTER_API_KEY"],)resp = client.responses.create(removed: model="gpt-5-mini",added: model="anyrouter/free", input="Hi",)print(resp.output_text)What came backKết quả trả về返回了什么
The cURL tab above, run on prod on 2026-10-31 with a Go key. Only the fields shown are kept, and long values are cut with "…".Tab cURL ở trên, chạy trên prod ngày 2026-10-31 với key gói Go. Chỉ giữ các field hiển thị, giá trị dài được cắt bằng "…".上面的 cURL 标签页,于 2026-10-31 在生产环境用 Go 套餐 key 运行。只保留显示的字段,过长的值用 "…" 截断。
HTTP 200
x-anyrouter-model: poolside/laguna-s-2.1
x-anyrouter-provider-chain: hagiang
x-anyrouter-credential-source: platform
x-request-id: req_a7e68fe692c24a6c91dc5412
{
"object": "response",
"status": "completed",
"output_text": "Hello! How can I help you today?",
"usage": {
"input_tokens": 45,
"output_tokens": 10,
"cost": 0
}
}- x-anyrouter-model
- The model that answered. A preset such as anyrouter/free names its pick here; pin a model id and it echoes yours.Model đã trả lời. Preset như anyrouter/free ghi model nó chọn ở đây; chỉ định model id thì header lặp lại id của bạn.实际回答的模型。anyrouter/free 等预设会在这里写出所选模型;指定模型 id 时则原样返回你的 id。
- x-anyrouter-provider-chain
- Each upstream tried, in order. One hop here; when a hop fails the next one answers and the header reads a->b.Các upstream đã thử, theo thứ tự. Ở đây chỉ một chặng; khi một chặng lỗi, chặng sau trả lời và header thành a->b.按顺序尝试过的上游。这里只有一跳;某一跳失败时由下一跳回答,header 变为 a->b。
- x-anyrouter-credential-source
- Whose upstream key paid: platform (ours), own_byok (yours) or pool (a donated key).Key upstream nào đã trả: platform (của chúng tôi), own_byok (của bạn) hoặc pool (key được đóng góp).由谁的上游 key 付费:platform(平台)、own_byok(你自己的)或 pool(捐赠的 key)。
- x-request-id
- Quote it to support, or find the request in your logs.Gửi cho bộ phận hỗ trợ, hoặc tìm request trong log của bạn.联系支持时提供它,或在日志中查找该请求。
- usage.cost
- What this request cost you, in USD, in the body. Zero on free models.Chi phí của request này, tính bằng USD, nằm trong body. Bằng 0 với model miễn phí.本次请求的费用(美元),写在 body 里。免费模型为 0。
Optional: steer the routeTùy chọn: điều hướng route可选:控制路由
Nothing below is required. Each one is a single field or header on the same request, captured on prod.Không mục nào bắt buộc. Mỗi mục là một field hoặc header trên cùng request, chạy thật trên prod.以下都不是必需的。每项只是同一请求上的一个字段或 header,均在生产环境实测。
Pick any model idChọn model id bất kỳ指定任意模型 id
Use owner/model from the catalog instead of a preset.Dùng owner/model trong danh mục thay cho preset.用目录里的 owner/model 代替预设。
"model": "nvidia/nemotron-3-nano-omni-30b-a3b-reasoning" → HTTP 200, provider-chain: hagiangPin a providerChỉ định provider固定提供商
One header, comma-separated in order of preference.Một header, phân tách bằng dấu phẩy theo thứ tự ưu tiên.一个 header,按偏好顺序用逗号分隔。
X-AnyRouter-Provider: hagiang,kilo "model": "poolside/laguna-s-2.1" → HTTP 200, provider-chain: hagiangOrder providers in the bodySắp thứ tự provider trong body在 body 中排序提供商
The same idea as OpenRouter's provider object.Giống object provider của OpenRouter.与 OpenRouter 的 provider 对象相同。
"model": "nvidia/nemotron-3-ultra-550b-a55b" "provider": {"order": ["hagiang", "kilo"]} → HTTP 200, provider-chain: hagiang
What worksHỗ trợ已支持
- Streaming (SSE)Streaming (SSE)流式输出(SSE)
- Tools / function callingTools / gọi hàm工具 / 函数调用
- Reasoning effortMức độ suy luận (reasoning)推理强度
- Image input on vision modelsNhận ảnh với model hỗ trợ vision视觉模型支持图像输入
- Stored responses (previous_response_id)Lưu và nối tiếp response (previous_response_id)存储与续接响应(previous_response_id)
Decisions modelsModel DecisionsDecisions 模型
Not a chat. Send a situation and a question with fixed choices, and get a probability for each choice back. Decisions are free on Go and up, with a 5-request trial on Free.Không phải chat. Gửi một tình huống và câu hỏi có các lựa chọn cố định, nhận lại xác suất cho từng lựa chọn. Decisions miễn phí từ gói Go trở lên, gói Free có 5 request dùng thử.不是聊天。发送一个情境和带固定选项的问题,返回每个选项的概率。Decisions 在 Go 及以上套餐免费,Free 套餐可试用 5 次请求。
curl https://anyrouter.dev/api/v1/decisions \
-H "Authorization: Bearer $ANYROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "hal-x/thx-01", "state": "My card was charged twice",
"questions": {"team": {"type": "choice", "criteria": {"billing": "Payments", "tech": "API problems"}}}}'
# {"answers": {"team": {"type": "choice", "choice": "billing", "probabilities": {"billing": 0.97, "tech": 0.03}}}, "model": "hal-x/thx-01", "status": "completed"}