跳轉到主要內容

Documentation Index

Fetch the complete documentation index at: https://docs.aihubmix.com/llms.txt

Use this file to discover all available pages before exploring further.

概覽

為了滿足開發者運用 Anthropic API 生態系的需求,我們的 API 現已支援透過 Anthropic API 介面存取所有模型
支援 200+ LLM,其中包含 7 個免費模型

快速開始

安裝 Anthropic SDK

pip install -U anthropic

API 用法

端點: https://aihubmix.com/v1/messages
curl https://aihubmix.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: <AIHUBMIX_API_KEY>" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "minimax-m2.1",
    "max_tokens": 16000,
    "thinking": {
      "type": "enabled",
      "budget_tokens": 10000
    },
    "messages": [
      {
        "role": "user",
        "content": "Are there an infinite number of prime numbers such that n mod 4 == 3?"
      }
    ]
  }'

相容性說明

支援的參數

透過 Anthropic API 整合時,支援下列輸入參數:
參數類型必填說明
modelstring支援的模型可參見模型清單
messagesarray of MessageParam輸入訊息
max_tokensnumber生成的最大 token 數
streamboolean啟用串流回應
systemstring or array of TextBlockParam系統提示
temperaturenumber範圍:(0.0, 1.0]。控制輸出隨機性;建議值為 1
top_pnumberNucleus sampling 參數
thinkingThinkingConfigParam推理設定

支援的訊息類型

類型說明
type="text"文字訊息
type="tool_use"工具呼叫
type="tool_result"工具呼叫結果
type="thinking"模型推理輸出

使用範例

在 Claude Code 中使用 GPT-5.2

雖然 AIHubMix 上的任何支援模型都可以透過此方式使用,但為了獲得最佳體驗,我們建議使用 gpt-5.2glm-4.7 等高能力模型。

1. 安裝並設定 Claude Code

請參考 Claude Code 安裝指南:https://docs.aihubmix.com/cn/api/Claude-Code

2. 將 Claude Code 連接到 AIHubMix

Claude 設定檔: .claude/settings.json
{
  "env": {
    "ANTHROPIC_API_KEY": "AIHUBMIX_API_KEY",
    "ANTHROPIC_BASE_URL": "https://aihubmix.com",
    "ANTHROPIC_DEFAULT_HAIKU_MODEL": "gpt-5.2",
    "ANTHROPIC_DEFAULT_OPUS_MODEL": "gpt-5.2",
    "ANTHROPIC_DEFAULT_SONNET_MODEL": "gpt-5.2",
    "ANTHROPIC_MODEL": "gpt-5.2"
  },
  "includeCoAuthoredBy": false
}
AIHUBMIX_API_KEY 替換為您實際的 AIHubMix API key。
原生 Claude Code 安裝程式無法讀取標準的 .env 檔案。請勿將上述設定置於 .env 檔案中。

3. 開始對話

切換到您的專案目錄並啟動 Claude Code:
$ cd /path/to/your-project
> claude
連接成功後,您送出的所有提示都會透過 AIHubMix 路由。

4. 驗證

您可以在 Claude Code 中執行 /status 指令來驗證連接狀態:
> /status

 API key: ANTHROPIC_API_KEY
 Anthropic base URL: https://aihubmix.com

 Model: gpt-5.2

最後更新:2026-06-01