Base URL
Mọi endpoint của cheapaimodel dùng chung một host. Đây là Base URL chính xác cho từng SDK và công cụ.
Mọi endpoint đều nằm trên một host:
https://api.cheapaimodel.aiKhông có host theo khu vực và không có host riêng cho từng nhà cung cấp. Cùng một API key và cùng một số dư dùng được cho cả hai định dạng bên dưới.
Dùng giá trị nào
Client kiểu OpenAI cần Base URL có sẵn /v1; client kiểu Anthropic chỉ cần host (không kèm /v1) và tự thêm /v1/messages.
| Định dạng | Base URL | Yêu cầu được gửi tới |
|---|---|---|
| Tương thích OpenAI | https://api.cheapaimodel.ai/v1 | /v1/chat/completions, /v1/responses, /v1/embeddings, /v1/models |
| Anthropic Messages | https://api.cheapaimodel.ai | /v1/messages |
Theo SDK và công cụ
| Client | Thiết lập | Giá trị |
|---|---|---|
| OpenAI SDK (Python) | base_url | https://api.cheapaimodel.ai/v1 |
| OpenAI SDK (TypeScript) | baseURL | https://api.cheapaimodel.ai/v1 |
| SDK OpenAI qua biến môi trường | OPENAI_BASE_URL | https://api.cheapaimodel.ai/v1 |
| LangChain (Python / TypeScript) | base_url / configuration.baseURL | https://api.cheapaimodel.ai/v1 |
| LlamaIndex | api_base trong OpenAILike | https://api.cheapaimodel.ai/v1 |
| Vercel AI SDK | baseURL trong createOpenAICompatible | https://api.cheapaimodel.ai/v1 |
| LiteLLM | api_base (mô hình openai/<id>) | https://api.cheapaimodel.ai/v1 |
| Anthropic SDK (Python / TypeScript) | base_url / baseURL | https://api.cheapaimodel.ai |
| SDK Anthropic qua biến môi trường | ANTHROPIC_BASE_URL | https://api.cheapaimodel.ai |
| Claude Code | ANTHROPIC_BASE_URL | https://api.cheapaimodel.ai |
| Codex CLI | base_url trong config.toml | https://api.cheapaimodel.ai/v1 |
| Cursor | Override OpenAI Base URL | https://api.cheapaimodel.ai/v1 |
| Cline | Base URL | https://api.cheapaimodel.ai/v1 |
| Continue | apiBase trong config.yaml | https://api.cheapaimodel.ai/v1 |
| Zed | api_url trong settings.json | https://api.cheapaimodel.ai/v1 |
| Aider | OPENAI_API_BASE hoặc --openai-api-base | https://api.cheapaimodel.ai/v1 |
| Open WebUI | URL của kết nối OpenAI API | https://api.cheapaimodel.ai/v1 |
| Dify | API Base URL (OpenAI-API-compatible) | https://api.cheapaimodel.ai/v1 |
| n8n | Base URL trong credential OpenAI | https://api.cheapaimodel.ai/v1 |
| OpenClaw | baseUrl trong models.providers | https://api.cheapaimodel.ai/v1 |
| curl | URL đầy đủ | https://api.cheapaimodel.ai/v1/<endpoint> |
Lỗi thường gặp
- Thêm
/v1cho client Anthropic. SDK tự thêm/v1/messages, nên yêu cầu bị gửi tới/v1/v1/messagesvà trả về404kèm thông báoInvalid URL (POST /v1/v1/messages). Chỉ dùng host, không kèm/v1. - Thiếu
/v1cho client OpenAI. Yêu cầu bị gửi tới/chat/completions(không phải đường dẫn API) và trả về404với body văn bản thuầnfault filter abort, không phải JSON. Thêm/v1. - Đưa cả đường dẫn endpoint vào Base URL. Đặt
https://api.cheapaimodel.ai/v1, không phảihttps://api.cheapaimodel.ai/v1/chat/completions; SDK sẽ tự thêm đường dẫn, và đường dẫn bị lặp sẽ trả về404. - Dùng host của trang web hoặc bảng điều khiển.
cheapaimodel.aivàconsole.cheapaimodel.aichỉ là trang web, không phải API.
Khi Base URL đã đúng, gửi key như mô tả trong Xác thực và API key.