下载图片

GET/v1/images/{image_id}/content

下载已完成图片记录的生成图片内容。

使用 GET /v1/images 获取 image_id。默认响应会 302 重定向到图片 URL。也可以请求 JSON URL 响应,或通过 API 直接流式下载图片二进制内容。

身份验证

Authorization Bearer

在 Authorization header 中使用 API key 作为 Bearer token。

Path and Query Parameters

image_idstringrequired

图片记录 ID。

formatenum<string>default:redirect

响应格式。redirect 返回 302 重定向,url 返回 JSON,binary 通过 API 流式返回图片文件。

Available options: redirect url binary

Response

redirect302

默认模式。重定向到图片 URL。

urlobject

format=url 时返回。

url.urlstring

图片 URL。

url.image_idstring

图片记录 ID。

url.expires_ininteger

URL 有效期提示,单位为秒。

binaryimage/*

format=binary 时返回。响应包含 Content-Disposition 附件文件名。

如果图片记录未完成或没有可用 URL,API 会返回错误对象。

请求

下载模式 1:重定向下载

Shell
1curl -L https://api.token360.ai/v1/images/your-image-id/content \
2  -H "Authorization: Bearer sk-your-api-key" \
3  -o image.png

下载模式 2:返回图片 URL

Shell
1curl "https://api.token360.ai/v1/images/your-image-id/content?format=url" \
2  -H "Authorization: Bearer sk-your-api-key"

下载模式 3:流式下载二进制内容

Shell
1curl "https://api.token360.ai/v1/images/your-image-id/content?format=binary" \
2  -H "Authorization: Bearer sk-your-api-key" \
3  -o image.png

响应

URL 响应:

JSON
1{
2  "url": "your-generated-image-url",
3  "image_id": "your-image-id",
4  "expires_in": 3600
5}

未就绪:

JSON
1{
2  "error": {
3    "message": "Image is not ready yet. Current status: failed",
4    "type": "invalid_request_error"
5  }
6}
此页面对您有帮助吗?