Base URL
Endpoint API AnyRouter là:
https://anyrouter.dev/api/v1Mọi route chuẩn tương thích OpenAI nằm dưới prefix này: /v1/chat/completions, /v1/embeddings, /v1/models, v.v.
Xác thực
Truyền API key trong header Authorization chuẩn:
curl https://anyrouter.dev/api/v1/chat/completions \
-H "Authorization: Bearer sk-ar-v1-placeholder" \
-H "Content-Type: application/json" \
-d '{"model":"anyrouter/free","messages":[{"role":"user","content":"Hi"}]}'Key bắt đầu bằng sk-ar-v1-. Tạo trên dashboard AnyRouter.
Định dạng model id
Model id theo quy ước provider/model:
- anthropic/claude-sonnet-4-5
- openai/gpt-5.5
- google/gemini-2.5-pro
- z-ai/glm-5.2
- anyrouter/free (tầng miễn phí pool dùng chung)
Prefix nhà cung cấp nói AnyRouter route lên upstream nào. Bỏ prefix hoặc dùng id không nhận ra thì 404.
Định dạng request
Body theo schema OpenAI Chat Completions. Các trường phổ biến nhất:
| Trường | Kiểu | Bắt buộc | Ghi chú |
|---|---|---|---|
| model | string | Có | provider/model id |
| messages | array | Có | Lịch sử hội thoại |
| temperature | number | Không | 0–2, mặc định 1 |
| max_tokens | integer | Không | Số token hoàn thành tối đa |
| stream | boolean | Không | true để SSE streaming |
| tools | array | Không | Định nghĩa function/tool |
Phản hồi streaming
Set stream: true để nhận Server-Sent Events. AnyRouter chuyển nguyên định dạng streaming của upstream. Xử lý SSE giống API gốc của nhà cung cấp.
Phản hồi lỗi
AnyRouter trả mã HTTP chuẩn:
- 200 — thành công
- 400 — body request sai dạng
- 401 — API key sai hoặc thiếu
- 404 — không tìm thấy model hoặc chưa cấu hình nhà cung cấp
- 429 — vượt rate limit (xem hướng dẫn 429)
- 500/502/503 — lỗi upstream hoặc gateway
Đi tiếp từ đây
Tham chiếu API tương tác đầy đủ với mọi endpoint và schema ở docs.anyrouter.dev. Để giám sát và debug, dùng chmonitor.dev xem trace từng request: upstream, latency, token, và chi phí.
API tương thích OpenAI, $2 credit miễn phí, không cần thẻ.
Lấy API keyBài liên quan
OpenRouter alternatives 2026: how AnyRouter differs
OpenRouter alternatives 2026, without invented rankings: AnyRouter is one OpenRouter alternative with $0-markup BYOK, a donated shared pool, a $2/mo Go plan, Cloudflare-edge routing, on-device models via local relay, a built-in MCP server, and open pricing config.
Run Claude Code on AnyRouter — wrapper script or CLI
Route Claude Code through AnyRouter in two ways: a wrapper that installs itself and maps Opus, Sonnet, and Haiku to one catalog model (override with --model), or the anyr CLI launcher. One key, unified billing, audit logs.