Image Generation API
Use an asynchronous task API to access Tracy Draw GPT-Image-2 generation with the same account credit balance.
Quick start
Authenticate with a Bearer API key. Create a generation, then poll its task until it reaches succeeded, partially_succeeded, or failed.
https://api.leolovetracy.com/v1curl https://api.leolovetracy.com/v1/images/generations \
-H "Authorization: Bearer td_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: generation-20260729-001" \
-d '{"model":"gpt-image-2","prompt":"A quiet reading room","n":1,"size":"1:1"}'Authentication
Send Authorization: Bearer td_live_... with every request. Revoked and expired keys stop working immediately. Store and use keys only on your server.
Authorization: Bearer td_live_YOUR_API_KEYIdempotency
Idempotency-Key is required. Repeating the same key and request body returns the same task; changing the body returns 409.
/v1/images/generationsCreate a generation
n defaults to 1 and supports up to 9. image_urls accepts up to 5 public HTTPS image URLs; localhost, private networks, and credential-bearing URLs are rejected.
Request example
curl https://api.leolovetracy.com/v1/images/generations \
-H "Authorization: Bearer td_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: generation-20260729-001" \
-d '{"model":"gpt-image-2","prompt":"A quiet reading room","n":1,"size":"1:1"}'Response example
{
"ok": true,
"data": {
"task_id": "task_q1w2e3...",
"object": "image.generation.task",
"status": "queued",
"model": "gpt-image-2",
"n": 1,
"size": "1:1",
"credits_reserved": 20,
"results_expires_at": "2026-08-01T08:00:00.000Z",
"items": []
}
}/v1/tasks/{task_id}Retrieve a task
Poll every 2 to 5 seconds. Any active API key belonging to the same user can retrieve tasks created through the API.
Request example
curl https://api.leolovetracy.com/v1/tasks/task_q1w2e3... \
-H "Authorization: Bearer td_live_YOUR_API_KEY"Response example
{
"ok": true,
"data": {
"task_id": "task_q1w2e3...",
"status": "succeeded",
"items": [{
"item_id": "task_q1w2e3..._1",
"status": "succeeded",
"image_url": "https://cdn.example.com/result.png",
"error": null
}]
}
}/v1/modelsModel capabilities
Retrieve the current model, supported sizes, maximum image count, and reference image limit.
Request example
curl https://api.leolovetracy.com/v1/models \
-H "Authorization: Bearer td_live_YOUR_API_KEY"Response example
{
"ok": true,
"data": { "list": [{
"id": "gpt-image-2",
"sizes": ["1:1", "4:3", "3:4", "1:2", "16:9", "9:16"],
"max_images": 9,
"max_reference_images": 5
}] }
}/v1/creditsCredits and pricing
Retrieve the balance and effective per-image price after role benefits. API and web calls share credits, role pricing, and failed-image refunds.
Request example
curl https://api.leolovetracy.com/v1/credits \
-H "Authorization: Bearer td_live_YOUR_API_KEY"Response example
{
"ok": true,
"data": {
"balance": 980,
"model": "gpt-image-2",
"standard_unit_credits": 20,
"actual_unit_credits": 16
}
}Result retention
Returned image URLs are guaranteed for at least 72 hours. Download them to your own storage within that period.
Status codes
400Invalid parameters or headers401Invalid, revoked, or expired API key402Insufficient credits404Task not found or not owned by this user409Idempotency conflict or request currently busy500Internal service errorV1 has no frequency or concurrency limits. The policy may change as usage develops, with documentation updated in advance.