OPENCLAW + GPT

在 OpenClaw 中使用 GPT。

GPT-5.5 是 OpenAI 的旗艦 LLM,透過 RunAPI 提供,每 token 價格僅為官方的一半。OpenClaw 原生支援 OpenAI completions 協定——將其指向 RunAPI 的 /v1 base URL,所有 GPT 變體(5.5、5.4、5.4-mini、5.3-codex)即可搭配串流、函式呼叫與結構化輸出使用。

一個 API key · 相容 OpenAI · 串流回應
Use RunAPI to call GPT-5.5 through the OpenAI-compatible Chat Completions endpoint.

Requirements:
- Read the API key from RUNAPI_API_KEY.
- Call POST https://runapi.ai/v1/chat/completions
- Set model to "gpt-5.5".
- Include a messages array with at least one user message.
- The response is synchronous — the completion arrives in the same HTTP response.
- For streaming, set "stream": true to receive server-sent events.
- For the Responses API, call POST https://runapi.ai/v1/responses instead.
curl -X POST https://runapi.ai/v1/chat/completions \
  -H "Authorization: Bearer $RUNAPI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "messages": [
      {"role": "system", "content": "You are a concise coding assistant."},
      {"role": "user", "content": "Write a Python function that merges two sorted lists in O(n) time."}
    ],
    "temperature": 0.3,
    "max_tokens": 1024
  }'
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "model": "gpt-5.5",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "def merge_sorted(a, b):\n    result = []\n    i = j = 0\n    while i < len(a) and j < len(b):\n        if a[i] <= b[j]:\n            result.append(a[i]); i += 1\n        else:\n            result.append(b[j]); j += 1\n    result.extend(a[i:])\n    result.extend(b[j:])\n    return result"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 38,
    "completion_tokens": 95,
    "total_tokens": 133
  }
}
複製 curl 指令進行測試 gpt
運作原理

三步驟在 OpenClaw 中使用 GPT

1

將 OpenClaw 指向 RunAPI

如果 RunAPI 已在 OpenClaw 中設定為供應商,相同的 key 與 /v1 base URL 即可用於 GPT。OpenClaw 使用 openai-completions API 模式,因此 GPT-5.5 可直接替換模型——無需更改協定。

export RUNAPI_API_KEY=runapi_xxx
2

選擇 GPT 模型

將 model 設為 gpt-5.5 使用旗艦版,gpt-5.4 或 gpt-5.4-mini 降低成本,或 gpt-5.3-codex 處理程式碼密集任務。/v1/chat/completions 端點回傳標準 OpenAI 回應,包含使用量統計與 finish_reason。

model: gpt-5.5
3

使用串流或函式呼叫

加入 "stream" true 以取得逐 token 的 SSE 輸出。加入 tools 陣列啟用函式呼叫。加入 response_format 取得結構化 JSON 輸出。所有標準 OpenAI 參數均可透過 RunAPI 直接使用,無需修改。

"stream": true
參數

GPT Chat Completions 參數

參數 類型 說明
model string 必填。gpt-5.5、gpt-5.4、gpt-5.4-mini、gpt-5.4-nano、gpt-5.3-codex 或 gpt-5.2。
messages array 必填。訊息物件陣列,每個物件包含 role(system、user、assistant)與 content 欄位。
temperature number 選填。取樣溫度,介於 0 到 2 之間。較低的值產生更具確定性的輸出。預設為 1。
max_tokens integer 選填。completion 中生成的最大 token 數量。
stream boolean 選填。設為 true 時,以 server-sent events 回傳增量 token 差異。預設為 false。
tools array 選填。函式呼叫的工具定義陣列。每個工具包含 type、函式名稱、描述與參數 schema。
response_format object 選填。將 type 設為 "json_object" 或 "json_schema" 以取得結構化 JSON 輸出。
reasoning_effort string 選填。控制支援模型的思考深度。接受的值為 low、medium、high。

OpenClaw 上的 GPT 是什麼?

GPT 是 OpenAI 的旗艦 LLM 家族,透過 RunAPI 以官方每 token 價格的一半提供。OpenClaw 本身就支援 OpenAI 聊天完成協議,因此切換到 RunAPI 只需更改一行 base URL——GPT-5.5 用於頂級推理、GPT-5.4 用於日常任務、GPT-5.4-mini 用於低成本批次工作、GPT-5.3-codex 用於程式碼生成,全部支援串流傳輸、函數呼叫和結構化 JSON 輸出。

GPT 使用情境

構建聊天機器人與對話式 AI

以 OpenAI 定價的 50% 透過 RunAPI 執行 GPT-5.5 聊天完成,使用應用程式已在使用的相同 SDK 和 API 格式。除了 base URL 外無需更改任何程式碼。

程式碼生成與代理式程式設計

以更低的每 token 成本使用 GPT-5.3-codex 進行程式碼生成、編輯和除錯任務。它支援與旗艦模型相同的函數呼叫和結構化輸出。

含結構化輸出的資料提取

將 response_format 設為 json_schema,從 GPT 獲得有效的 JSON,適用於從文件提取結構化資料、解析發票或構建 RAG 流程。

FAQ

GPT + OpenClaw 常見問題

OpenClaw 通用設定

尚未設定?請從 OpenClaw 的 RunAPI 設定指南開始。

OpenClaw 設定指南 →

GPT 模型目錄

查看所有 GPT 變體、每 token 定價與 API 文件。

GPT on RunAPI →

立即在 OpenClaw 中試用 GPT-5.5。

取得免費 RunAPI key,將 OpenClaw 指向 /v1,以 OpenAI 官方 token 價格的一半呼叫 GPT-5.5——含串流、函式呼叫與結構化輸出。