{"openapi":"3.1.0","info":{"title":"WanAPIs Unified AI API Gateway","version":"2026.11","summary":"OpenAI-compatible LLM gateway plus unified async image, video and media APIs.","description":"One API key for 180+ text, coding, image and video models (Claude, GPT, Gemini, DeepSeek, Kimi, GLM, Seedream 5.5, Seedance 2.5, MiniMax H3, Veo 3.1, Kling v3, Flux, Midjourney). Live unauthenticated pricing is exposed at GET /api/pricing; see /pricing.md and /SKILL.md for agent guides.","contact":{"name":"WanAPIs Support","email":"support@wanapis.com","url":"https://wanapis.com/docs"}},"servers":[{"url":"https://api.wanapis.com","description":"WanAPIs Production API Gateway"}],"externalDocs":{"description":"WanAPIs Developer Documentation & Agent Skill","url":"https://wanapis.com/docs"},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"API Key (sk-...)","description":"WanAPIs API key passed as Authorization: Bearer <WANAPIS_API_KEY>."}},"schemas":{"ErrorResponse":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string"},"code":{"type":"string"}}}}},"MuseVideoDuration":{"oneOf":[{"type":"integer","minimum":2,"maximum":10},{"type":"string","pattern":"^\\s*\\+?0*(?:[2-9]|10)s?\\s*$"}],"default":10,"description":"Output duration in whole seconds. Supply duration, seconds or duration_seconds. Omit all three for 10 seconds. If more than one is supplied, the values must represent the same duration."},"MuseVideoRequest":{"type":"object","required":["model","prompt"],"additionalProperties":false,"description":"Generate 720p video with audio from text and optional image references. First and last frame controls, video inputs and audio inputs are unsupported. At the 1× group rate each output second costs CNY 0.021385 (approximately CNY 0.21385 for the default 10 seconds, subject to quota rounding).","externalDocs":{"description":"Muse Video API guide","url":"https://wanapis.com/docs/muse-video"},"properties":{"model":{"const":"muse-video-ext"},"prompt":{"type":"string","pattern":"\\S"},"resolution":{"type":"string","pattern":"^\\s*720[pP]\\s*$","default":"720p"},"metadata":{"type":"object","additionalProperties":false,"properties":{"resolution":{"type":"string","pattern":"^\\s*720[pP]\\s*$"}}},"audio":{"const":true,"default":true},"generate_audio":{"const":true,"description":"Alias for audio. Muse Video always includes audio."},"n":{"const":1,"description":"One clip per request."},"nsfw_check":{"type":"boolean"},"duration":{"$ref":"#/components/schemas/MuseVideoDuration"},"seconds":{"$ref":"#/components/schemas/MuseVideoDuration"},"duration_seconds":{"$ref":"#/components/schemas/MuseVideoDuration"},"aspect_ratio":{"type":"string","enum":["1:1","16:9","9:16","4:3","3:4","3:2","2:3"]},"size":{"type":"string","enum":["1:1","16:9","9:16","4:3","3:4","3:2","2:3","auto"],"description":"Aspect ratio alias. Use auto to leave the ratio unspecified."},"image_urls":{"type":"array","maxItems":9,"items":{"type":"string","pattern":"^(?:https?://[^/\\s?#]+(?:[/?#][^\\s]*)?|(?:data:image/[^;,\\s]+;base64,)?[A-Za-z0-9+/]+={0,2})$"},"description":"Reference images given as publicly accessible HTTP(S) URLs, image data URIs or raw base64 strings. All original images together must fit within 11 MiB after download or decoding."}}},"Magi2Duration":{"oneOf":[{"type":"integer","minimum":4,"maximum":30},{"type":"string","pattern":"^(?:[4-9]|[12][0-9]|30)$"}],"default":5,"description":"Requested output duration in whole seconds. If both duration and seconds are supplied, they must agree."},"Magi2VideoRequest":{"type":"object","required":["model","prompt"],"properties":{"model":{"const":"magi-2"},"prompt":{"type":"string","minLength":1},"resolution":{"type":"string","const":"1080p","default":"1080p"},"duration":{"$ref":"#/components/schemas/Magi2Duration"},"seconds":{"$ref":"#/components/schemas/Magi2Duration","description":"Alias for duration. Both values must agree when supplied together."},"aspect_ratio":{"type":"string","enum":["16:9","9:16","1:1","4:3","3:4","21:9","auto"],"description":"Text and reference modes default to 16:9. Frame mode supports auto or omission to follow the first frame, and excludes 21:9."},"generate_audio":{"type":"boolean","default":true},"audio":{"type":"boolean","description":"Alias for generate_audio. Both fields must agree when supplied together."},"image_urls":{"type":"array","items":{"type":"string","format":"uri"},"maxItems":10,"description":"Publicly downloadable URLs. For frame mode, supply the first frame and optionally the last, in that order. Reference mode allows up to 10 images total across image_urls and reference_image roles."},"first_frame_image":{"type":"string","format":"uri","description":"Opening frame URL. Use in place of the ordered image_urls array in frame mode."},"last_frame_image":{"type":"string","format":"uri","description":"Closing frame URL. A first frame is required."},"image_with_roles":{"type":"array","maxItems":10,"items":{"type":"object","required":["url","role"],"properties":{"url":{"type":"string","format":"uri"},"role":{"enum":["first_frame","last_frame","reference_image"]}}},"description":"Image URLs with explicit roles. Submit frame mode and reference mode as separate requests."},"video_urls":{"type":"array","items":{"type":"string","format":"uri"},"maxItems":5,"description":"Reference video URLs."},"audio_urls":{"type":"array","items":{"type":"string","format":"uri"},"maxItems":5,"description":"Reference audio URLs."},"omni_reference_task_type":{"type":"string","enum":["auto","reference"],"default":"auto","description":"Set reference when image_urls are reference images rather than first/last frames."}}},"ChatMessage":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string","enum":["system","developer","user","assistant","tool"]},"content":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"object","additionalProperties":true}}]}}}}},"paths":{"/api/pricing":{"get":{"operationId":"getLivePricing","summary":"List all live models, ratios and multi-tier media pricing (no auth required)","tags":["Discovery"],"responses":{"200":{"description":"Live model pricing and versioned media capabilities. Media clients use the declared adapter and parameter rules for generation.","content":{"application/json":{"schema":{"type":"object","properties":{"success":{"type":"boolean"},"media_capability_version":{"type":"integer","example":1},"data":{"type":"array","items":{"type":"object","properties":{"model_name":{"type":"string"},"model_ratio":{"type":"number"},"completion_ratio":{"type":"number"},"model_price":{"type":"number"},"quota_type":{"type":"integer"},"video_pricing":{"type":"object","additionalProperties":{"type":"number"}},"image_pricing":{"type":"object","additionalProperties":{"type":"number"}},"media_capabilities":{"type":"object","required":["version","kind","adapter"],"description":"Optional public generation contract. A missing contract on a v1 gateway disables automatic execution for this row. Unknown versions or adapters require a compatible client.","properties":{"version":{"type":"integer","example":1},"kind":{"type":"string","enum":["image","video"]},"adapter":{"type":"string","examples":["video-task","image-task","image-sync","builtin"]},"profile":{"type":"string","description":"Compatibility profile for a built-in workflow."},"billing":{"type":"string","examples":["per_second","per_image","image_tiers"]},"parameters":{"type":"object","additionalProperties":{"type":"object","required":["field","type"],"properties":{"field":{"type":"string"},"type":{"enum":["integer","enum","boolean","images"]},"min":{"type":"integer"},"max":{"type":"integer"},"max_bytes":{"type":"integer"},"values":{"type":"array","items":{"type":["string","boolean"]}},"default":{}}}}}}}}}}}}}}}}},"/v1/models":{"get":{"operationId":"listModels","summary":"List models enabled for your API key (OpenAI-compatible)","tags":["Discovery"],"security":[{"bearerAuth":[]}],"responses":{"200":{"description":"OpenAI-compatible model list."}}}},"/v1/chat/completions":{"post":{"operationId":"createChatCompletion","summary":"Create a chat completion (OpenAI-compatible across Claude, GPT, Gemini, DeepSeek, Kimi, GLM, Grok)","tags":["Text & Reasoning"],"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model","messages"],"properties":{"model":{"type":"string","example":"claude-sonnet-5-5"},"messages":{"type":"array","items":{"$ref":"#/components/schemas/ChatMessage"}},"stream":{"type":"boolean","default":false},"temperature":{"type":"number"},"max_tokens":{"type":"integer"},"tools":{"type":"array","items":{"type":"object","additionalProperties":true}}}}}}},"responses":{"200":{"description":"Chat completion object or SSE stream when stream=true."},"401":{"description":"Invalid API key."},"402":{"description":"Insufficient quota balance."}}}},"/v1/responses":{"post":{"operationId":"createResponse","summary":"Create a model response (OpenAI Responses API, used by Codex CLI and agent SDKs)","tags":["Text & Reasoning"],"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model","input"],"properties":{"model":{"type":"string","example":"gpt-5.4"},"input":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"object"}}]},"stream":{"type":"boolean","default":false},"reasoning":{"type":"object","additionalProperties":true}}}}}},"responses":{"200":{"description":"Responses API payload or SSE stream."}}}},"/v1/embeddings":{"post":{"operationId":"createEmbedding","summary":"Create text embeddings (OpenAI-compatible)","tags":["Text & Reasoning"],"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model","input"],"properties":{"model":{"type":"string","example":"text-embedding-3-small"},"input":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]}}}}}},"responses":{"200":{"description":"Embedding vectors."}}}},"/v1/images/tasks":{"post":{"operationId":"createImageTask","summary":"Submit an async image generation/editing task (Seedream 5.5, GPT Image 2/2.6, Flux, Nano Banana, Midjourney)","tags":["Images"],"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model","prompt"],"properties":{"model":{"type":"string","example":"seedream-5-5"},"prompt":{"type":"string"},"size":{"type":"string","example":"1K"},"n":{"type":"integer","default":1,"minimum":1,"maximum":4},"output_format":{"type":"string","example":"png"},"transparent_background":{"type":"boolean"},"layer_decomposition":{"type":"boolean"},"quality":{"type":"string","enum":["low","medium","high"]},"resolution":{"type":"string","example":"1k"},"image":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}]}}}}}},"responses":{"200":{"description":"Task submission acknowledgement containing data.task_id."}}}},"/v1/images/tasks/{task_id}":{"get":{"operationId":"getImageTask","summary":"Poll an async image task by task_id until status is SUCCESS or FAILURE","description":"Returns task status in data.status. When SUCCESS, public direct image URLs are returned in data.data.data.result.images[].url[] (no Authorization header needed to download; top-level data.result_url is intentionally omitted for async image tasks).","tags":["Images"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"task_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Task status (data.status) and generated direct image URLs at data.data.data.result.images[].url[] once completed."}}}},"/v1/video/generations":{"post":{"operationId":"createVideoTask","summary":"Submit an async video generation task (Muse Video, MAGI-2, Seedance, MiniMax H3, Veo, Kling and others)","description":"Muse Video generates 720p video with audio for 2–10 whole seconds (default 10), optionally guided by up to 9 images. See the [Muse Video API guide](https://wanapis.com/docs/muse-video). MAGI-2 generates 1080p at 4–30 whole seconds and defaults to 5 seconds. MAGI-2 jobs are charged at submission for the requested output duration. Failed MAGI-2 jobs are refunded.","externalDocs":{"description":"MAGI-2 video generation guide","url":"https://wanapis.com/docs/magi-2"},"tags":["Video"],"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model","prompt"],"if":{"properties":{"model":{"const":"magi-2"}},"required":["model"]},"then":{"$ref":"#/components/schemas/Magi2VideoRequest"},"else":{"if":{"properties":{"model":{"const":"muse-video-ext"}},"required":["model"]},"then":{"$ref":"#/components/schemas/MuseVideoRequest"}},"properties":{"model":{"type":"string","example":"seedance-2-5-flash"},"prompt":{"type":"string"},"duration":{"oneOf":[{"type":"integer"},{"type":"string"}],"example":5},"resolution":{"type":"string","example":"720p"},"size":{"type":"string","example":"adaptive"},"generate_audio":{"type":"boolean"},"image_urls":{"type":"array","items":{"type":"string"}},"video_urls":{"type":"array","items":{"type":"string"}},"audio_urls":{"type":"array","items":{"type":"string"}}}},"examples":{"museText":{"summary":"Muse Video text-to-video with audio","value":{"model":"muse-video-ext","prompt":"Track a red bicycle along a cobbled street, with the sound of tires on stone.","duration":4,"aspect_ratio":"16:9"}},"museReferences":{"summary":"Muse Video with two reference images","value":{"model":"muse-video-ext","prompt":"Show the red bicycle from the first photo passing the bakery in the second photo.","seconds":"6s","aspect_ratio":"3:2","image_urls":["https://example.com/bicycle.jpg","https://example.com/bakery.jpg"]}},"magi2Text":{"summary":"MAGI-2 text-to-video","value":{"model":"magi-2","prompt":"A slow tracking shot of a paper boat drifting through a rain puddle","resolution":"1080p","duration":5,"aspect_ratio":"16:9","generate_audio":true}},"magi2Frames":{"summary":"MAGI-2 first and last frames","value":{"model":"magi-2","prompt":"The paper boat drifts from the opening frame to the closing frame","duration":5,"image_urls":["https://example.com/opening.jpg","https://example.com/closing.jpg"],"generate_audio":false}},"magi2References":{"summary":"MAGI-2 image, video, and audio references","value":{"model":"magi-2","prompt":"Keep the boat from the image and follow the camera motion and rhythm of the reference clips","duration":8,"aspect_ratio":"16:9","omni_reference_task_type":"reference","image_urls":["https://example.com/boat.jpg"],"video_urls":["https://example.com/camera.mp4"],"audio_urls":["https://example.com/rain.mp3"]}}}}}},"responses":{"200":{"description":"Task submission acknowledgement. Muse Video and MAGI-2 return the gateway task ID in data.task_id. Some other models return a top-level ID.","content":{"application/json":{"schema":{"type":"object"},"examples":{"magi2":{"summary":"MAGI-2 task accepted","value":{"code":"success","data":{"task_id":"task_example","status":"submitted"}}}}}}},"400":{"description":"Invalid task parameters, such as an unsupported MAGI-2 resolution or duration."},"401":{"description":"Missing or invalid API key."}}}},"/v1/video/generations/{task_id}":{"get":{"operationId":"getVideoTask","summary":"Poll an async video task by task_id","description":"For Muse Video and MAGI-2, read data.status. SUCCESS includes data.result_url, an authenticated download URL. FAILURE includes data.fail_reason. Keep polling the same task ID until a terminal state.","tags":["Video"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"task_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"Video task state and, on success, the video result URL when available.","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"string"},"data":{"type":"object","properties":{"task_id":{"type":"string"},"status":{"type":"string","examples":["NOT_START","IN_PROGRESS","SUCCESS","FAILURE"]},"progress":{"type":"string","examples":["100%"]},"result_url":{"type":"string","description":"For completed Muse Video and MAGI-2 tasks, fetch with the task owner's API key."},"fail_reason":{"type":"string","description":"Failure details when the task fails."}}}}},"examples":{"magi2":{"summary":"Completed MAGI-2 task","value":{"code":"success","data":{"task_id":"task_example","status":"SUCCESS","progress":"100%","result_url":"https://api.wanapis.com/v1/videos/task_example/content"}}}}}}},"401":{"description":"Missing or invalid API key."}}}},"/v1/videos/{task_id}":{"get":{"operationId":"getOpenAIVideoTask","summary":"Poll video status in the OpenAI-compatible format","description":"Muse Video and MAGI-2 return top-level id and status (queued, in_progress, completed or failed). On completed, metadata.url points to the authenticated content endpoint.","tags":["Video"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"task_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"OpenAI-compatible video task.","content":{"application/json":{"schema":{"type":"object"},"example":{"id":"task_example","object":"video","model":"magi-2","status":"completed","progress":100,"metadata":{"url":"https://api.wanapis.com/v1/videos/task_example/content"}}}}},"401":{"description":"Missing or invalid API key."}}}},"/v1/videos/{task_id}/content":{"get":{"operationId":"downloadVideoTaskContent","summary":"Download a completed video using the task owner's API key","description":"Send the same WanAPIs Bearer API key used to submit the task. Muse Video and MAGI-2 provide this URL as data.result_url. Save the MP4 before the hosted result expires.","tags":["Video"],"security":[{"bearerAuth":[]}],"parameters":[{"name":"task_id","in":"path","required":true,"schema":{"type":"string"}},{"name":"Range","in":"header","schema":{"type":"string"},"description":"Optional byte range, for example bytes=0-1023."}],"responses":{"200":{"description":"Full MP4 content.","content":{"video/mp4":{"schema":{"type":"string","format":"binary"}}}},"206":{"description":"Partial MP4 content for a supported byte range.","content":{"video/mp4":{"schema":{"type":"string","format":"binary"}}}},"400":{"description":"The task has not successfully completed."},"401":{"description":"Missing or invalid API key."},"404":{"description":"The task does not exist or is not visible to the caller."}}}},"/v1/media":{"post":{"operationId":"uploadTemporaryMedia","summary":"Free temporary upload for local image, video or audio reference files used by /v1/video/generations or /v1/images/tasks","tags":["Media"],"security":[{"bearerAuth":[]}],"requestBody":{"required":true,"content":{"multipart/form-data":{"schema":{"type":"object","required":["file"],"properties":{"file":{"type":"string","format":"binary"}}}}}},"responses":{"200":{"description":"Returns temporary URL usable as reference media."}}}}}}