# Base URL (/zh-Hant/docs/api/base-url)

所有 cheapaimodel 端點共用的單一主機，以及各 SDK 與工具需要的確切 Base URL。



所有端點都位於同一個主機：

```text
https://api.cheapaimodel.ai
```

沒有區域主機，也沒有依供應商區分的獨立主機。下列兩種協定都使用同一組 API Key 與同一份餘額。

## 該用哪個值 [#which-value-to-use]

OpenAI 風格的用戶端預期 Base URL 包含 `/v1`；Anthropic 風格的用戶端預期不含路徑的主機，並自行加上 `/v1/messages`。

| 協定                 | Base URL                         | 請求送往                                                                 |
| ------------------ | -------------------------------- | -------------------------------------------------------------------- |
| OpenAI 相容          | `https://api.cheapaimodel.ai/v1` | `/v1/chat/completions`、`/v1/responses`、`/v1/embeddings`、`/v1/models` |
| Anthropic Messages | `https://api.cheapaimodel.ai`    | `/v1/messages`                                                       |

## 依 SDK 與工具 [#by-sdk-and-tool]

| 用戶端                                                                      | 設定項                                     | 值                                           |
| ------------------------------------------------------------------------ | --------------------------------------- | ------------------------------------------- |
| [OpenAI SDK](/zh-Hant/docs/guides/openai-sdk)（Python）                    | `base_url`                              | `https://api.cheapaimodel.ai/v1`            |
| [OpenAI SDK](/zh-Hant/docs/guides/openai-sdk)（TypeScript）                | `baseURL`                               | `https://api.cheapaimodel.ai/v1`            |
| OpenAI SDK（透過環境變數）                                                       | `OPENAI_BASE_URL`                       | `https://api.cheapaimodel.ai/v1`            |
| [LangChain](/zh-Hant/docs/guides/langchain)（Python / TypeScript）         | `base_url` / `configuration.baseURL`    | `https://api.cheapaimodel.ai/v1`            |
| [LlamaIndex](/zh-Hant/docs/guides/llamaindex)                            | `OpenAILike` 的 `api_base`               | `https://api.cheapaimodel.ai/v1`            |
| [Vercel AI SDK](/zh-Hant/docs/guides/vercel-ai-sdk)                      | `createOpenAICompatible` 的 `baseURL`    | `https://api.cheapaimodel.ai/v1`            |
| [LiteLLM](/zh-Hant/docs/guides/litellm)                                  | `api_base`（模型寫 `openai/<id>`）           | `https://api.cheapaimodel.ai/v1`            |
| [Anthropic SDK](/zh-Hant/docs/guides/anthropic-sdk)（Python / TypeScript） | `base_url` / `baseURL`                  | `https://api.cheapaimodel.ai`               |
| Anthropic SDK（透過環境變數）                                                    | `ANTHROPIC_BASE_URL`                    | `https://api.cheapaimodel.ai`               |
| [Claude Code](/zh-Hant/docs/guides/claude-code)                          | `ANTHROPIC_BASE_URL`                    | `https://api.cheapaimodel.ai`               |
| [Codex CLI](/zh-Hant/docs/guides/codex-cli)                              | `config.toml` 中的 `base_url`             | `https://api.cheapaimodel.ai/v1`            |
| [Cursor](/zh-Hant/docs/guides/cursor)                                    | Override OpenAI Base URL                | `https://api.cheapaimodel.ai/v1`            |
| [Cline](/zh-Hant/docs/guides/cline)                                      | Base URL                                | `https://api.cheapaimodel.ai/v1`            |
| [Continue](/zh-Hant/docs/guides/continue)                                | `config.yaml` 中的 `apiBase`              | `https://api.cheapaimodel.ai/v1`            |
| [Zed](/zh-Hant/docs/guides/zed)                                          | `settings.json` 中的 `api_url`            | `https://api.cheapaimodel.ai/v1`            |
| [Aider](/zh-Hant/docs/guides/aider)                                      | `OPENAI_API_BASE` 或 `--openai-api-base` | `https://api.cheapaimodel.ai/v1`            |
| [Open WebUI](/zh-Hant/docs/guides/open-webui)                            | OpenAI API 連線的 URL                      | `https://api.cheapaimodel.ai/v1`            |
| [Dify](/zh-Hant/docs/guides/dify)                                        | API Base URL（OpenAI-API-compatible）     | `https://api.cheapaimodel.ai/v1`            |
| [n8n](/zh-Hant/docs/guides/n8n)                                          | OpenAI 憑證的 Base URL                     | `https://api.cheapaimodel.ai/v1`            |
| [OpenClaw](/zh-Hant/docs/guides/openclaw)                                | `models.providers` 中的 `baseUrl`         | `https://api.cheapaimodel.ai/v1`            |
| [curl](/zh-Hant/docs/guides/curl)                                        | 完整 URL                                  | `https://api.cheapaimodel.ai/v1/<endpoint>` |

## 常見錯誤 [#common-mistakes]

* **在 Anthropic 用戶端加上 `/v1`。** SDK 會自行加上 `/v1/messages`，於是請求送往 `/v1/v1/messages`，並以 `404` 與 `Invalid URL (POST /v1/v1/messages)` 失敗。請使用不含路徑的主機。
* **OpenAI 用戶端漏了 `/v1`。** 請求會送往 `/chat/completions`，這不是 API 路徑，會以 `404` 失敗，回應是純文字 `fault filter abort` 而不是 JSON。請加上 `/v1`。
* **在 Base URL 中寫入端點路徑。** 請設定 `https://api.cheapaimodel.ai/v1`，而不是 `https://api.cheapaimodel.ai/v1/chat/completions`；SDK 會自行加上路徑，重複的路徑會以 `404` 失敗。
* **使用網站或控制台的主機。** `cheapaimodel.ai` 與 `console.cheapaimodel.ai` 提供的是網頁，不是 API。

Base URL 設定正確後，請依[驗證與 API Key](/zh-Hant/docs/concepts/authentication) 的說明傳送你的 Key。
