{"openapi":"3.1.0","info":{"title":"BetterWaifu API","version":"1.1.0","description":"Generate and edit anime images and videos from code or an agent. Every paid call spends the account’s credits and reports credits_charged; failed jobs are refunded automatically. Typical flow: GET /models (prices), POST /generate | /videos | /upscale with an Idempotency-Key, then poll GET /generate/{id} or pass webhook_url. An MCP server with the same tools is at https://betterwaifu.com/api/mcp. Docs: https://docs.betterwaifu.com/p/documentation/api-reference/introduction"},"servers":[{"url":"https://betterwaifu.com/api/v1"}],"externalDocs":{"url":"https://docs.betterwaifu.com/p/documentation/api-reference/introduction"},"security":[{"bearer":[]}],"paths":{"/account":{"get":{"operationId":"getAccount","summary":"Credit balance, subscription, and this key’s daily limit and spend","responses":{"200":{"description":"Account","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Account"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active subscription, account restricted, model not allowed for this key, or a required confirmation missing","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit or concurrent-job limit reached (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/models":{"get":{"operationId":"listModels","summary":"Everything you can run, with prices: checkpoints and LoRAs, hosted image models, video models, upscale","responses":{"200":{"description":"Catalog","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit or concurrent-job limit reached (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/generate":{"post":{"operationId":"generateImage","summary":"Generate or edit images","description":"Pass model_version_id (a checkpoint) or model (a hosted model), not both. Source images are your image ids or upload ids.","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Unique per request, the same on a retry: a retry returns the first answer instead of charging again. 1-255 chars of letters, digits, _ - : . Remembered 24 h.","schema":{"type":"string","maxLength":255}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/GenerateRequest"}}}},"responses":{"201":{"description":"Accepted (or finished, for models that answer in the request)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobAccepted"}}}},"400":{"description":"Invalid parameters, or refused by moderation (nothing charged)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"Not enough credits, or the key’s daily credit limit is reached","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active subscription, account restricted, model not allowed for this key, or a required confirmation missing","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown model, or an id that is not yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"A request with the same Idempotency-Key is still running","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The Idempotency-Key was already used with a different request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit or concurrent-job limit reached (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/videos":{"post":{"operationId":"generateVideo","summary":"Generate a video from an image or from text","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Unique per request, the same on a retry: a retry returns the first answer instead of charging again. 1-255 chars of letters, digits, _ - : . Remembered 24 h.","schema":{"type":"string","maxLength":255}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/VideoRequest"}}}},"responses":{"201":{"description":"Accepted (or finished, for models that answer in the request)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobAccepted"}}}},"400":{"description":"Invalid parameters, or refused by moderation (nothing charged)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"Not enough credits, or the key’s daily credit limit is reached","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active subscription, account restricted, model not allowed for this key, or a required confirmation missing","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown model, or an id that is not yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"A request with the same Idempotency-Key is still running","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The Idempotency-Key was already used with a different request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit or concurrent-job limit reached (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/upscale":{"post":{"operationId":"upscaleImage","summary":"Upscale one of your images 2x or 4x","parameters":[{"name":"Idempotency-Key","in":"header","required":false,"description":"Unique per request, the same on a retry: a retry returns the first answer instead of charging again. 1-255 chars of letters, digits, _ - : . Remembered 24 h.","schema":{"type":"string","maxLength":255}}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/UpscaleRequest"}}}},"responses":{"201":{"description":"Accepted (or finished, for models that answer in the request)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/JobAccepted"}}}},"400":{"description":"Invalid parameters, or refused by moderation (nothing charged)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"402":{"description":"Not enough credits, or the key’s daily credit limit is reached","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active subscription, account restricted, model not allowed for this key, or a required confirmation missing","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown model, or an id that is not yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"A request with the same Idempotency-Key is still running","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"The Idempotency-Key was already used with a different request","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit or concurrent-job limit reached (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Temporarily unavailable","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/uploads":{"post":{"operationId":"uploadImage","summary":"Upload a source image (free). JPEG/PNG/WebP, 4 MB, 4096 px. Moderated.","requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["image"],"properties":{"image":{"type":"string","description":"base64 or a data:image/...;base64, URL"}}}},"multipart/form-data":{"schema":{"type":"object","required":["file"],"properties":{"file":{"type":"string","format":"binary"}}}}}},"responses":{"200":{"description":"Same bytes uploaded before","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Upload"}}}},"201":{"description":"Stored","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Upload"}}}},"400":{"description":"Invalid parameters, or refused by moderation (nothing charged)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active subscription, account restricted, model not allowed for this key, or a required confirmation missing","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"413":{"description":"Body too large","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit or concurrent-job limit reached (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/generate/{id}":{"get":{"operationId":"getGeneration","summary":"Status and result of any job (image, video, upscale). Saves the result to your account; refunds a failure.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Status","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown model, or an id that is not yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit or concurrent-job limit reached (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}},"delete":{"operationId":"cancelGeneration","summary":"Cancel an in-flight job on models that support upstream cancellation (check cancelable in GET /models). Returns 409 not_cancelable otherwise.","parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Canceled and refunded","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Job"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"403":{"description":"No active subscription, account restricted, model not allowed for this key, or a required confirmation missing","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"404":{"description":"Unknown model, or an id that is not yours","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"409":{"description":"A request with the same Idempotency-Key is still running","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit or concurrent-job limit reached (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/generations":{"get":{"operationId":"listGenerations","summary":"Your recent API jobs (images, videos, upscales), newest first","parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}},{"name":"cursor","in":"query","schema":{"type":"string"}},{"name":"kind","in":"query","schema":{"type":"string","enum":["image","video","upscale"]}},{"name":"status","in":"query","schema":{"type":"string","enum":["queued","succeeded","failed"]}}],"responses":{"200":{"description":"Page of generations","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Invalid parameters, or refused by moderation (nothing charged)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit or concurrent-job limit reached (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}},"/images":{"get":{"operationId":"listImages","summary":"Your images or videos, newest first (ids usable as source_image_id or upscale_source_id)","parameters":[{"name":"limit","in":"query","schema":{"type":"integer","minimum":1,"maximum":50,"default":20}},{"name":"cursor","in":"query","schema":{"type":"string"}},{"name":"media_type","in":"query","schema":{"type":"string","enum":["image","video","all"],"default":"image"}}],"responses":{"200":{"description":"Page of media","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"description":"Invalid parameters, or refused by moderation (nothing charged)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"401":{"description":"Missing or invalid API key","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"429":{"description":"Rate limit or concurrent-job limit reached (see Retry-After)","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}},"components":{"securitySchemes":{"bearer":{"type":"http","scheme":"bearer","description":"Your bw_… API key from the developer console"}},"schemas":{"Error":{"type":"object","required":["error"],"properties":{"error":{"type":"string"},"detail":{"type":"string"}}},"Account":{"type":"object","properties":{"username":{"type":"string"},"credits":{"type":"integer"},"subscription":{"type":["object","null"],"additionalProperties":true},"api_key":{"type":"object","properties":{"daily_credit_limit":{"type":["integer","null"]},"spent_today":{"type":"integer"},"remaining_today":{"type":["integer","null"]},"allowed_models":{"type":["array","null"],"items":{"type":"string"}},"resets_at":{"type":"string","format":"date-time"}}}}},"GenerateRequest":{"type":"object","required":["prompt"],"properties":{"prompt":{"type":"string","maxLength":2000},"enhance_prompt":{"type":"boolean","description":"Automatically rewrite your prompt into the model’s optimal format (SDXL booru tags, Anima hybrid tags, or detailed natural language) before generating. Returns enhanced_prompt in the response."},"negative_prompt":{"type":"string","maxLength":2000,"description":"Checkpoints only"},"model_version_id":{"type":"integer","description":"A checkpoint id from GET /models (models array)"},"model":{"type":"string","enum":["seedream-5","seedream-5-flash","qwen-image-edit-spicy","flux-2-klein-9b"],"description":"A hosted model id from GET /models (hosted_models)"},"size":{"type":"string","description":"Hosted models: one of the model’s sizes"},"width":{"type":"integer","minimum":256,"maximum":2048},"height":{"type":"integer","minimum":256,"maximum":2048},"batch_size":{"type":"integer","minimum":1,"maximum":4},"seed":{"type":"integer","minimum":0},"steps":{"type":"integer"},"cfg_scale":{"type":"number"},"sampler":{"type":"string"},"fast_mode":{"type":"boolean"},"loras":{"type":"array","maxItems":4,"items":{"type":"object","required":["model_version_id"],"properties":{"model_version_id":{"type":"integer"},"strength":{"type":"number","minimum":0,"maximum":2}}}},"source_image_id":{"type":"string","description":"Your image id or an upload id (up_…)"},"reference_image_ids":{"type":"array","items":{"type":"string"}},"strength":{"type":"number","minimum":0.05,"maximum":1},"i2i_terms_accepted":{"type":"boolean","description":"Pass true once on your account when using source images; remembered for future calls"},"webhook_url":{"type":"string","format":"uri","description":"https URL that receives the signed terminal event"}}},"VideoRequest":{"type":"object","required":["model"],"properties":{"model":{"type":"string","enum":["seedance-2.0-byteplus","seedance-2.0-fast-byteplus","seedance-2.0-mini-byteplus","seedance-2.5-byteplus","wan2.7-i2v-spicy","w3.0-video","minimax-h3"]},"prompt":{"type":"string","maxLength":2000},"enhance_prompt":{"type":"boolean","description":"Automatically rewrite your motion prompt into the model’s native director format (supported on models with prompt_enhance: true, e.g. minimax-h3, seedance-2.0-*, bwai-spicy). Returns enhanced_prompt in the response."},"negative_prompt":{"type":"string"},"source_image_id":{"type":"string","description":"Start frame"},"end_image_id":{"type":"string"},"reference_image_ids":{"type":"array","items":{"type":"string"},"maxItems":9,"description":"Reference images for models with max_reference_images > 0 (e.g. minimax-h3, seedance-2.0-*)"},"upscale_source_id":{"type":"string","description":"Video id to upscale to HD (for models with upscale, e.g. minimax-h3)"},"upscale_strength":{"type":"number","description":"Optional re-draw strength when using upscale_source_id"},"duration":{"type":"number"},"resolution":{"type":"string"},"aspect_ratio":{"type":"string"},"generate_audio":{"type":"boolean"},"camera_fixed":{"type":"boolean"},"seed":{"type":"integer"},"i2i_terms_accepted":{"type":"boolean","description":"Pass true once on your account when using source/reference images; remembered for future calls"},"webhook_url":{"type":"string","format":"uri"}}},"UpscaleRequest":{"type":"object","required":["source_image_id"],"properties":{"source_image_id":{"type":"string"},"scale":{"type":"integer","enum":[2,4],"default":2},"webhook_url":{"type":"string","format":"uri"}}},"Upload":{"type":"object","properties":{"id":{"type":"string"},"url":{"type":"string"},"width":{"type":"integer"},"height":{"type":"integer"}}},"JobAccepted":{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string","enum":["queued","succeeded"]},"credits_charged":{"type":"integer"},"seed":{"type":"integer"},"enhanced_prompt":{"type":"string","description":"Present when enhance_prompt: true was used and the prompt was rewritten."},"poll_url":{"type":"string"},"output":{"$ref":"#/components/schemas/Output"}}},"Job":{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string","enum":["queued","processing","succeeded","failed"]},"output":{"$ref":"#/components/schemas/Output"},"error":{"type":"string"},"credits_refunded":{"type":"integer"},"queue_position":{"type":"integer"},"progress":{"type":"number"}}},"Output":{"type":"object","properties":{"images":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"url":{"type":"string"}}}},"video":{"type":"object","properties":{"id":{"type":"string"},"url":{"type":"string"}}},"seed":{"type":"integer"}}}}}}