OHGROK / 接入指南
图像生成
提交同步图像生成请求。
本页内容
鉴权
使用 Authorization: Bearer YOUR_API_KEY。所选模型须在该密钥分组内开放;JSON 请求使用 Content-Type: application/json。
参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
| model | string | 必填 | 已开放图像模型,例如 image-2。 |
| prompt | string | 必填 | 描述希望生成的图像。 |
| n | integer | 可选 | 建议从 1 张开始,具体上限以模型说明为准。 |
请求示例
cURL
export OHGROK_API_KEY='YOUR_API_KEY'
curl --fail-with-body --silent --show-error \
'https://api.ohgrok.com/v1/images/generations' \
-H "Authorization: Bearer $OHGROK_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "image-2",
"prompt": "A blue inflatable puppy on a peach studio set, soft natural shadows",
"n": 1
}' \
-o image-response.json 响应结构
按实际响应读取 data[].url 或 data[].b64_json,不假设所有模型使用相同字段或文件格式。尺寸等额外选项需核对对应模型支持情况。
错误处理
结合 HTTP 状态与返回的错误信息排查。鉴权或模型权限错误先检查密钥与分组;额度或限流错误检查余额及上游限制;超时时保留已有任务 ID。