在 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)都能配合流式传输、函数调用和结构化输出正常工作。
使用 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
}
}
三步在 OpenClaw 中使用 GPT
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
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
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 常见问题
Yes. OpenClaw supports OpenAI-compatible providers. Add RunAPI with base URL https://runapi.ai/v1 and set the model to gpt-5.5. The openai-completions protocol that OpenClaw already uses works without changes.
Chat Completions (/v1/chat/completions) is the standard request-response endpoint that returns a message. The Responses API (/v1/responses) is OpenAI's newer surface that supports built-in web search, file search, and computer use tools. Both are available through RunAPI at the same discounted rate.
GPT-5.5 for complex reasoning and hard problems. GPT-5.4 for everyday tasks at lower cost. GPT-5.4-mini for high-volume cheap work like classification or tagging. GPT-5.3-codex for code generation and editing. All use the same endpoint and parameters.
Set response_format to json_schema with a schema definition in your request. GPT will constrain its output to match your schema exactly. This works for data extraction, form parsing, and any task where you need predictable JSON structure. RunAPI forwards the schema parameter unchanged.
Yes. Pass a tools array for function calling or set response_format to json_schema for structured output. RunAPI forwards these parameters to the GPT model and returns the tool_calls or structured JSON in the standard OpenAI response format.
立即在 OpenClaw 中试用 GPT-5.5。
免费获取 RunAPI 密钥,将 OpenClaw 指向 /v1,以官方 OpenAI token 价格的一半调用 GPT-5.5——含流式传输、函数调用和结构化输出。