Skip to main content

Codex

Alibaba Cloud Model Studio のモデルを Codex で使用します。

クイックスタート

  1. 1

    設定ファイルを開くか作成する

    • macOS / Linux: ~/.codex/config.toml
    • Windows: C:\Users\<username>\.codex\config.toml
  2. 2

    モデルを設定する

    モデルを切り替えるには、モデルメタデータを設定するを参照してください。
    • Token Plan
    • 従量課金
    • Coding Plan
    OPENAI_API_KEY を Token Plan の API Key に置き換えます:
    model_provider = "Token_Plan"
    model = "auto"
    
    [model_providers.Token_Plan]
    name = "Token_Plan"
    base_url = "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
    env_key = "OPENAI_API_KEY"
    wire_api = "responses"
    
  3. 3

    確認する

    プロジェクトディレクトリで次のコマンドを実行します:
    codex exec "Hello"
    

モデルメタデータを設定する

モデルメタデータは Codex でモデルを切り替えるために使用します。設定しない場合、config.toml で指定したモデルは引き続き呼び出せますが、起動時に Model metadata ... not found 警告が表示され、Codex はデフォルトのメタデータを使用します。設定後は、codex -m または TUI の /model でモデルを切り替えられます。
  • Token Plan Personal Edition
  • Token Plan Team Edition
  • 従量課金
