OPENCLAW + GPT

在 OpenClaw 中使用 GPT。

GPT-5.5 是 OpenAI 的旗舰大模型,通过 RunAPI 可以官方每 token 价格的一半使用。OpenClaw 已支持 OpenAI completions 协议——将其指向 RunAPI 的 /v1 基础 URL,每个 GPT 版本(5.5、5.4、5.4-mini、5.3-codex)都能配合流式传输、函数调用和结构化输出正常工作。

一个 API 密钥 · OpenAI 兼容 · 流式响应
使用 RunAPI 通过 OpenAI 兼容的 Chat Completions 端点调用 GPT-5.5。

要求:
- 从 RUNAPI_API_KEY 读取 API 密钥。
- 调用 POST https://runapi.ai/v1/chat/completions
- 将 model 设置为 "gpt-5.5"。
- 包含一个至少有一条 user 消息的 messages 数组。
- 响应是同步的——补全结果在同一个 HTTP 响应中返回。
- 如需流式传输,设置 "stream": true 以接收 server-sent events。
- 如需使用 Responses API,改为调用 POST https://runapi.ai/v1/responses。
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

Point OpenClaw at RunAPI

If RunAPI is already configured as a provider in OpenClaw, the same key and /v1 base URL work for GPT. OpenClaw uses the openai-completions API mode, so GPT-5.5 is a drop-in model swap — no protocol change needed.

export RUNAPI_API_KEY=runapi_xxx
2

Select a GPT model

Set the model to gpt-5.5 for the flagship, gpt-5.4 or gpt-5.4-mini for lower cost, or gpt-5.3-codex for code-heavy tasks. The /v1/chat/completions endpoint returns a standard OpenAI response with usage counts and finish_reason.

model: gpt-5.5
3

Use streaming or function calling

Add "stream" true for token-by-token SSE output. Add a tools array for function calling. Add response_format for structured JSON output. All standard OpenAI parameters work through RunAPI without modification.

"stream": true
参数

GPT Chat Completions 参数

参数 类型 说明
model string Required. gpt-5.5, gpt-5.4, gpt-5.4-mini, gpt-5.4-nano, gpt-5.3-codex, or gpt-5.2.
messages array Required. Array of message objects with role (system, user, assistant) and content fields.
temperature number Optional. Sampling temperature between 0 and 2. Lower values produce more deterministic output. Defaults to 1.
max_tokens integer Optional. Maximum number of tokens to generate in the completion.
stream boolean Optional. When true, returns server-sent events with incremental token deltas. Defaults to false.
tools array Optional. Array of tool definitions for function calling. Each tool has a type, function name, description, and parameters schema.
response_format object Optional. Set type to "json_object" or "json_schema" for structured JSON output.
reasoning_effort string Optional. Controls thinking depth for supported models. Accepted values are 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

通过 RunAPI 以 OpenAI 定价 50% 的成本运行 GPT-5.5 聊天补全,使用应用现有的 SDK 和 API 格式。除了 base URL,无需任何代码修改。

代码生成与 agent 编程

以更低的单 token 成本使用 GPT-5.3-codex 完成代码生成、编辑和调试任务。支持与旗舰模型相同的函数调用和结构化输出。

结构化输出数据提取

将 response_format 设为 json_schema,从 GPT 获得有效的 JSON 输出,适用于从文档提取结构化数据、解析发票或构建 RAG 流水线。

常见问题

GPT + OpenClaw 常见问题

OpenClaw 通用配置

尚未配置?请从 OpenClaw 的 RunAPI 配置指南开始。

OpenClaw 配置指南 →

GPT 模型目录

查看所有 GPT 版本、每 token 定价和 API 文档。

GPT on RunAPI →

立即在 OpenClaw 中试用 GPT-5.5。

免费获取 RunAPI 密钥,将 OpenClaw 指向 /v1,以官方 OpenAI token 价格的一半调用 GPT-5.5——含流式传输、函数调用和结构化输出。