{"openapi":"3.1.0","info":{"title":"AnimeAPI","version":"1.0.0","description":"Generate anime images and videos. One synchronous request returns an image URL; videos are async jobs you start with POST /api/videos and poll with GET /api/videos/{id}. Prices per image: anime: $0.003, 832x1280 portrait; ultra: $0.01, 1024x1536 portrait; ultra-max: $0.02, 1024x1536 portrait. Video prices: 480p: $0.016 per second; 768p: $0.04 per second. Pay as you go from a prepaid balance, with no daily cap.","termsOfService":"https://animeapi.ai/terms","contact":{"email":"contact@animeapi.ai","url":"https://animeapi.ai/docs"}},"servers":[{"url":"https://animeapi.ai"}],"externalDocs":{"url":"https://animeapi.ai/docs/api-reference"},"security":[{"bearerAuth":[]}],"paths":{"/api/generate":{"post":{"operationId":"generateAnimeImage","summary":"Generate an anime image","description":"Returns when the image is ready (about 4s on the anime model, 10-13s on ultra tiers). Show the returned image_url to the user. Each call is charged to the key owner's balance.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateRequest"},"example":{"prompt":"a girl with a red umbrella at a rainy bus stop","model":"anime","orientation":"portrait"}}}},"responses":{"200":{"description":"The generated image.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateResponse"}}}},"400":{"description":"Invalid input, the prompt was refused by the safety system (MODERATION_BLOCKED), or the image model rejected this exact request (PROVIDER_REJECTED; the message carries the model's reason).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Missing 'prompt' field in request body"}}}},"401":{"description":"Missing, malformed, unknown or revoked API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Invalid API key","code":"INVALID_KEY"}}}},"402":{"description":"Balance too low for this image. Top up at https://animeapi.ai/dashboard/billing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Insufficient balance: this request costs $0.003 and the account has $0.00. Add funds at https://animeapi.ai/dashboard/billing (from $5; the balance never expires).","code":"INSUFFICIENT_BALANCE"}}}},"500":{"description":"Generation failed. The charge was refunded; retrying is safe.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Internal server error","code":"GENERATION_FAILED"}}}},"503":{"description":"The image model was rate limited or unavailable after 3 attempts. The charge was refunded; retry after the Retry-After header.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"The image model is temporarily unavailable. You were not charged; retry in a few seconds.","code":"PROVIDER_UNAVAILABLE"}}}}}}},"/api/videos":{"post":{"operationId":"createAnimeVideo","summary":"Start an anime video","description":"Starts rendering one MP4 clip (24 fps, with sound) and returns 202 with a job id at once. Poll GET /api/videos/{id} about every 5 seconds until status is succeeded or failed. Send no frames for text-to-video, or first_frame and/or last_frame to animate from/to images. Priced per requested second (480p: $0.016 per second; 768p: $0.04 per second; a 5s 768p clip is $0.20), charged up front and refunded if the job fails. Confirm the price with the user before long or repeated videos.","requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VideoRequest"},"example":{"prompt":"a girl with a red umbrella waits at a rainy bus stop, then looks up as the bus pulls in","resolution":"480p","duration":5,"orientation":"landscape"}}}},"responses":{"202":{"description":"The job was started and charged.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/VideoJob"}}}},"400":{"description":"Invalid input, or a frame couldn't be used (INVALID_FRAME).","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Invalid duration. Must be a whole number of seconds from 5 to 15"}}}},"401":{"description":"Missing, malformed, unknown or revoked API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Invalid API key","code":"INVALID_KEY"}}}},"402":{"description":"Balance too low for this video. Top up at https://animeapi.ai/dashboard/billing.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Insufficient balance. Please add funds to your account.","code":"INSUFFICIENT_BALANCE"}}}},"500":{"description":"The job couldn't be started. The charge was refunded; retrying once is fine.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"The video couldn't be generated. The charge was refunded; retrying once is fine.","code":"GENERATION_FAILED"}}}}}}},"/v1/images/generations":{"post":{"operationId":"createImageOpenAICompatible","summary":"Generate anime images (OpenAI-compatible)","description":"Same generation as POST /api/generate, in the OpenAI images request and response shape, so OpenAI client libraries and tools work with base URL https://animeapi.ai/v1. Errors use the OpenAI error envelope.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["prompt"],"properties":{"prompt":{"type":"string","maxLength":1000},"model":{"type":"string","default":"anime","description":"anime, ultra or ultra-max. Unknown names fall back to anime."},"size":{"type":"string","default":"auto","description":"WIDTHxHEIGHT or auto. Only the shape (portrait, square, landscape) is used."},"n":{"type":"integer","minimum":1,"maximum":4,"default":1},"response_format":{"type":"string","enum":["url","b64_json"],"default":"url"},"orientation":{"type":"string","enum":["portrait","square","landscape"]},"enhance":{"type":"boolean","default":true}}},"example":{"model":"anime","prompt":"a girl with a red umbrella at a rainy bus stop","size":"1024x1024"}}}},"responses":{"200":{"description":"The generated images.","content":{"application/json":{"schema":{"type":"object","properties":{"created":{"type":"integer"},"data":{"type":"array","items":{"type":"object","properties":{"url":{"type":"string"},"b64_json":{"type":"string"},"revised_prompt":{"type":"string"}}}},"model":{"type":"string"},"balance_usd":{"type":"number"}}}}}},"400":{"description":"Invalid input, or the request was refused."},"401":{"description":"Missing or invalid API key."},"402":{"description":"Balance too low. Top up at https://animeapi.ai/dashboard/billing."},"503":{"description":"The image model is temporarily unavailable. Retry after the Retry-After header."}}}},"/api/balance":{"get":{"operationId":"getBalance","summary":"Check the key and read the balance","description":"Free. Returns the prepaid balance and how many images it covers on each model. 401 if the key is invalid.","responses":{"200":{"description":"The balance.","content":{"application/json":{"example":{"balance_usd":4.997,"images_remaining":{"anime":1665,"ultra":499,"ultra-max":249},"add_funds_url":"https://animeapi.ai/dashboard/billing"}}}},"401":{"description":"Missing or invalid API key."}}}},"/v1/models":{"get":{"operationId":"listModelsOpenAICompatible","summary":"List models (OpenAI-compatible)","security":[],"responses":{"200":{"description":"The three models with their prices."}}}},"/api/videos/{id}":{"get":{"operationId":"getAnimeVideo","summary":"Get a video job","description":"Returns the job. status is processing until the video is ready (succeeded, with video_url) or failed (refunded, with error). Poll about every 5 seconds.","parameters":[{"name":"id","in":"path","required":true,"description":"The id returned by POST /api/videos.","schema":{"type":"string"}}],"responses":{"200":{"description":"The video job.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Video"}}}},"401":{"description":"Missing, malformed, unknown or revoked API key.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Invalid API key","code":"INVALID_KEY"}}}},"404":{"description":"No video with that id on this account.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"},"example":{"error":"Video not found","code":"NOT_FOUND"}}}}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"API key from https://animeapi.ai/dashboard/api-keys (starts with ank_)."}},"schemas":{"GenerateRequest":{"type":"object","required":["prompt"],"properties":{"prompt":{"type":"string","maxLength":1000,"description":"What to draw, in plain English. Ultra tiers add an anime style automatically."},"model":{"type":"string","enum":["anime","ultra","ultra-max"],"default":"anime","description":"anime: cheapest, best for characters. ultra: follows long sentences, renders legible text. ultra-max: highest detail."},"orientation":{"type":"string","enum":["portrait","square","landscape"],"default":"portrait"},"enhance":{"type":"boolean","default":true,"description":"anime model only: rewrite the prompt into anime-style tags first."},"allowNSFW":{"type":"boolean","deprecated":true,"description":"Ignored. AnimeAPI does not generate adult content; the field is accepted only so existing code keeps working."}}},"GenerateResponse":{"type":"object","required":["image_url","enhanced_prompt","balance_usd","generation_time_ms"],"properties":{"image_url":{"type":"string","format":"uri","description":"WebP (anime) or PNG (ultra tiers)."},"enhanced_prompt":{"type":"string","description":"What the model actually received."},"balance_usd":{"type":"number","description":"Balance after this charge."},"generation_time_ms":{"type":"number"}}},"VideoRequest":{"type":"object","required":["prompt"],"properties":{"prompt":{"type":"string","maxLength":1000,"description":"What happens in the clip, in plain English. An anime style is added automatically."},"resolution":{"type":"string","enum":["480p","768p"],"default":"768p","description":"Priced per second: 480p: $0.016 per second; 768p: $0.04 per second."},"duration":{"type":"integer","minimum":5,"maximum":15,"default":5,"description":"Length in seconds."},"orientation":{"type":"string","enum":["portrait","square","landscape"],"default":"landscape","description":"9:16, 1:1 or 16:9. When first_frame is set, the image sets the shape instead."},"enhance":{"type":"boolean","default":true,"description":"Let the video model expand the prompt before rendering."},"first_frame":{"type":"string","description":"Image the clip starts on: an http(s) URL or a base64 data URI (data:image/png;base64,...), up to 10 MB."},"last_frame":{"type":"string","description":"Image the clip ends on. Same format as first_frame."}}},"VideoJob":{"type":"object","required":["id","status","poll_url","enhanced_prompt","resolution","duration","orientation","cost_usd","balance_usd"],"properties":{"id":{"type":"string"},"status":{"type":"string","enum":["processing"]},"poll_url":{"type":"string","format":"uri","description":"GET this URL to check on the job."},"enhanced_prompt":{"type":"string","description":"Your prompt plus the anime style."},"resolution":{"type":"string","enum":["480p","768p"]},"duration":{"type":"integer"},"orientation":{"type":"string","enum":["portrait","square","landscape"]},"cost_usd":{"type":"number","description":"Charged now; refunded if the job fails."},"balance_usd":{"type":"number","description":"Balance after this charge."}}},"Video":{"type":"object","required":["id","status","video_url","prompt","enhanced_prompt","resolution","duration","orientation","first_frame","last_frame","cost_usd","refunded","generation_time_ms","error","created_at"],"properties":{"id":{"type":"string"},"status":{"type":"string","enum":["processing","succeeded","failed"]},"video_url":{"type":["string","null"],"format":"uri","description":"MP4 (24 fps, with sound) once status is succeeded."},"prompt":{"type":"string"},"enhanced_prompt":{"type":"string"},"resolution":{"type":"string","enum":["480p","768p"]},"duration":{"type":"integer"},"orientation":{"type":"string","enum":["portrait","square","landscape"]},"first_frame":{"type":"boolean","description":"Whether a first frame was used."},"last_frame":{"type":"boolean","description":"Whether a last frame was used."},"cost_usd":{"type":"number"},"refunded":{"type":"boolean","description":"true when the job failed and the charge was returned."},"generation_time_ms":{"type":["number","null"]},"error":{"type":["string","null"],"description":"Why the job failed."},"created_at":{"type":"string","format":"date-time"}}},"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string"},"code":{"type":"string","enum":["INVALID_KEY","INSUFFICIENT_BALANCE","MODERATION_BLOCKED","INVALID_FRAME","NOT_FOUND","GENERATION_FAILED","PROVIDER_REJECTED","PROVIDER_UNAVAILABLE","RATE_LIMITED"]},"retryable":{"type":"boolean","description":"True when sending the same request again can succeed."}}}}}}