~/.codex/model-catalog.local.json を作成し、次の内容を書き込みます:
{
  "models": [
    {
      "slug": "auto",
      "display_name": "auto",
      "description": "DashScope model: auto",
      "default_reasoning_level": "medium",
      "supported_reasoning_levels": [
        {
          "effort": "low",
          "description": "Fast responses with lighter reasoning"
        },
        {
          "effort": "medium",
          "description": "Balances speed and reasoning depth"
        },
        {
          "effort": "high",
          "description": "Greater reasoning depth for complex problems"
        },
        {
          "effort": "xhigh",
          "description": "Extra high reasoning depth for complex problems"
        }
      ],
      "context_window": 1000000,
      "effective_context_window_percent": 95,
      "supports_parallel_tool_calls": false,
      "supports_image_detail_original": false,
      "input_modalities": [
        "text"
      ],
      "shell_type": "default",
      "visibility": "list",
      "supported_in_api": true,
      "priority": 1,
      "base_instructions": "",
      "support_verbosity": false,
      "supports_reasoning_summaries": false,
      "experimental_supported_tools": [],
      "truncation_policy": {
        "mode": "bytes",
        "limit": 10000
      }
    },
    {
      "slug": "qwen4-max-preview",
      "display_name": "qwen4-max-preview",
      "description": "DashScope model: qwen4-max-preview",
      "default_reasoning_level": "xhigh",
      "supported_reasoning_levels": [
        {
          "effort": "low",
          "description": "Fast responses with lighter reasoning"
        },
        {
          "effort": "medium",
          "description": "Balances speed and reasoning depth"
        },
        {
          "effort": "xhigh",
          "description": "Extra high reasoning depth for complex problems"
        }
      ],
      "context_window": 1000000,
      "effective_context_window_percent": 95,
      "supports_parallel_tool_calls": false,
      "supports_image_detail_original": true,
      "input_modalities": [
        "text",
        "image"
      ],
      "shell_type": "default",
      "visibility": "list",
      "supported_in_api": true,
      "priority": 2,
      "base_instructions": "",
      "support_verbosity": false,
      "supports_reasoning_summaries": false,
      "experimental_supported_tools": [],
      "truncation_policy": {
        "mode": "bytes",
        "limit": 10000
      }
    },
    {
      "slug": "qwen3.8-max",
      "display_name": "qwen3.8-max",
      "description": "DashScope model: qwen3.8-max",
      "default_reasoning_level": "xhigh",
      "supported_reasoning_levels": [
        {
          "effort": "low",
          "description": "Fast responses with lighter reasoning"
        },
        {
          "effort": "medium",
          "description": "Balances speed and reasoning depth"
        },
        {
          "effort": "xhigh",
          "description": "Extra high reasoning depth for complex problems"
        }
      ],
      "context_window": 983616,
      "effective_context_window_percent": 95,
      "supports_parallel_tool_calls": false,
      "supports_image_detail_original": true,
      "input_modalities": [
        "text",
        "image"
      ],
      "shell_type": "default",
      "visibility": "list",
      "supported_in_api": true,
      "priority": 3,
      "base_instructions": "",
      "support_verbosity": false,
      "supports_reasoning_summaries": false,
      "experimental_supported_tools": [],
      "truncation_policy": {
        "mode": "bytes",
        "limit": 10000
      }
    },
    {
      "slug": "qwen3.8-flash",
      "display_name": "qwen3.8-flash",
      "description": "DashScope model: qwen3.8-flash",
      "default_reasoning_level": "xhigh",
      "supported_reasoning_levels": [
        {
          "effort": "low",
          "description": "Fast responses with lighter reasoning"
        },
        {
          "effort": "medium",
          "description": "Balances speed and reasoning depth"
        },
        {
          "effort": "xhigh",
          "description": "Extra high reasoning depth for complex problems"
        }
      ],
      "context_window": 983616,
      "effective_context_window_percent": 95,
      "supports_parallel_tool_calls": false,
      "supports_image_detail_original": true,
      "input_modalities": [
        "text",
        "image"
      ],
      "shell_type": "default",
      "visibility": "list",
      "supported_in_api": true,
      "priority": 4,
      "base_instructions": "",
      "support_verbosity": false,
      "supports_reasoning_summaries": false,
      "experimental_supported_tools": [],
      "truncation_policy": {
        "mode": "bytes",
        "limit": 10000
      }
    },
    {
      "slug": "qwen3.7-max",
      "display_name": "qwen3.7-max",
      "description": "DashScope model: qwen3.7-max",
      "default_reasoning_level": "medium",
      "supported_reasoning_levels": [
        {
          "effort": "low",
          "description": "Fast responses with lighter reasoning"
        },
        {
          "effort": "medium",
          "description": "Balances speed and reasoning depth"
        },
        {
          "effort": "high",
          "description": "Greater reasoning depth for complex problems"
        },
        {
          "effort": "xhigh",
          "description": "Extra high reasoning depth for complex problems"
        }
      ],
      "context_window": 1000000,
      "effective_context_window_percent": 95,
      "supports_parallel_tool_calls": false,
      "supports_image_detail_original": false,
      "input_modalities": [
        "text"
      ],
      "shell_type": "default",
      "visibility": "list",
      "supported_in_api": true,
      "priority": 5,
      "base_instructions": "",
      "support_verbosity": false,
      "supports_reasoning_summaries": false,
      "experimental_supported_tools": [],
      "truncation_policy": {
        "mode": "bytes",
        "limit": 10000
      }
    },
    {
      "slug": "qwen3.7-plus",
      "display_name": "qwen3.7-plus",
      "description": "DashScope model: qwen3.7-plus",
      "default_reasoning_level": "medium",
      "supported_reasoning_levels": [
        {
          "effort": "low",
          "description": "Fast responses with lighter reasoning"
        },
        {
          "effort": "medium",
          "description": "Balances speed and reasoning depth"
        },
        {
          "effort": "high",
          "description": "Greater reasoning depth for complex problems"
        },
        {
          "effort": "xhigh",
          "description": "Extra high reasoning depth for complex problems"
        }
      ],
      "context_window": 1000000,
      "effective_context_window_percent": 95,
      "supports_parallel_tool_calls": false,
      "supports_image_detail_original": true,
      "input_modalities": [
        "text",
        "image"
      ],
      "shell_type": "default",
      "visibility": "list",
      "supported_in_api": true,
      "priority": 6,
      "base_instructions": "",
      "support_verbosity": false,
      "supports_reasoning_summaries": false,
      "experimental_supported_tools": [],
      "truncation_policy": {
        "mode": "bytes",
        "limit": 10000
      }
    },
    {
      "slug": "qwen3.6-flash",
      "display_name": "qwen3.6-flash",
      "description": "DashScope model: qwen3.6-flash",
      "default_reasoning_level": "medium",
      "supported_reasoning_levels": [
        {
          "effort": "low",
          "description": "Fast responses with lighter reasoning"
        },
        {
          "effort": "medium",
          "description": "Balances speed and reasoning depth"
        },
        {
          "effort": "high",
          "description": "Greater reasoning depth for complex problems"
        },
        {
          "effort": "xhigh",
          "description": "Extra high reasoning depth for complex problems"
        }
      ],
      "context_window": 1000000,
      "effective_context_window_percent": 95,
      "supports_parallel_tool_calls": false,
      "supports_image_detail_original": true,
      "input_modalities": [
        "text",
        "image"
      ],
      "shell_type": "default",
      "visibility": "list",
      "supported_in_api": true,
      "priority": 7,
      "base_instructions": "",
      "support_verbosity": false,
      "supports_reasoning_summaries": false,
      "experimental_supported_tools": [],
      "truncation_policy": {
        "mode": "bytes",
        "limit": 10000
      }
    },
    {
      "slug": "glm-5.3",
      "display_name": "glm-5.3",
      "description": "DashScope model: glm-5.3",
      "default_reasoning_level": "medium",
      "supported_reasoning_levels": [
        {
          "effort": "low",
          "description": "Fast responses with lighter reasoning"
        },
        {
          "effort": "medium",
          "description": "Balances speed and reasoning depth"
        },
        {
          "effort": "high",
          "description": "Greater reasoning depth for complex problems"
        },
        {
          "effort": "xhigh",
          "description": "Extra high reasoning depth for complex problems"
        }
      ],
      "context_window": 1000000,
      "effective_context_window_percent": 95,
      "supports_parallel_tool_calls": false,
      "supports_image_detail_original": false,
      "input_modalities": [
        "text"
      ],
      "shell_type": "default",
      "visibility": "list",
      "supported_in_api": true,
      "priority": 8,
      "base_instructions": "",
      "support_verbosity": false,
      "supports_reasoning_summaries": false,
      "experimental_supported_tools": [],
      "truncation_policy": {
        "mode": "bytes",
        "limit": 10000
      }
    },
    {
      "slug": "glm-5.2",
      "display_name": "glm-5.2",
      "description": "DashScope model: glm-5.2",
      "default_reasoning_level": "medium",
      "supported_reasoning_levels": [
        {
          "effort": "low",
          "description": "Fast responses with lighter reasoning"
        },
        {
          "effort": "medium",
          "description": "Balances speed and reasoning depth"
        },
        {
          "effort": "high",
          "description": "Greater reasoning depth for complex problems"
        },
        {
          "effort": "xhigh",
          "description": "Extra high reasoning depth for complex problems"
        }
      ],
      "context_window": 1000000,
      "effective_context_window_percent": 95,
      "supports_parallel_tool_calls": false,
      "supports_image_detail_original": false,
      "input_modalities": [
        "text"
      ],
      "shell_type": "default",
      "visibility": "list",
      "supported_in_api": true,
      "priority": 9,
      "base_instructions": "",
      "support_verbosity": false,
      "supports_reasoning_summaries": false,
      "experimental_supported_tools": [],
      "truncation_policy": {
        "mode": "bytes",
        "limit": 10000
      }
    },
    {
      "slug": "deepseek-v4.1-flash",
      "display_name": "deepseek-v4.1-flash",
      "description": "DashScope model: deepseek-v4.1-flash",
      "default_reasoning_level": "medium",
      "supported_reasoning_levels": [
        {
          "effort": "low",
          "description": "Fast responses with lighter reasoning"
        },
        {
          "effort": "medium",
          "description": "Balances speed and reasoning depth"
        },
        {
          "effort": "high",
          "description": "Greater reasoning depth for complex problems"
        },
        {
          "effort": "xhigh",
          "description": "Extra high reasoning depth for complex problems"
        }
      ],
      "context_window": 1000000,
      "effective_context_window_percent": 95,
      "supports_parallel_tool_calls": false,
      "supports_image_detail_original": true,
      "input_modalities": [
        "text",
        "image"
      ],
      "shell_type": "default",
      "visibility": "list",
      "supported_in_api": true,
      "priority": 10,
      "base_instructions": "",
      "support_verbosity": false,
      "supports_reasoning_summaries": false,
      "experimental_supported_tools": [],
      "truncation_policy": {
        "mode": "bytes",
        "limit": 10000
      }
    },
    {
      "slug": "deepseek-v4.1-flash-1017",
      "display_name": "deepseek-v4.1-flash-1017",
      "description": "DashScope model: deepseek-v4.1-flash-1017",
      "default_reasoning_level": "medium",
      "supported_reasoning_levels": [
        {
          "effort": "low",
          "description": "Fast responses with lighter reasoning"
        },
        {
          "effort": "medium",
          "description": "Balances speed and reasoning depth"
        },
        {
          "effort": "high",
          "description": "Greater reasoning depth for complex problems"
        },
        {
          "effort": "xhigh",
          "description": "Extra high reasoning depth for complex problems"
        }
      ],
      "context_window": 1000000,
      "effective_context_window_percent": 95,
      "supports_parallel_tool_calls": false,
      "supports_image_detail_original": true,
      "input_modalities": [
        "text",
        "image"
      ],
      "shell_type": "default",
      "visibility": "list",
      "supported_in_api": true,
      "priority": 11,
      "base_instructions": "",
      "support_verbosity": false,
      "supports_reasoning_summaries": false,
      "experimental_supported_tools": [],
      "truncation_policy": {
        "mode": "bytes",
        "limit": 10000
      }
    },
    {
      "slug": "deepseek-v4-pro",
      "display_name": "deepseek-v4-pro",
      "description": "DashScope model: deepseek-v4-pro",
      "default_reasoning_level": "medium",
      "supported_reasoning_levels": [
        {
          "effort": "low",
          "description": "Fast responses with lighter reasoning"
        },
        {
          "effort": "medium",
          "description": "Balances speed and reasoning depth"
        },
        {
          "effort": "high",
          "description": "Greater reasoning depth for complex problems"
        },
        {
          "effort": "xhigh",
          "description": "Extra high reasoning depth for complex problems"
        }
      ],
      "context_window": 1000000,
      "effective_context_window_percent": 95,
      "supports_parallel_tool_calls": false,
      "supports_image_detail_original": false,
      "input_modalities": [
        "text"
      ],
      "shell_type": "default",
      "visibility": "list",
      "supported_in_api": true,
      "priority": 12,
      "base_instructions": "",
      "support_verbosity": false,
      "supports_reasoning_summaries": false,
      "experimental_supported_tools": [],
      "truncation_policy": {
        "mode": "bytes",
        "limit": 10000
      }
    },
    {
      "slug": "deepseek-v4-pro-0813",
      "display_name": "deepseek-v4-pro-0813",
      "description": "DashScope model: deepseek-v4-pro-0813",
      "default_reasoning_level": "medium",
      "supported_reasoning_levels": [
        {
          "effort": "low",
          "description": "Fast responses with lighter reasoning"
        },
        {
          "effort": "medium",
          "description": "Balances speed and reasoning depth"
        },
        {
          "effort": "high",
          "description": "Greater reasoning depth for complex problems"
        },
        {
          "effort": "xhigh",
          "description": "Extra high reasoning depth for complex problems"
        }
      ],
      "context_window": 1000000,
      "effective_context_window_percent": 95,
      "supports_parallel_tool_calls": false,
      "supports_image_detail_original": false,
      "input_modalities": [
        "text"
      ],
      "shell_type": "default",
      "visibility": "list",
      "supported_in_api": true,
      "priority": 13,
      "base_instructions": "",
      "support_verbosity": false,
      "supports_reasoning_summaries": false,
      "experimental_supported_tools": [],
      "truncation_policy": {
        "mode": "bytes",
        "limit": 10000
      }
    },
    {
      "slug": "deepseek-v4-flash-0731",
      "display_name": "deepseek-v4-flash-0731",
      "description": "DashScope model: deepseek-v4-flash-0731",
      "default_reasoning_level": "medium",
      "supported_reasoning_levels": [
        {
          "effort": "low",
          "description": "Fast responses with lighter reasoning"
        },
        {
          "effort": "medium",
          "description": "Balances speed and reasoning depth"
        },
        {
          "effort": "high",
          "description": "Greater reasoning depth for complex problems"
        },
        {
          "effort": "xhigh",
          "description": "Extra high reasoning depth for complex problems"
        }
      ],
      "context_window": 1000000,
      "effective_context_window_percent": 95,
      "supports_parallel_tool_calls": false,
      "supports_image_detail_original": false,
      "input_modalities": [
        "text"
      ],
      "shell_type": "default",
      "visibility": "list",
      "supported_in_api": true,
      "priority": 14,
      "base_instructions": "",
      "support_verbosity": false,
      "supports_reasoning_summaries": false,
      "experimental_supported_tools": [],
      "truncation_policy": {
        "mode": "bytes",
        "limit": 10000
      }
    }
  ]
}
~/.codex/config.toml に次を追加します:
model_catalog_json = "~/.codex/model-catalog.local.json"
設定後、codex -m でモデル ID を指定するか(例:codex -m qwen3.8-flash)、TUI で /model を入力して設定済みのモデルを切り替えます。

