{"openapi":"3.1.0","info":{"title":"Mogu IO API","version":"1.0.0","description":"Agent-friendly AI model gateway for language, image, video, audio, and embedding models.\n\nBase URL for SDKs: https://mogu.io/api/v1\n\nLanguage model formats:\n- OpenAI Format: POST /api/v1/chat/completions, protocol openai_chat_completions, broad SDK compatibility.\n- Anthropic Format: POST /api/v1/messages, protocol anthropic_messages, preferred for Claude/Anthropic models when supported.\n- Gemini Format: POST /api/v1/models/{model}:generateContent, protocol gemini_generate_content, preferred for Gemini models when supported.\n\nAgents should inspect GET /api/v1/models, choose by category + supported_protocols, then fetch per-model docs at /docs/{category}/{model-id}/llms.txt when model-specific parameters are needed.\n\nOpenAI Format multi-turn state:\n- Gemini image outputs may encode thought_signature in image_url.url data URIs. Pass returned URLs back unchanged.\n- Anthropic reasoning outputs may include message.reasoning_details with signatures. Preserve reasoning_details on assistant messages in later turns.\n\nAvailable models: black-forest-labs/flux-3/image-edit, black-forest-labs/flux-3/text-to-image, bytedance/seedream-v4.5, bytedance/seedream-v5.5, google/gemini-3.1-flash-image-preview, google/gemini-nano-banana-2.1, midjourney/text-to-image, openai/ gpt-image-2.5-flare, openai/gpt-image-2, x-ai/grok-imagine-image-v2.0/edit, x-ai/grok-imagine-image-v2.0/text-to-image, x-ai/grok-imagine-image/edit, anthropic/claude-fable-5.2, anthropic/claude-haiku-5.5, anthropic/claude-opus-4.6, anthropic/claude-opus-4.7, anthropic/claude-opus-5.5, anthropic/claude-sonnet-4.6, anthropic/claude-sonnet-5.5, deepseek/deepseek-flash, deepseek/deepseek-v4-flash, deepseek/deepseek-v4-flash-vision-exp, deepseek/deepseek-v4-pro, deepseek/deepseek-v4.1-flash, deepseek/deepseek-v4.1-pro, google/gemini-3.1-flash-image-preview, google/gemini-3.1-pro-preview, google/gemini-3.5-flash, google/gemini-3.7-flash, google/gemini-3.8-flash, minimax/minimax-m2.7, minimax/minimax-m3, minimax/minimax-m3.1-flash, moonshotai/kimi-k3, moonshotai/kimi-k3.1-pro, openai/ grok-4.7, openai/gpt-4o, openai/gpt-4o-mini, openai/gpt-5.4, openai/gpt-5.6-sol, openai/gpt-6-astra, openai/gpt-6.1-sol, openai/gpt-6.1-terra, tencent/hy3, tencent/hy4, tencent/hy4-preview, x-ai/grok-4-1-fast-non-reasoning, x-ai/grok-4-1-fast-reasoning, z-ai/glm-5.2, z-ai/glm-5.3, alibaba/wan-2.6, alibaba/wan-2.7, alibaba/wan-3.0, alibaba/wan-3.0/image-to-video, alibaba/wan-3.0/text-to-video, black-forest-labs/flux-3/image-to-video, black-forest-labs/flux-3/text-to-video, black-forest-labs/flux-3/video-edit, bytedance/seedance-2.0, bytedance/seedance-2.5/text-to-video, bytedance/seedance-2.5/video-edit, kwaivgi/kling-v4.0-flash/image-to-video, kwaivgi/kling-v4.0-flash/text-to-video, kwaivgi/kling-v4.0-flash/video-edit, kwaivgi/kling-v4.0/image-to-video, kwaivgi/kling-v4.0/text-to-video, kwaivgi/kling-v4.0/video-edit\n\nUser-facing Text models use the internal language category in model docs URLs.","contact":{"email":"develop@weshop.com"}},"servers":[{"url":"https://mogu.io","description":"Production origin"}],"security":[{"bearerAuth":[]},{"xApiKeyAuth":[]}],"paths":{"/api/v1/chat/completions":{"post":{"operationId":"createChatCompletion","summary":"Create chat completion using OpenAI Format","description":"OpenAI-compatible chat completions. Use for broad SDK compatibility. If the selected model supports anthropic_messages or gemini_generate_content and native semantics matter, prefer the corresponding endpoint.\n\nMulti-turn provider state:\n- Gemini image editing: pass returned image_url.url values unchanged if they contain thought_signature.\n- Anthropic thinking: preserve assistant message.reasoning_details in later turns.\n\nAvailable models: anthropic/claude-fable-5.2, anthropic/claude-haiku-5.5, anthropic/claude-opus-4.6, anthropic/claude-opus-4.7, anthropic/claude-opus-5.5, anthropic/claude-sonnet-4.6, anthropic/claude-sonnet-5.5, deepseek/deepseek-flash, deepseek/deepseek-v4-flash, deepseek/deepseek-v4-flash-vision-exp, deepseek/deepseek-v4-pro, deepseek/deepseek-v4.1-flash, deepseek/deepseek-v4.1-pro, google/gemini-3.1-flash-image-preview, google/gemini-3.1-pro-preview, google/gemini-3.5-flash, google/gemini-3.7-flash, google/gemini-3.8-flash, minimax/minimax-m2.7, minimax/minimax-m3, minimax/minimax-m3.1-flash, moonshotai/kimi-k3, moonshotai/kimi-k3.1-pro, openai/ grok-4.7, openai/gpt-4o, openai/gpt-4o-mini, openai/gpt-5.4, openai/gpt-5.6-sol, openai/gpt-6-astra, openai/gpt-6.1-sol, openai/gpt-6.1-terra, tencent/hy3, tencent/hy4, tencent/hy4-preview, x-ai/grok-4-1-fast-non-reasoning, x-ai/grok-4-1-fast-reasoning, z-ai/glm-5.2, z-ai/glm-5.3","tags":["Language: OpenAI Format"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model","messages"],"properties":{"model":{"type":"string","description":"Model ID","enum":["anthropic/claude-fable-5.2","anthropic/claude-haiku-5.5","anthropic/claude-opus-4.6","anthropic/claude-opus-4.7","anthropic/claude-opus-5.5","anthropic/claude-sonnet-4.6","anthropic/claude-sonnet-5.5","deepseek/deepseek-flash","deepseek/deepseek-v4-flash","deepseek/deepseek-v4-flash-vision-exp","deepseek/deepseek-v4-pro","deepseek/deepseek-v4.1-flash","deepseek/deepseek-v4.1-pro","google/gemini-3.1-flash-image-preview","google/gemini-3.1-pro-preview","google/gemini-3.5-flash","google/gemini-3.7-flash","google/gemini-3.8-flash","minimax/minimax-m2.7","minimax/minimax-m3","minimax/minimax-m3.1-flash","moonshotai/kimi-k3","moonshotai/kimi-k3.1-pro","openai/ grok-4.7","openai/gpt-4o","openai/gpt-4o-mini","openai/gpt-5.4","openai/gpt-5.6-sol","openai/gpt-6-astra","openai/gpt-6.1-sol","openai/gpt-6.1-terra","tencent/hy3","tencent/hy4","tencent/hy4-preview","x-ai/grok-4-1-fast-non-reasoning","x-ai/grok-4-1-fast-reasoning","z-ai/glm-5.2","z-ai/glm-5.3"]},"messages":{"type":"array","description":"Array of message objects","items":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string","enum":["system","user","assistant","tool"]},"content":{"nullable":true,"oneOf":[{"type":"string","description":"Text content"},{"type":"array","description":"Multimodal content array","items":{"type":"object","properties":{"type":{"type":"string","enum":["text","image_url","video_url","audio_url"]},"text":{"type":"string"},"image_url":{"type":"object","properties":{"url":{"type":"string","format":"uri"}}},"video_url":{"type":"object","properties":{"url":{"type":"string","format":"uri"}}},"audio_url":{"type":"object","properties":{"url":{"type":"string","format":"uri"}}}}}}]},"reasoning_details":{"type":"array","description":"Provider reasoning details for multi-turn continuity. Preserve unchanged on assistant messages when returned, especially Anthropic thinking signatures.","items":{"type":"object","properties":{"type":{"type":"string","enum":["thinking"]},"thinking":{"type":"string"},"signature":{"type":"string","description":"Provider signature that must be preserved across turns"}}}},"images":{"type":"array","description":"Generated images returned by multimodal text models. Preserve image_url.url unchanged across Gemini image-edit turns.","items":{"type":"object","properties":{"type":{"type":"string","enum":["image_url"]},"image_url":{"type":"object","properties":{"url":{"type":"string","description":"Image URL or data URI. Gemini may include thought_signature in the data URI prefix; preserve unchanged."}}}}}}}}},"stream":{"type":"boolean","default":false,"description":"Enable SSE streaming"},"stream_options":{"type":"object","additionalProperties":true},"temperature":{"type":"number","minimum":0,"maximum":2,"description":"Sampling temperature"},"max_completion_tokens":{"type":"integer","description":"Maximum completion tokens, including reasoning tokens"},"max_tokens":{"type":"integer","deprecated":true,"description":"Deprecated alias for max_completion_tokens"},"top_p":{"type":"number","minimum":0,"maximum":1,"description":"Nucleus sampling"},"stop":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"string"}}],"description":"Stop sequences"},"presence_penalty":{"type":"number"},"frequency_penalty":{"type":"number"},"tools":{"type":"array","items":{"type":"object"},"description":"OpenAI-compatible tool definitions"},"tool_choice":{"oneOf":[{"type":"string","enum":["none","auto","required"]},{"type":"object"}]},"reasoning":{"type":"object","description":"Reasoning config for supported providers"},"modalities":{"type":"array","items":{"type":"string","enum":["text","image"]},"description":"Output modalities"},"image_config":{"type":"object","additionalProperties":true}}}}}},"responses":{"200":{"description":"Chat completion response","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"object":{"type":"string","const":"chat.completion"},"created":{"type":"integer"},"model":{"type":"string"},"choices":{"type":"array","items":{"type":"object","properties":{"index":{"type":"integer"},"message":{"type":"object","properties":{"role":{"type":"string"},"content":{"type":"string","nullable":true},"images":{"type":"array","description":"Optional generated images for multimodal text models","items":{"type":"object","properties":{"type":{"type":"string"},"image_url":{"type":"object","properties":{"url":{"type":"string","description":"Image URL or base64 data URI, depending on the text model protocol"}}}}}},"reasoning_details":{"type":"array","description":"Optional provider reasoning details. Preserve unchanged in later turns when present.","items":{"type":"object","properties":{"type":{"type":"string","enum":["thinking"]},"thinking":{"type":"string"},"signature":{"type":"string"}}}}}},"finish_reason":{"type":"string","enum":["stop","length","content_filter","tool_calls","error"]}}}},"usage":{"type":"object","properties":{"prompt_tokens":{"type":"integer"},"completion_tokens":{"type":"integer"},"total_tokens":{"type":"integer"}}},"credit":{"type":"number","description":"Cost in credits (1 USD = 10,000 credits)"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/InsufficientCredits"},"429":{"$ref":"#/components/responses/RateLimit"}}}},"/api/v1/messages":{"post":{"operationId":"createAnthropicMessage","summary":"Create response using Anthropic Format","description":"Anthropic Messages-compatible endpoint. Prefer this for Claude/Anthropic models when supported, especially for native content blocks, tool use, thinking blocks, and thinking signatures.\n\nAvailable models: anthropic/claude-fable-5.2, anthropic/claude-haiku-5.5, anthropic/claude-opus-4.6, anthropic/claude-opus-4.7, anthropic/claude-opus-5.5, anthropic/claude-sonnet-4.6, anthropic/claude-sonnet-5.5, deepseek/deepseek-flash, deepseek/deepseek-v4-flash, deepseek/deepseek-v4-flash-vision-exp, deepseek/deepseek-v4-pro, deepseek/deepseek-v4.1-flash, deepseek/deepseek-v4.1-pro, minimax/minimax-m3, minimax/minimax-m3.1-flash, moonshotai/kimi-k3, moonshotai/kimi-k3.1-pro, tencent/hy3, tencent/hy4, tencent/hy4-preview, z-ai/glm-5.2, z-ai/glm-5.3","tags":["Language: Anthropic Format"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model","max_tokens","messages"],"properties":{"model":{"type":"string","description":"Model ID","enum":["anthropic/claude-fable-5.2","anthropic/claude-haiku-5.5","anthropic/claude-opus-4.6","anthropic/claude-opus-4.7","anthropic/claude-opus-5.5","anthropic/claude-sonnet-4.6","anthropic/claude-sonnet-5.5","deepseek/deepseek-flash","deepseek/deepseek-v4-flash","deepseek/deepseek-v4-flash-vision-exp","deepseek/deepseek-v4-pro","deepseek/deepseek-v4.1-flash","deepseek/deepseek-v4.1-pro","minimax/minimax-m3","minimax/minimax-m3.1-flash","moonshotai/kimi-k3","moonshotai/kimi-k3.1-pro","tencent/hy3","tencent/hy4","tencent/hy4-preview","z-ai/glm-5.2","z-ai/glm-5.3"]},"max_tokens":{"type":"integer","description":"Maximum output tokens"},"system":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"object"}}],"description":"System prompt"},"messages":{"type":"array","description":"Anthropic user/assistant messages","items":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string","enum":["user","assistant"]},"content":{"oneOf":[{"type":"string"},{"type":"array","items":{"type":"object"}}]}}}},"stream":{"type":"boolean","default":false,"description":"Enable Anthropic SSE streaming"},"temperature":{"type":"number","minimum":0,"maximum":2},"top_p":{"type":"number","minimum":0,"maximum":1},"top_k":{"type":"integer"},"stop_sequences":{"type":"array","items":{"type":"string"}},"tools":{"type":"array","items":{"type":"object"}},"tool_choice":{"type":"object"},"thinking":{"type":"object","description":"Extended thinking config for supported models"}}}}}},"responses":{"200":{"description":"Anthropic message response","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"type":{"type":"string","const":"message"},"role":{"type":"string","const":"assistant"},"model":{"type":"string"},"content":{"type":"array","items":{"type":"object"}},"stop_reason":{"type":"string","nullable":true},"usage":{"type":"object","properties":{"input_tokens":{"type":"integer"},"output_tokens":{"type":"integer"}}},"credit":{"type":"number","description":"Cost in credits"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/InsufficientCredits"},"429":{"$ref":"#/components/responses/RateLimit"}}}},"/api/v1/models/{model}:generateContent":{"post":{"operationId":"generateGeminiContent","summary":"Generate content using Gemini Format","description":"Gemini Generate Content-compatible endpoint. Prefer this for Gemini-family models when supported, especially for native contents, parts, multimodal files, and generationConfig.\n\nAvailable models: google/gemini-3.1-flash-image-preview, google/gemini-3.1-pro-preview, google/gemini-3.5-flash, google/gemini-3.7-flash, google/gemini-3.8-flash","tags":["Language: Gemini Format"],"parameters":[{"name":"model","in":"path","required":true,"schema":{"type":"string","enum":["google/gemini-3.1-flash-image-preview","google/gemini-3.1-pro-preview","google/gemini-3.5-flash","google/gemini-3.7-flash","google/gemini-3.8-flash"]},"description":"Model ID"}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["contents"],"properties":{"contents":{"type":"array","items":{"type":"object"},"description":"Gemini content turns"},"systemInstruction":{"type":"object"},"generationConfig":{"type":"object","additionalProperties":true},"tools":{"type":"array","items":{"type":"object"}}}}}}},"responses":{"200":{"description":"Gemini generateContent response with optional credit field","content":{"application/json":{"schema":{"type":"object","additionalProperties":true}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/InsufficientCredits"},"429":{"$ref":"#/components/responses/RateLimit"}}}},"/api/v1/images/generations":{"post":{"operationId":"createImage","summary":"Generate image","description":"Image generation supporting both sync (default) and async modes. Returns Mogu IO signed image URLs. Download returned URLs as soon as possible; signed URLs are short-lived. This URL normalization only applies to the Image category endpoint; text models that output images through chat/messages keep their protocol-native response shape.\n\nSet async=true to receive a 202 with a task ID for polling. Default is synchronous (waits for result).\n\nAvailable models: black-forest-labs/flux-3/image-edit, black-forest-labs/flux-3/text-to-image, bytedance/seedream-v4.5, bytedance/seedream-v5.5, google/gemini-3.1-flash-image-preview, google/gemini-nano-banana-2.1, midjourney/text-to-image, openai/ gpt-image-2.5-flare, openai/gpt-image-2, x-ai/grok-imagine-image-v2.0/edit, x-ai/grok-imagine-image-v2.0/text-to-image, x-ai/grok-imagine-image/edit\n\nParameters vary by model. See model-specific schemas in the request body.","tags":["Images"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model","prompt"],"properties":{"model":{"type":"string","description":"Model ID","enum":["black-forest-labs/flux-3/image-edit","black-forest-labs/flux-3/text-to-image","bytedance/seedream-v4.5","bytedance/seedream-v5.5","google/gemini-3.1-flash-image-preview","google/gemini-nano-banana-2.1","midjourney/text-to-image","openai/ gpt-image-2.5-flare","openai/gpt-image-2","x-ai/grok-imagine-image-v2.0/edit","x-ai/grok-imagine-image-v2.0/text-to-image","x-ai/grok-imagine-image/edit"]},"prompt":{"type":"string","description":"Text description of the image"},"async":{"type":"boolean","default":false,"description":"If true, returns 202 with task ID for polling instead of waiting for result"},"timeout":{"description":"Maximum wait time in seconds","default":900,"type":"number","minimum":30,"maximum":1800},"images":{"description":"1 to 10 image URLs or data URIs; each image at least 256 pixels per dimension and at most 4 megapixels","type":"array","items":{"type":"string","format":"uri"}},"resolution":{"description":"Output resolution","default":"1k","type":"string","enum":["1k","2k","4k"]},"aspect_ratio":{"description":"Leave blank to follow the first input image","default":"","type":"string","enum":["","21:9","2:1","16:9","3:2","7:5","4:3","5:4","1:1","4:5","3:4","5:7","2:3","9:16","1:2"]},"output_format":{"description":"Output image format","default":"jpeg","type":"string","enum":["jpeg","png"]},"size":{"description":"Image size in pixels (width*height)","default":"2048*2048","type":"string","enum":["512*512","768*768","1024*1024","1536*1536","2048*2048","1024*768","768*1024","1536*1024","1024*1536"]},"n":{"description":"Number of images","default":1,"type":"number","minimum":1,"maximum":4},"seed":{"description":"Random seed (-1 for random)","default":-1,"type":"number"},"image":{"description":"Optional reference image URLs or base64 images for editing","type":"array"},"image_size":{"description":"Image size","default":"1K","type":"string","enum":["1K","2K","4K"]},"response_format":{"description":"Response format","default":"b64_json","type":"string","enum":["b64_json","url"]},"niji":{"description":"Niji mode for anime/Eastern aesthetics","default":"close","type":"string","enum":["close","0","5","6"]},"sref":{"description":"URL of a reference image for style guidance","type":"string","format":"uri"},"chaos":{"description":"Variety in results (0-100)","default":0,"type":"number","minimum":0,"maximum":100},"weird":{"description":"Unconventional aesthetics (0-3000)","default":0,"type":"number","minimum":0,"maximum":3000},"quality":{"description":"Image detail and processing time (0.25=draft, 1=standard, 2=high)","default":"1","type":"string","enum":["0.25","0.5","1","2"]},"stylize":{"description":"Artistic style intensity (0-1000)","default":100,"type":"number","minimum":0,"maximum":1000},"version":{"description":"Midjourney model version","default":"7","type":"string","enum":["6","6.1","7"]},"mask":{"description":"Mask image for partial editing (PNG with alpha channel)","type":"string","format":"uri"},"background":{"description":"Background type","default":"auto","type":"string","enum":["opaque","auto"]}}}}}},"responses":{"200":{"description":"Generated image(s)","content":{"application/json":{"schema":{"type":"object","properties":{"created":{"type":"integer"},"data":{"type":"array","items":{"type":"object","properties":{"url":{"type":"string","format":"uri","description":"Short-lived signed image URL"}}}},"usage":{"type":"object","description":"Optional provider token usage","additionalProperties":true},"credit":{"type":"number","description":"Cost in credits"}}}}}},"202":{"description":"Task accepted (async mode)","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"Task ID"},"object":{"type":"string","const":"image_generation.task"},"status":{"type":"string","const":"pending"},"created":{"type":"integer","description":"Unix timestamp of task creation"},"timeout":{"type":"integer","description":"Timeout in seconds"},"polling_url":{"type":"string","description":"URL to poll for task status"},"cancel_url":{"type":"string","description":"URL to cancel the task"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/InsufficientCredits"},"429":{"$ref":"#/components/responses/RateLimit"}}}},"/api/v1/images/generations/{id}":{"get":{"operationId":"getImageTask","summary":"Get image task status","description":"Poll an async image generation task. Returns current status and result when completed.","tags":["Images"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Task ID"}],"responses":{"200":{"description":"Task status","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"Task ID"},"object":{"type":"string","const":"image_generation.task"},"status":{"type":"string","enum":["pending","running","completed","failed","cancelled"]},"created":{"type":"integer","description":"Unix timestamp of task creation"},"completed_at":{"type":"integer","nullable":true,"description":"Unix timestamp of completion"},"started_at":{"type":"integer","nullable":true,"description":"Unix timestamp when processing started"},"data":{"type":"array","description":"Generated images (present when completed)","items":{"type":"object","properties":{"url":{"type":"string","format":"uri","description":"Short-lived signed image URL"}}}},"usage":{"type":"object","description":"Optional provider token usage (present when completed)","additionalProperties":true},"credit":{"type":"number","description":"Cost in credits (present when completed)"},"polling_url":{"type":"string","description":"URL to poll for task status"},"error":{"type":"string","nullable":true,"description":"Error message (present when failed)"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"Task not found"}}}},"/api/v1/images/generations/{id}/cancel":{"post":{"operationId":"cancelImageTask","summary":"Cancel image task","description":"Cancel a pending image generation task. Only tasks in pending status can be cancelled.","tags":["Images"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Task ID"}],"responses":{"200":{"description":"Task cancelled","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"Task ID"},"object":{"type":"string","const":"image_generation.task"},"status":{"type":"string","const":"cancelled"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"Task not found"},"409":{"description":"Task already started and cannot be cancelled"}}}},"/api/v1/videos":{"post":{"operationId":"createVideoTask","summary":"Create video generation task","description":"Async video generation with timeout support. Returns task ID — poll GET /api/v1/videos/:id for result. Use timeout to control maximum generation time.\n\nAvailable models: alibaba/wan-2.6, alibaba/wan-2.7, alibaba/wan-3.0, alibaba/wan-3.0/image-to-video, alibaba/wan-3.0/text-to-video, black-forest-labs/flux-3/image-to-video, black-forest-labs/flux-3/text-to-video, black-forest-labs/flux-3/video-edit, bytedance/seedance-2.0, bytedance/seedance-2.5/text-to-video, bytedance/seedance-2.5/video-edit, kwaivgi/kling-v4.0-flash/image-to-video, kwaivgi/kling-v4.0-flash/text-to-video, kwaivgi/kling-v4.0-flash/video-edit, kwaivgi/kling-v4.0/image-to-video, kwaivgi/kling-v4.0/text-to-video, kwaivgi/kling-v4.0/video-edit","tags":["Videos"],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model","prompt"],"properties":{"model":{"type":"string","description":"Model ID","enum":["alibaba/wan-2.6","alibaba/wan-2.7","alibaba/wan-3.0","alibaba/wan-3.0/image-to-video","alibaba/wan-3.0/text-to-video","black-forest-labs/flux-3/image-to-video","black-forest-labs/flux-3/text-to-video","black-forest-labs/flux-3/video-edit","bytedance/seedance-2.0","bytedance/seedance-2.5/text-to-video","bytedance/seedance-2.5/video-edit","kwaivgi/kling-v4.0-flash/image-to-video","kwaivgi/kling-v4.0-flash/text-to-video","kwaivgi/kling-v4.0-flash/video-edit","kwaivgi/kling-v4.0/image-to-video","kwaivgi/kling-v4.0/text-to-video","kwaivgi/kling-v4.0/video-edit"]},"prompt":{"type":"string","description":"Video description"},"timeout":{"description":"Maximum wait time in seconds","default":1800,"type":"number","minimum":60,"maximum":3600},"seed":{"description":"Random seed (-1 for random)","default":-1,"type":"number","minimum":-1,"maximum":2147483647},"duration":{"description":"Duration in seconds","default":"5","type":"string","enum":["5","10","15"]},"shot_type":{"description":"Single shot or multi-shot","default":"single","type":"string","enum":["single","multi"]},"resolution":{"description":"Video resolution","default":"720p","type":"string","enum":["480p","720p","1080p"]},"aspect_ratio":{"description":"Aspect ratio (text-to-video only)","default":"16:9","type":"string","enum":["16:9","9:16"]},"frame_images":{"description":"Reference images for image-to-video (omit for text-to-video)","type":"array","items":{"type":"string"}},"negative_prompt":{"description":"Things to avoid in the video","type":"string"},"enable_prompt_expansion":{"description":"Enable AI prompt expansion","default":false,"type":"boolean"},"video":{"description":"Source video URL to edit (first 15 seconds are used)","type":"string","format":"uri"},"generate_audio":{"description":"Generate audio; disable to preserve the source audio when available","default":true,"type":"boolean"},"reference_audios":{"description":"Optional reference audio, up to 5 clips and 15 seconds combined","type":"array","items":{"type":"string","format":"uri"}},"reference_images":{"description":"Optional reference images, up to 10","type":"array","items":{"type":"string","format":"uri"}},"image":{"description":"First-frame image URL or data URI","type":"string","format":"uri"},"last_image":{"description":"Optional last-frame image URL or data URI","type":"string","format":"uri"},"input_references":{"description":"Reference images for style/content guidance (text-to-video only)","type":"array","items":{"type":"string"}},"reference_videos":{"description":"Reference videos for motion/style guidance (text-to-video only)","type":"array","items":{"type":"string"}},"images":{"description":"Up to 10 reference image URLs","type":"array","items":{"type":"string","format":"uri"}},"keep_original_sound":{"description":"Keep the original source audio","default":false,"type":"boolean"},"keyframes":{"description":"Ordered middle keyframe URLs; first, last and middle frames total at most 10","type":"array","items":{"type":"string","format":"uri"}},"audios":{"description":"Up to 3 reference audio URLs; each 5-30 seconds","type":"array","items":{"type":"string","format":"uri"}}}}}}},"responses":{"202":{"description":"Task created","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"Task ID"},"status":{"type":"string","const":"pending"},"polling_url":{"type":"string","description":"URL to poll for status"}}}}}},"400":{"$ref":"#/components/responses/BadRequest"},"401":{"$ref":"#/components/responses/Unauthorized"},"402":{"$ref":"#/components/responses/InsufficientCredits"}}}},"/api/v1/videos/{id}":{"get":{"operationId":"getVideoTask","summary":"Get video task status","description":"Poll every 3-5 seconds until status is completed, failed, or cancelled. Polling is a pure DB read and returns instantly.","tags":["Videos"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Task ID"}],"responses":{"200":{"description":"Task status","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string"},"status":{"type":"string","enum":["pending","running","in_progress","completed","failed","cancelled"]},"output":{"type":"object","properties":{"urls":{"type":"array","items":{"type":"string","format":"uri"}}},"description":"Present when status is completed"},"error":{"type":"string","description":"Present when status is failed"},"credit":{"type":"number","description":"Cost in credits (present when completed)"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"Task not found"}}}},"/api/v1/videos/{id}/cancel":{"post":{"operationId":"cancelVideoTask","summary":"Cancel video task","description":"Cancel a pending video generation task. Only tasks in pending status can be cancelled.","tags":["Videos"],"parameters":[{"name":"id","in":"path","required":true,"schema":{"type":"string"},"description":"Task ID"}],"responses":{"200":{"description":"Task cancelled","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"Task ID"},"status":{"type":"string","const":"cancelled"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"Task not found"},"409":{"description":"Task already started and cannot be cancelled"}}}},"/api/v1/models":{"get":{"operationId":"listModels","summary":"List available models","description":"Returns all enabled models with their capabilities.","tags":["Models"],"responses":{"200":{"description":"Model list","content":{"application/json":{"schema":{"type":"object","properties":{"object":{"type":"string","const":"list"},"data":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string","description":"Model ID"},"unique_id":{"type":"string","description":"Category-qualified ID, e.g. language/vendor/model"},"object":{"type":"string","const":"model"},"category":{"type":"string","enum":["language","image","video","audio","embedding"],"description":"Internal category. Display \"language\" as Text in user-facing UI."},"display_name":{"type":"string"},"vendor":{"type":"string"},"supported_protocols":{"type":"array","items":{"type":"string"}},"input_modalities":{"type":"array","items":{"type":"string"}},"output_modalities":{"type":"array","items":{"type":"string"}},"total_context":{"type":"integer","nullable":true},"max_output":{"type":"integer","nullable":true},"parameter_schema":{"type":"object","additionalProperties":true},"documentation_url":{"type":"string","format":"uri"}}}}}}}}}}}},"/api/v1/models/{model}":{"get":{"operationId":"retrieveModel","summary":"Retrieve model","description":"Returns one enabled model. If the same model ID exists in multiple categories, pass the category query parameter.","tags":["Models"],"parameters":[{"name":"model","in":"path","required":true,"schema":{"type":"string"},"description":"Model ID, e.g. vendor/model-name"},{"name":"category","in":"query","required":false,"schema":{"type":"string","enum":["language","image","video","audio","embedding"]},"description":"Internal category. Use language for user-facing Text models."}],"responses":{"200":{"description":"Model","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"string","description":"Model ID"},"unique_id":{"type":"string","description":"Category-qualified ID, e.g. language/vendor/model"},"object":{"type":"string","const":"model"},"category":{"type":"string","enum":["language","image","video","audio","embedding"]},"display_name":{"type":"string"},"vendor":{"type":"string"},"supported_protocols":{"type":"array","items":{"type":"string"}},"input_modalities":{"type":"array","items":{"type":"string"}},"output_modalities":{"type":"array","items":{"type":"string"}},"total_context":{"type":"integer","nullable":true},"max_output":{"type":"integer","nullable":true},"parameter_schema":{"type":"object","additionalProperties":true},"documentation_url":{"type":"string","format":"uri"}}}}}},"401":{"$ref":"#/components/responses/Unauthorized"},"404":{"description":"Model not found"}}}}},"components":{"securitySchemes":{"bearerAuth":{"type":"http","scheme":"bearer","description":"API key (sk-...)"},"xApiKeyAuth":{"type":"apiKey","in":"header","name":"x-api-key","description":"API key header used by Anthropic-compatible clients"}},"responses":{"BadRequest":{"description":"Invalid request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string","enum":["invalid_request_error","content_moderation","input_too_large"]}}}}}}}},"Unauthorized":{"description":"Invalid API key","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string","const":"auth_error"}}}}}}}},"InsufficientCredits":{"description":"Not enough credits","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string","const":"insufficient_credits"}}}}}}}},"RateLimit":{"description":"Rate limit exceeded","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"message":{"type":"string"},"type":{"type":"string","const":"rate_limit_error"}}}}}}}}}},"tags":[{"name":"Language: OpenAI Format","description":"OpenAI-compatible chat completions for broad SDK compatibility"},{"name":"Language: Anthropic Format","description":"Anthropic-compatible messages for selected language models"},{"name":"Language: Gemini Format","description":"Gemini Generate Content-compatible API for selected language models"},{"name":"Images","description":"Sync and async image generation from text prompts"},{"name":"Videos","description":"Async video generation with task polling and cancellation support"},{"name":"Models","description":"Model discovery and capabilities"}]}