curl --request POST \
--url https://api.omnirelay.ai/v1/images/edits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form model=gpt-image-2 \
--form 'prompt=<string>' \
--form image=@example-file \
--form mask=@example-fileimport requests
url = "https://api.omnirelay.ai/v1/images/edits"
files = {
"image": ("example-file", open("example-file", "rb")),
"mask": ("example-file", open("example-file", "rb"))
}
payload = {
"model": "gpt-image-2",
"prompt": "<string>"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('model', 'gpt-image-2');
form.append('prompt', '<string>');
form.append('image', '<string>');
form.append('mask', '{
"fileName": "example-file"
}');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.omnirelay.ai/v1/images/edits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"created": 123,
"model": "<string>",
"data": [
{
"b64_json": "<string>",
"revised_prompt": "<string>"
}
],
"cost_microusd": 123,
"background": "<string>",
"output_format": "<string>",
"quality": "<string>",
"size": "<string>",
"usage": {},
"omnirelay_metadata": {
"request_id": "<string>",
"requested": "<string>",
"model": "<string>",
"provider": "<string>",
"mode": "live",
"strategy": "direct",
"attempt": 123,
"attempts": [
{
"provider": "<string>",
"model": "<string>",
"mode": "<string>"
}
],
"tags": {},
"deprecated_header": "<string>"
},
"gateway_metadata": {
"request_id": "<string>",
"requested": "<string>",
"model": "<string>",
"provider": "<string>",
"mode": "live",
"strategy": "direct",
"attempt": 123,
"attempts": [
{
"provider": "<string>",
"model": "<string>",
"mode": "<string>"
}
],
"tags": {},
"deprecated_header": "<string>"
}
}{
"error": {
"code": "unsupported_parameter"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "unauthorized"
}
}{
"error": {
"code": "inference_budget_or_access_denied"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "model_not_allowed"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "model_unavailable"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "payload_too_large"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "rate_limited"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "image_call_held"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "live_provider_unavailable"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "image_call_held"
},
"request_id": "2f6c1d0e9a"
}编辑图片
编辑或扩展一张或多张上传的图片(multipart/form-data,字段 image 或 image[],可选 mask)。计费、尺寸档位、n、b64_json 输出与长耗时行为同「生成图片」。整个请求最大 20 MiB。
curl --request POST \
--url https://api.omnirelay.ai/v1/images/edits \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form model=gpt-image-2 \
--form 'prompt=<string>' \
--form image=@example-file \
--form mask=@example-fileimport requests
url = "https://api.omnirelay.ai/v1/images/edits"
files = {
"image": ("example-file", open("example-file", "rb")),
"mask": ("example-file", open("example-file", "rb"))
}
payload = {
"model": "gpt-image-2",
"prompt": "<string>"
}
headers = {"Authorization": "Bearer <token>"}
response = requests.post(url, data=payload, files=files, headers=headers)
print(response.text)const form = new FormData();
form.append('model', 'gpt-image-2');
form.append('prompt', '<string>');
form.append('image', '<string>');
form.append('mask', '{
"fileName": "example-file"
}');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://api.omnirelay.ai/v1/images/edits', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"created": 123,
"model": "<string>",
"data": [
{
"b64_json": "<string>",
"revised_prompt": "<string>"
}
],
"cost_microusd": 123,
"background": "<string>",
"output_format": "<string>",
"quality": "<string>",
"size": "<string>",
"usage": {},
"omnirelay_metadata": {
"request_id": "<string>",
"requested": "<string>",
"model": "<string>",
"provider": "<string>",
"mode": "live",
"strategy": "direct",
"attempt": 123,
"attempts": [
{
"provider": "<string>",
"model": "<string>",
"mode": "<string>"
}
],
"tags": {},
"deprecated_header": "<string>"
},
"gateway_metadata": {
"request_id": "<string>",
"requested": "<string>",
"model": "<string>",
"provider": "<string>",
"mode": "live",
"strategy": "direct",
"attempt": 123,
"attempts": [
{
"provider": "<string>",
"model": "<string>",
"mode": "<string>"
}
],
"tags": {},
"deprecated_header": "<string>"
}
}{
"error": {
"code": "unsupported_parameter"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "unauthorized"
}
}{
"error": {
"code": "inference_budget_or_access_denied"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "model_not_allowed"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "model_unavailable"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "payload_too_large"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "rate_limited"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "image_call_held"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "live_provider_unavailable"
},
"request_id": "2f6c1d0e9a"
}{
"error": {
"code": "image_call_held"
},
"request_id": "2f6c1d0e9a"
}授权
在 OmniRelay 控制台创建的 API Key。所有者确认身份后可在控制台再次查看。
请求头
本次调用的标签,以逗号分隔的 key=value,例如 client=acme,env=prod。与 API Key 的默认标签合并;同名 key 以请求体 tags 字段为准。X-OmniRelay-Tags 是同一个请求头的旧名,继续接受。
传 enabled 时,响应会附带 gateway_metadata,说明网关为本次调用做出的决定。其他值或不传此头,响应保持不变。X-OmniRelay-Metadata 是同一个请求头的旧名,继续接受。
enabled 请求体
其他字段(background、output_format、output_compression、moderation、user)原样传给模型,由模型决定是否接受。
图片模型 ID,例如 gpt-image-2。
"gpt-image-2"
图片的文字描述,最多 32000 个字符。
32000一张或多张原图(PNG、JPEG 或 WebP)。
图片张数,1 至模型上限(4)。预留 n 张的费用,只对实际返回的图片扣费。
1 <= x <= 4宽x高 或 auto。决定价格档位:最长边不超过 1024 px 为 1K,不超过 2048 px 为 2K,不超过 4096 px 为 4K;auto 或未传为 2K。
"1024x1024"
传给模型,例如 low、medium、high 或 auto。不影响价格。
仅支持 b64_json。
b64_json 可选蒙版图片,透明区域表示要编辑的位置。
响应
图片及已结算的用量与费用。
生成的图片。
Show child attributes
Show child attributes
折扣后的扣费金额(micro-USD)。
模型报告的 token 数,仅供参考;图片按张计费,不按 token 计费。
仅在请求带有 X-Gateway-Metadata: enabled 时出现。同时以 gateway_metadata 和旧名 omnirelay_metadata 返回,内容相同。流式响应中随第一个数据块返回。
Show child attributes
Show child attributes
仅在请求带有 X-Gateway-Metadata: enabled 时出现。同时以 gateway_metadata 和旧名 omnirelay_metadata 返回,内容相同。流式响应中随第一个数据块返回。
Show child attributes
Show child attributes