Universal Image API
Unified API for multiple image generation and image editing models
API Overview
To simplify the integration of different image generation models、image editing models, OneRouter provides a unified image API.
API Specification
image generation models
curl https://image.onerouter.pro/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: <API_KEY>" \
-d '{
"model": "gpt-image-1",
"prompt": "A cute baby sea otter",
"n": 1,
"output_format": "url"
}'from openai import OpenAI
import base64
import os
client = OpenAI(
api_key="<API_KEY>", # Replace with your Key "sk-***"
base_url="https://image.onerouter.pro/v1"
)
prompt = """A cute baby sea otter."""
result = client.images.generate(
model="gpt-image-1",
prompt=prompt,
n=1,
output_format: "url"
)
print(result)https://image.onerouter.pro/v1/images/generationsis the base URL<API_KEY>is your API Key generated in API page.modelis the model name, such asgpt-image-1, available model list can be access in Model page.promptis the prompt.nis the number of images to generate, default value is1.output_formatindicate the output format, default value isurl.b64_jsonurl
Example response
image editing models
https://image.onerouter.pro/v1/images/editsis the base URL<API_KEY>is your API Key generated in API page.modelis the model name, such asdreamomni2-image-to-image, available model list can be access in Model page.promptis the prompt.image_urlsis the list of URLs of input images for editing.nis the number of images to generate, default value is1.output_formatindicate the output format, default value isurl.b64_jsonurl
Example response
Last updated