Chat Completions の設定

Codex 0.94.0 以降は Responses API のみをサポートします。Codex 0.93.0 以前を使用する場合、またはモデルが Chat Completions のみをサポートする場合は、次の設定を使用します。設定ファイルのパスについては、クイックスタートを参照してください。
  • Token Plan
  • 従量課金
  • Coding Plan
OPENAI_API_KEY を Token Plan の API Key に置き換えます:
model_provider = "Token_Plan"
model = "auto"

[model_providers.Token_Plan]
name = "Token_Plan"
base_url = "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"
env_key = "OPENAI_API_KEY"
wire_api = "chat"

CC Switch を使用する

CC Switch は、API Key や課金プランを切り替えるためのコミュニティ製オープンソースデスクトップ GUI です。

プロバイダーを追加する

  1. 1
    CC Switch のツールバーで Codex アイコンを選択し、+ をクリックして Add provider を開き、課金プランのタブを選択して設定を入力し、Add をクリックします。
    • Token Plan
    • 従量課金
    • Coding Plan
    • プロバイダー名: Bailian-Token Plan
    • API Key: コンソールから取得
    • エンドポイント: https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1
  2. 2
    Advanced options を展開し、お使いのプランでサポートされているモデルからモデル(例: qwen3.8-max)を入力します。
  3. 3
    プロバイダーの横にある Enable をクリックし、ターミナルを開き直して codex を実行すると、設定が有効になります。

