BazaarLinkBazaarLink
登入
文件API 參考SDK 參考Agent 應用AI Skills

Codex CLI 接 BazaarLink:config.toml 設定與實測(/v1/responses)

依照這份指南,將 Codex CLI 的 Responses API 連線指向 BazaarLink,然後用一個指令檢查設定。

實測環境:Codex CLI 0.160.0、模型 openai/gpt-5.4-mini、2026-10-05。模型清單與名稱可能調整,請以模型頁為準。

開始前

需要 Codex CLI 與 BazaarLink API Key。以下範例把金鑰放在環境變數,不寫入 config.toml。

1. 取得 API Key 並設環境變數

取得 BazaarLink API Key 後,在執行 Codex CLI 的終端機設定 BAZAARLINK_API_KEY。請用自己的金鑰取代範例佔位文字。

macOS / Linux

export BAZAARLINK_API_KEY="YOUR_BAZAARLINK_API_KEY"

Windows PowerShell

$env:BAZAARLINK_API_KEY = "YOUR_BAZAARLINK_API_KEY"

2. 編輯 ~/.codex/config.toml

在 Windows,對應路徑是 %USERPROFILE%\.codex\config.toml。把下列設定寫入檔案;如果已有設定,請調整相同欄位。

config.toml
model = "openai/gpt-5.4-mini"
model_provider = "bazaarlink"

[model_providers.bazaarlink]
name = "BazaarLink"
base_url = "https://api.bazaarlink.ai/v1"
env_key = "BAZAARLINK_API_KEY"
wire_api = "responses"

3. 跑第一個指令

在終端機執行以下測試指令。這是 2026-10-05 實測使用的指令。

codex exec --skip-git-repo-check "Reply with exactly one line: hello from BazaarLink"

實測輸出摘要

provider: bazaarlink
model: openai/gpt-5.4-mini
hello from BazaarLink
tokens used

實測時,標頭顯示 provider 與 model,回答是一行 hello from BazaarLink,末尾顯示 tokens used。即使提示很短,Codex 仍會傳送自己的系統指令和工具定義;該次約用了 10k tokens。

該次測試中,模型發出 shell 函式呼叫,Codex 在本機執行或阻擋後把結果送回,模型接著回答。這驗證了 /v1/responses 的 function_call 往返;不代表所有 Codex 功能都已驗證。

4. 換模型

config.toml 的 model 值可以換成模型頁(/models)上列出的任何模型。

把 config.toml 的 model 值換成模型頁或 GET /v1/models 列出的可用 model ID。金鑰或路由未啟用的模型可能回傳 503,請選另一個 model ID。

5. 常見問題與疑難排解

Model metadata 警告

Codex 可能顯示 `Model metadata for openai/gpt-5.4-mini not found. Defaulting to fallback metadata`,標頭也可能顯示 `reasoning effort: none`。這是本次實測看到的警告,可忽略。

HTTP 503:模型不可用

若看到 `Service unavailable for this model. Please try a different model or contact support.`,該模型對目前金鑰或路由未啟用。請從模型頁或 GET /v1/models 選另一個 model ID。

401 或金鑰設定問題

檢查執行 Codex CLI 的終端機是否已設定 BAZAARLINK_API_KEY,並確認 config.toml 的 env_key 拼字相同。

base_url 應填什麼?

建議使用 https://api.bazaarlink.ai/v1。https://bazaarlink.ai/api/v1 也受支援。

常見問答

金鑰要寫在 config.toml 嗎?

不用。範例用 env_key 讀取 BAZAARLINK_API_KEY 環境變數。

Model metadata 警告需要處理嗎?

本次使用 openai/gpt-5.4-mini 的實測出現 fallback metadata 警告,可以忽略。

模型回傳 503 怎麼辦?

從模型頁或 GET /v1/models 選擇目前金鑰或路由可用的另一個 model ID。

客服
客服
您好!有什麼可以協助?
請留下訊息,我們會盡快回覆。
Codex CLI 接 BazaarLink:config.toml 設定與實測(/v1/responses)