> ## 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 互換（Beta）

## 概要

開発者の Anthropic API エコシステム活用ニーズに応えるため、当社の API は **Anthropic API インターフェース経由ですべてのモデルにアクセス**できるようになりました。\
**200以上のLLM** をサポートし、**7つの無料モデル**を含みます。

## クイックスタート

### Anthropic SDK のインストール

<CodeGroup>
  ```shellscript Python theme={null}
  pip install -U anthropic
  ```

  ```shellscript Node.js theme={null}
  npm install @anthropic-ai/sdk
  ```
</CodeGroup>

### API の使用方法

**エンドポイント：** `https://aihubmix.com/v1/messages`

<CodeGroup>
  ```shellscript Curl theme={null}
  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?"
        }
      ]
    }'
  ```

  ```python Python theme={null}
  from anthropic import Anthropic

  client = Anthropic(
    api_key="<AIHUBMIX_API_KEY>",
    base_url="https://aihubmix.com"
  )

  response = client.messages.create(
    model="glm-4.7",
    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?"
        }
    ]
  )

  # The response contains summarized thinking blocks and text blocks
  for block in response.content:
      if block.type == "thinking":
          print(f"\nThinking summary: {block.thinking}")
      elif block.type == "text":
          print(f"\nResponse: {block.text}")
  ```
</CodeGroup>

## 互換性に関する注意事項

### サポートされるパラメータ

Anthropic API 経由で連携する際、以下の入力パラメータがサポートされます：

| パラメータ         | タイプ                               | 必須  | 説明                                                      |
| ------------- | --------------------------------- | --- | ------------------------------------------------------- |
| `model`       | string                            | はい  | サポート対象モデルは [モデル一覧](https://aihubmix.com/models) で確認できます |
| `messages`    | array of MessageParam             | はい  | 入力メッセージ                                                 |
| `max_tokens`  | number                            | いいえ | 生成する最大トークン数                                             |
| `stream`      | boolean                           | いいえ | ストリーミング応答を有効にする                                         |
| `system`      | string or array of TextBlockParam | はい  | システムプロンプト                                               |
| `temperature` | number                            | いいえ | 範囲: (0.0, 1.0]。出力のランダム性を制御。推奨値は 1                       |
| `top_p`       | number                            | いいえ | Nucleus サンプリングパラメータ                                     |
| `thinking`    | ThinkingConfigParam               | いいえ | 推論設定                                                    |

### サポートされるメッセージタイプ

| タイプ                  | 説明        |
| -------------------- | --------- |
| `type="text"`        | テキストメッセージ |
| `type="tool_use"`    | ツール呼び出し   |
| `type="tool_result"` | ツール呼び出し結果 |
| `type="thinking"`    | モデルの推論出力  |

## 使用例

### Claude Code で GPT-5.2 を使用する

AIHubMix 経由ではサポート対象のあらゆるモデルを使用できますが、最良の体験のためには **gpt-5.2** や **glm-4.7** のような高性能モデルを推奨します。

#### 1. Claude Code のインストールと設定

Claude Code のインストールガイドを参照してください：[https://docs.aihubmix.com/cn/api/Claude-Code](https://docs.aihubmix.com/cn/api/Claude-Code)

#### 2. Claude Code を AIHubMix に接続する

**Claude 設定ファイル：** `.claude/settings.json`

```json theme={null}
{
  "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 キーに置き換えてください。

<Tip>
  ネイティブの Claude Code インストーラは標準の `.env` ファイルを読み込むことができません。これらの設定を `.env` ファイルに記述しないでください。
</Tip>

#### 3. 会話を開始する

プロジェクトディレクトリに移動して Claude Code を起動します：

```bash theme={null}
$ cd /path/to/your-project
> claude
```

接続に成功すると、送信するすべてのプロンプトが AIHubMix 経由で処理されます。

#### 4. 確認

Claude Code 内で `/status` コマンドを実行することで、接続を確認できます：

```bash theme={null}
> /status

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

 Model: gpt-5.2
```

***

最終更新日：2026-06-01