エラーコード

設定中にエラーが発生した場合は、課金プランの FAQ ドキュメントを参照してください:

FAQ

モデルメタデータが未設定の場合に表示される警告です。Codex はデフォルトのメタデータでモデルを処理し、呼び出しには影響しません。モデルを切り替えるには、モデルメタデータを設定するを参照してください。
従量課金の接続方法は変わりません。Model Studio の汎用 API Key と Base URL を使用します。節約プランを購入すると自動的に有効になり、対象の利用料金が自動的に控除されます。詳細は節約プランをご参照ください。
原因: CC-Switch などの一部のサードパーティ製管理ツールは、プロバイダーを切り替えるときにヘルスチェックや接続テストのプローブを送信します。プローブの形式は Codex が実際に使用するリクエスト形式と異なるため、Model Studio ゲートウェイが 400 Bad request を返し、ツールが "domestic models not supported" と報告することがあります。このメッセージはプローブが失敗したことだけを示しています。Model Studio が中国本土のモデルをサポートしていないという意味ではなく、実際の Codex の使用にも影響しません。解決策: クイックスタートの説明に従って ~/.codex/config.toml で Codex を直接設定し、サードパーティ製ツールのヘルスチェックには依存しないでください。設定後は確認の手順で Codex を起動します。正常な応答が返れば、中国本土のモデルが動作しています。
原因: Codex 0.94.0 以降は wire_api = "chat" をサポートしなくなりました。バージョンによって、次のいずれかのエラーが表示される場合があります:
  • wire_api = "chat" is no longer supported
  • unknown configuration field wire_api
