Image Generation API quickstart
Create an account, copy your key, and make your first request. Model id used below: openai/gpt-image-1/openai.
- Create a VideoRouter account and add credit.
- Create an API key in the dashboard.
- Run one of the examples below.
cURL
curl https://videorouter.sh/api/v1/images \
-H "Authorization: Bearer $VIDEOROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "openai/gpt-image-1/openai", "prompt": "a red panda astronaut floating in space", "aspect_ratio": "16:9"}'
# -> {"data": [{"b64_json": "..."}], "usage": {"cost": ...}}Python
import base64, requests
resp = requests.post(
"https://videorouter.sh/api/v1/images",
headers={"Authorization": "Bearer llmr_sk_live_..."},
json={"model": "openai/gpt-image-1/openai", "prompt": "a red panda astronaut floating in space", "aspect_ratio": "16:9"},
).json()
open("out.png", "wb").write(base64.b64decode(resp["data"][0]["b64_json"]))
print("cost:", resp["usage"]["cost"])Image-to-image uses the same endpoint: add one or more reference images in input_references.
Errors
All errors use {"error": {"message", "type", "code"}}. 402 = out of credit or cap hit, 429 = rate limited
(honour Retry-After), 400 = bad model id or parameters. Full reference in the
API docs.