Làm sao chỉ Claude Code vào custom base URL?
Claude Code đọc hai biến môi trường cho kết nối nhà cung cấp: ANTHROPIC_BASE_URL và ANTHROPIC_API_KEY. Đặt chúng thành endpoint AnyRouter và key AnyRouter, mọi request Claude Code tạo — phiên chính, subagent, tác vụ nền — đi qua tài khoản của bạn thay vì thẳng Anthropic.
export ANTHROPIC_BASE_URL="https://anyrouter.dev/api"
export ANTHROPIC_API_KEY="sk-ar-your-anyrouter-key"
claudeViệc này chạy vì Claude Code nói phương ngữ Anthropic /messages, và AnyRouter phục vụ cùng phương ngữ cho mọi model trong catalog — client không biết request đã rời hạ tầng của Anthropic.
anyr CLI setup giúp bạn
Không muốn tự quản biến môi trường, launcher anyr xử lý login, lưu key và môi trường một lệnh:
# Install the native CLI (no Node required)
curl -fsSL https://anyrouter.dev/setup.sh | bash
anyr login
# Launch Claude Code through AnyRouter
anyr claude
# Pin a specific model for this session
anyr claude --model "z-ai/glm-5.2"
# Preview the environment without launching
anyr claude --dry-runConfig lưu vào ~/.anyrouter/config.yaml và dùng lại — bởi claude, và mọi launcher khác CLI mang theo (codex, cursor). Mọi thứ sau -- chuyển thẳng cho Claude Code, flag cũ vẫn chạy (anyr claude -- --resume).
Chạy Codex và Cursor trên cùng key
Không chỉ Claude Code đáng route kiểu này. Codex và Cursor nói phương ngữ OpenAI, AnyRouter phục vụ cả hai từ cùng tài khoản — một key cho mọi agent bạn chạy.
| Agent | Giao thức | Biến môi trường |
|---|---|---|
| Claude Code | Anthropic /messages | ANTHROPIC_BASE_URL, ANTHROPIC_API_KEY |
| Codex | OpenAI /chat/completions | OPENAI_BASE_URL, OPENAI_API_KEY |
| OpenCode | OpenAI /chat/completions | anyr opencode, or opencode.json provider |
| Cursor | OpenAI-compatible custom model | Base URL + key pasted into settings |
Dù combo nào, request từ mọi tool vào cùng số dư, cùng audit log từng request, cùng rate limit — không tài khoản riêng từng agent.
Đổi model Claude Code dùng mà không rời terminal
Model id trên AnyRouter là chuỗi provider/model, nên đổi thứ Claude Code chạy cho một task là một flag, không phải viết lại. Sửa rẻ/nhanh một đường, refactor khó một đường, cùng phiên.
- Route trên key của bạn markup $0 — anyrouter/coding gửi tới subset coding trong BYOK đã cấu hình.
- Ghim model cho bài khó — anyr claude --model "anthropic/claude-opus-4-8".
- Xem hành vi model trước khi nối — thử live ở /playground.

Đi tiếp từ đây
Bức tranh rộng hơn khi route mọi tool tương thích OpenAI hoặc Anthropic qua một tài khoản — gồm header app-attribution để từng tool hiện riêng trong analytics — xem /blog/vi/coding-agents-one-gateway. Route trên key nhà cung cấp bạn đã trả, xem /blog/vi/byok-bring-your-own-keys.
- Tham chiếu CLI đầy đủ và flag — /cli.
- Endpoint và header — /docs.
- Thử model live trước khi nối — /playground.
Chỉ Claude Code vào AnyRouter, mọi model sau một key.
Setup miễn phíBài liên quan
Use OpenCode with AnyRouter — CLI launcher or opencode.json
Point the OpenCode coding agent at AnyRouter in one command, or add a custom Chat Completions provider in opencode.json. One sk-ar- key reaches every catalog model, with unified billing and request logs.
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.
Gửi request đầu trong hai phút
Bắt đầu miễn phí với key của bạn, hoặc nạp rồi trả theo token. Go: $4 credit/tháng — $2/tháng, hoặc miễn phí khi góp một provider key.
Bắt đầu miễn phí