解決策:
  • エラー wire_api = "chat" is no longer supported: wire_api を responses に変更し、base_url を確認します。
  • エラー unknown configuration field wire_api: ~/.codex/config.toml の該当するプロバイダーセクションから wire_api を削除します。
  • Chat Completions を引き続き使用するには、Codex 0.93.0 以前(0.80.0 など)をインストールします。
原因:
  • API Key が別のプランに属しています(Token Plan、Coding Plan、従量課金のキーは相互に使用できません)。
  • サブスクリプションの有効期限が切れています。
  • API Key のコピーが正しくありません(不完全、余分なスペース、入力ミスなど)。
解決策:
  • 選択したプランの API Key を使用していることを確認します。
  • プラン管理ページでサブスクリプションの有効期限を確認します。
  • API Key を再コピーし、余分なスペースがなく完全であることを確認します。
  • エラーが続く場合は、プラン管理ページで API Key をリセットし、新しいキーを設定します。
原因: 設定ファイルの base_url または wire_api が正しくありません。解決策: base_url と wire_api がプランの設定と一致していることを確認します。クイックスタートを参照してください。
原因: Codex とサーバー間のストリーミング接続が、応答が完了する前に閉じられました。一般的な原因は次のとおりです:
  • 会話スレッドが長すぎて、コンテキストの圧縮に失敗しました。
  • ネットワークが不安定で、SSE または WebSocket 接続が切断されました。
  • サーバーが過負荷状態にあるか、レート制限によって接続が早期に終了しました。
解決策:
  • コンテキストの過度な蓄積を避けるため、新しい会話スレッドを開始します。
  • ネットワークの安定性を確認します。VPN またはプロキシを無効にして再試行します。
  • しばらく待ってから再試行します。Codex には組み込みの再試行メカニズムがあり、ほとんどの一時的な障害は解決されます。
原因: 429 エラーには主に次の 2 つの原因があります:
  • リクエストのレート制限(429 Requests rate limit exceeded): 短時間にリクエストが集中しすぎています。
  • クォータの枯渇(429 Allocated quota exceeded または Your token-plan quota has been exhausted): Token Plan の月間クォータを使い切りました。
解決策:
  • リクエストのレート制限: 1 分待ってから、リクエストの頻度を下げます。
  • クォータの枯渇: 次のサブスクリプション月を待つか、使用量パッケージを購入するか(月間クォータを使い切ると、パッケージからクォータが自動的に差し引かれます)、プランをアップグレードします。エラーメッセージ内のリセット時刻(The quota will reset at HH:MM:SS UTC など)は UTC です。8 時間を加えてシンガポール時間(CST)に変換してください。