{"openapi":"3.1.0","info":{"title":"AIImg API","version":"1.0.0","description":"OpenAI-compatible image generation API. Drop-in replace base URL + API key in the OpenAI SDK to migrate.","contact":{"name":"AIImg","url":"https://aiimg.top"},"license":{"name":"Commercial"}},"servers":[{"url":"https://aiimg.top/v1","description":"Production"}],"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"aiimg-sk-live-*"}},"schemas":{"ImageGenerateRequest":{"type":"object","required":["prompt"],"properties":{"prompt":{"type":"string","minLength":2,"maxLength":4000},"model":{"type":"string","default":"gpt-image-2"},"n":{"type":"integer","minimum":1,"maximum":4,"default":1},"size":{"type":"string","default":"1024x1024"},"quality":{"type":"string","enum":["low","medium","high","auto"]},"response_format":{"type":"string","enum":["url","b64_json"],"default":"url"},"user":{"type":"string"}}},"ImageResponse":{"type":"object","properties":{"created":{"type":"integer"},"data":{"type":"array","items":{"type":"object","properties":{"url":{"type":"string"},"b64_json":{"type":"string"}}}},"aiimg_generation_id":{"type":"string"}}},"ApiError":{"type":"object","properties":{"error":{"type":"object","properties":{"type":{"type":"string"},"code":{"type":"string"},"message":{"type":"string"}},"required":["type","code","message"]}}}}},"security":[{"bearerAuth":[]}],"paths":{"/images/generations":{"post":{"summary":"Create an image","operationId":"createImage","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImageGenerateRequest"}}}},"responses":{"200":{"description":"Generated image(s)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImageResponse"}}}},"400":{"description":"Bad request / prohibited content","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"401":{"description":"Invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"402":{"description":"Insufficient T-coin balance","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"429":{"description":"Rate limited / daily quota / concurrency","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}},"502":{"description":"Upstream model failure (auto-refunded)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ApiError"}}}}}}},"/images/edits":{"post":{"summary":"Edit an image","operationId":"editImage","requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["prompt","image"],"properties":{"prompt":{"type":"string"},"image":{"type":"string","format":"binary"},"image[]":{"type":"array","items":{"type":"string","format":"binary"}},"model":{"type":"string","default":"gpt-image-2"},"n":{"type":"integer","default":1},"size":{"type":"string"},"quality":{"type":"string","enum":["low","medium","high","auto"]},"response_format":{"type":"string","enum":["url","b64_json"]}}}}}},"responses":{"200":{"description":"Edited image(s)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/ImageResponse"}}}}}}},"/images/{id}":{"get":{"summary":"Get a generation status","operationId":"getGeneration","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Status + data"},"404":{"description":"Not found"}}}},"/account/balance":{"get":{"summary":"Get T-coin balance and per-key limits","operationId":"getBalance","responses":{"200":{"description":"Balance info"}}}},"/account/usage":{"get":{"summary":"List API usage records (last 30 days)","operationId":"getUsage","parameters":[{"name":"before","in":"query","schema":{"type":"string","format":"date-time"}}],"responses":{"200":{"description":"Paginated usage"}}}}}}