在 OpenClaw 中使用 GPT Image。
GPT Image 2 是 OpenAI 专用的图像生成模型——支持文生图和基于指令的图像编辑,输出分辨率最高可达 4K,并支持透明背景。OpenClaw agent 通过与聊天相同的 RunAPI 密钥和 /v1 端点调用它,无需安装额外的 skill。
使用 RunAPI 通过 OpenAI GPT Image 2 生成图像。
要求:
- 使用位于 https://runapi.ai/v1/text_to_image 的 RunAPI API。
- 从 RUNAPI_API_KEY 环境变量读取 API 密钥。
- 将 model 设置为 "gpt-image-2-text-to-image"。
- 编写一个描述性的 prompt。GPT Image 2 会紧密遵循自然语言指令——描述布局、风格、文字叠加和透明度需求。
- 可选地将 output_resolution 设为 1k、2k 或 4k。默认为 1k。
- 响应会返回一个 task_id。轮询任务状态端点直到任务完成,然后获取输出 URL。
curl -X POST https://runapi.ai/v1/text_to_image \
-H "Authorization: Bearer $RUNAPI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2-text-to-image",
"prompt": "A product photo of a glass perfume bottle on a marble surface, transparent background, studio lighting, the label reads AURORA in gold serif font",
"output_resolution": "2k",
"aspect_ratio": "3:4"
}'
{
"task_id": "tsk_abc123",
"status": "pending",
"model": "gpt-image-2-text-to-image"
}
三步在 OpenClaw 中使用 GPT Image
Configure RunAPI
Set the RUNAPI_API_KEY environment variable in your shell profile. If RunAPI is already configured in OpenClaw for chat, the same key works for GPT Image — no additional setup needed.
export RUNAPI_API_KEY=runapi_xxx
Call GPT Image 2
Send a POST request to the text_to_image endpoint with model set to gpt-image-2-text-to-image. Include a descriptive prompt with layout and style instructions. Set output_resolution to 2k or 4k for higher detail. For editing existing images, use the edit_image endpoint with gpt-image-2-image-to-image and provide source_image_urls.
POST /v1/text_to_image
Get the result
The API returns a task_id immediately. Poll the task status endpoint until the status changes to completed, then retrieve the output image URL from the response. GPT Image 2 typically completes within 10–30 seconds depending on resolution.
task_id: tsk_abc123
GPT Image API 参数
| 参数 | 类型 | 说明 |
|---|---|---|
model |
string |
Required. gpt-image-2-text-to-image for generation, gpt-image-2-image-to-image for editing. |
prompt |
string |
Required. Natural language description of the desired image. Supports detailed instructions for layout, text overlays, and style. |
output_resolution |
string |
Optional. Output resolution — 1k (default), 2k, or 4k. Higher resolution costs more per image. |
aspect_ratio |
string |
Optional. Defaults to auto. Supports 1:1, 3:2, 2:3, 4:3, 3:4, 16:9, 9:16, and more. |
source_image_urls |
array |
Required for edit_image endpoint. One or more URLs of source images to edit. |
OpenClaw 上的 GPT Image 是什么?
GPT Image 2 是 OpenAI 专用的图像模型,其运作方式更像一个结构化的设计助手而非关键词驱动的生成器。你给它一个制作简报——排版、文字位置、风格约束——它能严格遵循指令。OpenClaw agent 通过与聊天相同的 RunAPI 端点调用它。
GPT Image 使用场景
品牌视觉与广告设计
根据详细的制作简报生成品牌广告、社交媒体横幅和营销视觉——指定精确的排版、文字位置和风格约束,GPT Image 2 严格遵循执行。
带透明背景的产品图
生成带透明背景的产品展示图,可直接用于电商网站、营销材料或 UI 叠加层,无需后期去背景处理。
UI 模型与界面概念图
生成带可读文字标签和清晰布局层级的 UI 模型和应用界面概念图,在开发团队评审前快速可视化设计概念。
GPT Image + OpenClaw 常见问题
Yes. OpenClaw agents call GPT Image 2 through the RunAPI text_to_image endpoint. Set the model field to gpt-image-2-text-to-image and send the request with the same RUNAPI_API_KEY you use for chat. No extra skills or plugins required.
GPT Image 2 is OpenAI's dedicated image generation model with higher quality, 4K output, and transparent background support. GPT-4o Image generates images within a chat context but is limited to 1:1, 3:2, or 2:3 aspect ratios. Both are available through RunAPI — use gpt-image-2-text-to-image for standalone generation and gpt-4o-image for chat-integrated image output.
Yes. GPT Image 2 can output images with transparent backgrounds when instructed in the prompt. This is useful for product photos, logos, and UI elements. Specify transparency in your prompt — for example, "product photo with transparent background."
GPT Image 2 is billed per image based on output resolution: 1k is the lowest cost, 2k is mid-range, and 4k is the most expensive. The same rate applies to both text_to_image and edit_image. Check the RunAPI pricing page for current per-image rates. Failed generations are not charged.
Yes. Use the edit_image endpoint with model set to gpt-image-2-image-to-image. Pass the source image URLs in source_image_urls and describe the edit in the prompt — for example, "change the background to a beach sunset" or "add a red hat to the person." GPT Image 2 follows natural language editing instructions.