API Documentation
Base URL: https://api.aimodelapi.ai. Auth header Authorization: Bearer sk-ama-..., or x-api-key. The body is JSON.
Important compliance notice (read before signing up)
- ModelAPI is an AI algorithm & orchestration cloud (SaaS): Harness Control, Nexus routing, session budgets, and compaction — proprietary software on licensed B2B channels.
- We do not offer: bulk fake signups for free quotas, reverse-engineered web/API access, ChatGPT/Claude subscription splitting (Sub2API), identity spoofing to bypass geo-blocks, or circumvention proxies marketed to restricted regions.
- Not available to entities registered in mainland China, or accounts operated for/on behalf of such entities (including policies such as Anthropic's restrictions on China-controlled use). Individuals must reside in provider-permitted jurisdictions.
- Cross-border transfers, personal data, export controls, and generative-AI regulatory duties are your responsibility as the customer/data controller. Do not submit state secrets, unauthorized PII, or unlawful content.
Details: Compliance & Acceptable Use · Terms · Privacy
Endpoints
| Use | Method | Path |
|---|---|---|
| Chat | POST | /v1/chat/completions |
| Messages | POST | /v1/messages |
| Models | GET | /v1/models |
| Images | POST | /v1/images/generations |
| Video tasks | POST | /v1/contents/generations/tasks |
| Balance | GET | /v1/credits |
| Health | GET | /health/live |
Health checks do not need a key. GET /health is the deep check. Create keys in the console. Successful calls deduct balance.
Chat
POST /v1/chat/completions. For OpenAI-compatible clients the Base URL is https://api.aimodelapi.ai/v1. model and messages are required. Model IDs come from GET /v1/models.
| Field | Default | Description |
|---|---|---|
| model | required | Model ID |
| messages | required | role is system, user, assistant, or tool |
| max_tokens | omit | Maximum output length |
| temperature | omit | Sampling temperature |
| stream | false | When true, the response is SSE and ends with data: [DONE] |
| tools | none | Tool definitions. The model may return tool_calls |
curl -sS https://api.aimodelapi.ai/v1/chat/completions \
-H "Authorization: Bearer sk-ama-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-latest",
"messages": [{"role": "user", "content": "Introduce yourself in one sentence"}],
"max_tokens": 64
}'On success the text is in choices[0].message.content. Usage is in usage. The charge is applied after the response completes.
{
"id": "chatcmpl-...",
"model": "claude-sonnet-latest",
"choices": [{ "message": { "role": "assistant", "content": "..." } }],
"usage": { "prompt_tokens": 12, "completion_tokens": 20, "total_tokens": 32 }
}Messages
POST /v1/messages. The Base URL for this path is https://api.aimodelapi.ai, without /v1. The key is the same as the chat API. model, max_tokens, and messages are required.
curl -sS https://api.aimodelapi.ai/v1/messages \
-H "Authorization: Bearer sk-ama-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-latest",
"max_tokens": 64,
"messages": [{"role": "user", "content": "Introduce yourself in one sentence"}]
}'Models
GET /v1/models returns the models you can call. Add capability=chat, image, video or 3d. A single model is GET /v1/models/{id}.
curl -sS "https://api.aimodelapi.ai/v1/models?capability=chat" \ -H "Authorization: Bearer sk-ama-YOUR_KEY"
Image generation · Wan image
Synchronous API. Base URL: https://api.aimodelapi.ai. Auth header Authorization: Bearer sk-ama-.... The body is a flat JSON object. The examples use IMG-bl-wan2.7-image. Text-to-image, reference images, and edits use the same model. The image URL is in data[].url of that response. The chat and video APIs do not generate images.
| Action | Method | Path |
|---|---|---|
| Generate | POST | /v1/images/generations |
| Edit | POST | /v1/images/edits |
Both paths use the same body. Put reference images in image or images. Do not use multipart upload. Insufficient balance returns 402 and no image is generated. A missing prompt returns 400. An unknown model returns 404.
Model IDs
| ID | Use | Resolution / price |
|---|---|---|
| IMG-bl-qwen-image-3.0 | Text-to-image, reference images, edits | 1K and 2K output $0.03 / image · reference $0.003 / image |
| IMG-bl-qwen-image-3.0-pro | Same, stronger layout and small text | 1K output $0.04 · 2K output $0.075 · reference $0.003 |
| IMG-bl-wan2.7-image | Text-to-image, reference images, edits | 1K, 2K · $0.03 / image |
| IMG-bl-wan2.7-image-pro | Same | Text-to-image also 4K · with references, max 2K · $0.075 / image |
Catalog: GET /v1/models?capability=image. Successful responses are charged by the number of images returned.
Request parameters · Qwen-Image 3.0
Applies to IMG-bl-qwen-image-3.0 and IMG-bl-qwen-image-3.0-pro. Upstream names qwen-image-3.0 and qwen-image-3.0-pro also work. Omit image for text-to-image; include it to edit. Pixel area at or below 2,250,000 is billed as 1K, above that as 2K. When size is omitted, 3.0 charges the same either way. Pro checks balance at the 2K rate, then settles on the actual resolution.
| Field | Default | Description |
|---|---|---|
| model | required | IMG-bl-qwen-image-3.0 or IMG-bl-qwen-image-3.0-pro |
| prompt | required | Chinese or English |
| image / images | none | 1–3 reference images. http(s) or data URL. Do not send an empty list |
| n | 1 | Output count, 1–6, including when reference images are present |
| size | auto | WIDTH*HEIGHT, area 512*512 to 2048*2048, aspect 1:8 to 8:1. 1K, 2K, or auto also work |
| negative_prompt | omit | What to keep out of the image |
| seed | random | Integer 0–2147483647 |
| prompt_extend | true | Rewrite the prompt. Upstream default is on when omitted |
| prompt_extend_mode | direct | direct or agent. agent is text-to-image only |
| enable_thinking | true | Thinking. Applies only when prompt_extend is on |
| watermark | false | Add a watermark |
curl -sS https://api.aimodelapi.ai/v1/images/generations \
-H "Authorization: Bearer sk-ama-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "IMG-bl-qwen-image-3.0",
"prompt": "一张竖版海报,标题清晰",
"size": "1024x1536",
"n": 1,
"prompt_extend": true
}'Request parameters · Wan 2.7
Applies to IMG-bl-wan2.7-image and IMG-bl-wan2.7-image-pro. With no reference image and no size, the default is 1024*1024. With a reference image and no size, the default is 2K.
| Field | Default | Description |
|---|---|---|
| model | required | IMG-bl-wan2.7-image or IMG-bl-wan2.7-image-pro |
| prompt | required | Chinese or English. For an edit, describe the change |
| image / images | none | Reference images, up to 9. image_url is also accepted. http(s) or data URL |
| n | 1 | Image count. Up to 6 without references, up to 4 with references |
| size | 1024*1024 or 2K | Standard tier: 1K, 2K. Pro text-to-image also accepts 4K. With references, 4K is output as 2K |
| thinking_mode | omit | true or false. Applies only when there is no reference image |
| watermark | omit | true or false |
| response_format | url | url or b64_json |
Text-to-image example
curl -sS https://api.aimodelapi.ai/v1/images/generations \
-H "Authorization: Bearer sk-ama-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "IMG-bl-wan2.7-image",
"prompt": "A ceramic teacup on a wooden table, soft morning light",
"n": 1,
"size": "2K"
}'Success is HTTP 200. The image URL is in data[].url. The link expires.
{
"created": 1710000000,
"data": [{ "url": "https://..." }]
}Edit example
POST /v1/images/generations and POST /v1/images/edits both work. With a reference image, output is at most 2K.
curl -sS https://api.aimodelapi.ai/v1/images/edits \
-H "Authorization: Bearer sk-ama-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "IMG-bl-wan2.7-image",
"prompt": "Replace the background with a rainy night street. Keep the product unchanged.",
"image": "https://example.com/cup.png",
"size": "2K"
}'Pro text-to-image uses IMG-bl-wan2.7-image-pro. size may be 4K, and you may pass thinking_mode. Video uses POST /v1/contents/generations/tasks, with model IDs WAN-*.
Video generation · Wan video
Asynchronous task API. Base URL: https://api.aimodelapi.ai. Auth header Authorization: Bearer sk-ama-.... The body is a flat JSON object. The examples use WAN-video-3.0. /v1/videos and the image API are not used for video.
| Action | Method | Path |
|---|---|---|
| Submit task | POST | /v1/contents/generations/tasks |
| Poll task | GET | /v1/contents/generations/tasks/{id} |
| List tasks | GET | /v1/contents/generations/tasks |
| Cancel (Seedance only) | DELETE | /v1/contents/generations/tasks/{id} |
Wan models support create and poll. Cancel returns 405, and there is no task list. The id in the response is used to poll. Insufficient balance returns 402 and the task is not created. A resolution outside the price list returns 400.
Model IDs
| ID | Use | Resolution / duration / price |
|---|---|---|
| WAN-video-3.0 | 3.0 text, image, and reference, one model | 480P $0.05/s · 720P $0.10/s · 1080P $0.20/s · 2–30s |
| WAN-video-3.0-prime | Same, faster | 480P $0.068/s · 720P $0.14/s · 1080P $0.28/s · 2–30s |
| WAN-t2v-3.0 / WAN-i2v-3.0 / WAN-r2v-3.0 | 3.0 text / image / reference | Same as WAN-video-3.0 |
| WAN-t2v-2.7 / WAN-i2v-2.7 / WAN-r2v-2.7 | 2.7 text / image / reference | 720P $0.10/s · 1080P $0.15/s · text and image 2–15s, reference 2–10s |
| WAN-t2v / WAN-i2v / WAN-r2v | 2.5 | 480P $0.02/s · 720P $0.04/s · up to 30s |
Catalog: GET /v1/models?capability=video. WAN-t2v is 2.5.
Request parameters · Wan 3.0
Applies to WAN-video-3.0 and WAN-video-3.0-prime. If resolution is omitted, it is 720P. If duration is omitted, it is 5 seconds. After the task is created, the charge is the per-second price for that resolution multiplied by the duration.
| Field | Default | Description |
|---|---|---|
| model | required | WAN-video-3.0 or WAN-video-3.0-prime |
| prompt | required for text-to-video | Chinese or English, about 20,000 characters. Refer to assets in order as “image 1” and “video 1” |
| resolution | 720P | 480P, 720P, 1080P. A value outside the price list returns 400 |
| duration | 5 | Integer seconds from 2 to 30. -1 is smart duration and is billed as a 5-second estimate |
| ratio | adaptive | adaptive, 21:9, 16:9, 4:3, 1:1, 3:4, 9:16 |
| prompt_extend | true | false turns off prompt expansion. true when the request includes file or link |
| watermark | false | true places an “AI generated” mark at the bottom right |
| audio | true | Boolean. true includes an audio track, false is silent. Audio files use reference_audio |
| seed | random | -1 or 0–2147483647 |
| negative_prompt | none | Content to avoid |
Assets are publicly reachable http or https URLs. Images may be data URLs.
| Asset field | Max | Role |
|---|---|---|
| first_frame_image | 1 | First frame. Alias first_frame |
| last_frame_image | 1 | Last frame. Alias last_frame |
| reference_image | 10 | Reference images |
| reference_video | 5 clips, 15 seconds total | Reference video |
| reference_audio | 5 clips, 15 seconds total | Reference audio. Alias driving_audio |
Put multiple images, multiple videos, or a mix in the media array. Each item is an object with type and url. A URL array in reference_image or reference_video is not forwarded. A single reference_image string is one reference image. An image without type is treated as the first frame. First and last frames cannot be combined with reference images, video, or audio. Reference images, video, and audio can be used together. With reference video, input duration plus output duration is at most 30 seconds.
Text-to-video example · Wan 3.0
curl -sS https://api.aimodelapi.ai/v1/contents/generations/tasks \
-H "Authorization: Bearer sk-ama-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "WAN-video-3.0",
"prompt": "A golden retriever running on a beach at sunset, cinematic",
"duration": 5,
"resolution": "720P",
"ratio": "16:9"
}'A successful create returns a task ID. status is queued, and there is no video URL yet.
{
"id": "<task_id>",
"model": "WAN-video-3.0",
"status": "queued",
"created_at": 1710000000
}Image-to-video example · Wan 3.0
curl -sS https://api.aimodelapi.ai/v1/contents/generations/tasks \
-H "Authorization: Bearer sk-ama-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "WAN-video-3.0",
"prompt": "The camera slowly pushes in as the sea breeze moves the hair",
"duration": 5,
"resolution": "720P",
"first_frame_image": "https://example.com/first.jpg"
}'Multiple reference images · Wan 3.0
Up to 10 images. “Image 1” and “image 2” in the prompt follow the array order.
curl -sS https://api.aimodelapi.ai/v1/contents/generations/tasks \
-H "Authorization: Bearer sk-ama-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "WAN-video-3.0",
"prompt": "The person in image 1 walks onto the street in image 2",
"duration": 5,
"resolution": "720P",
"ratio": "adaptive",
"media": [
{ "type": "reference_image", "url": "https://example.com/a.jpg" },
{ "type": "reference_image", "url": "https://example.com/b.jpg" }
]
}'Multiple reference videos · Wan 3.0
Up to 5 clips, 15 seconds in total. Videos must be public URLs. “Video 1” follows the array order.
curl -sS https://api.aimodelapi.ai/v1/contents/generations/tasks \
-H "Authorization: Bearer sk-ama-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "WAN-video-3.0",
"prompt": "Follow the motion in video 1 and switch the scene to video 2",
"duration": 5,
"resolution": "720P",
"ratio": "adaptive",
"media": [
{ "type": "reference_video", "url": "https://example.com/a.mp4" },
{ "type": "reference_video", "url": "https://example.com/b.mp4" }
]
}'Images and video together · Wan 3.0
curl -sS https://api.aimodelapi.ai/v1/contents/generations/tasks \
-H "Authorization: Bearer sk-ama-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "WAN-video-3.0",
"prompt": "The person in image 1 walks with the motion from video 1",
"duration": 5,
"resolution": "720P",
"ratio": "adaptive",
"media": [
{ "type": "reference_image", "url": "https://example.com/person.jpg" },
{ "type": "reference_video", "url": "https://example.com/walk.mp4" }
]
}'First and last frame · Wan 3.0
One of each. Do not add reference images or reference video.
curl -sS https://api.aimodelapi.ai/v1/contents/generations/tasks \
-H "Authorization: Bearer sk-ama-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "WAN-video-3.0",
"prompt": "Transition from the first image to the second image",
"duration": 5,
"resolution": "720P",
"ratio": "adaptive",
"media": [
{ "type": "first_frame", "url": "https://example.com/first.jpg" },
{ "type": "last_frame", "url": "https://example.com/last.jpg" }
]
}'Poll a task
GET /v1/contents/generations/tasks/{id}. queued and running mean it is not finished. succeeded puts the video URL in content.video_url, as mp4. The link expires. failed puts the error in error.message.
curl -sS https://api.aimodelapi.ai/v1/contents/generations/tasks/<task_id> \ -H "Authorization: Bearer sk-ama-YOUR_KEY"
succeeded also returns usage. output_video_duration is the finished duration in seconds. SR is the resolution tier. The charge is taken when the task is created. usage does not change the amount already charged.
{
"id": "<task_id>",
"model": "WAN-video-3.0",
"status": "succeeded",
"content": { "video_url": "https://..." },
"usage": {
"output_video_duration": 5,
"input_video_duration": 0,
"SR": 720,
"ratio": "16:9"
}
}Images use POST /v1/images/generations, with model IDs IMG-*. The chat API /v1/chat/completions does not return video.
Check balance
GET /v1/credits. Use the same sk-ama- key you use for API calls. There is no body. The header can also be x-api-key. Top-up and checkout use the console login token, not this key.
GET /v1/credits HTTP/1.1 Host: api.aimodelapi.ai Authorization: Bearer sk-ama-YOUR_KEY # or curl -s "https://api.aimodelapi.ai/v1/credits" \ -H "Authorization: Bearer sk-ama-YOUR_KEY"
Returns the latest 20 entries, newest first. Charges are negative. model is present only when that entry has a model.
| Field | Type | Meaning |
|---|---|---|
| balance_usd | number | Current balance in USD, up to 6 decimal places |
| recent[].time | string | UTC time |
| recent[].amount_usd | number | Amount. Charges are negative, top-ups are positive |
| recent[].type | string | charge · top-up · refund · bonus |
| recent[].description | string | Description |
| recent[].model | string | Model ID. Omitted when there is no model |
{
"balance_usd": 25.317564,
"recent": [
{
"time": "2026-10-28T02:31:25.702Z",
"amount_usd": -0.325,
"type": "charge",
"description": "Video: Wan 3.0 Text-to-Video (~5s)",
"model": "WAN-video-3.0"
}
]
}Errors
| HTTP | Meaning |
|---|---|
| 400 | The request does not match this endpoint |
| 401 | Missing or invalid key |
| 402 | Insufficient balance. The request was not run |
| 404 | Unknown model or path |
| 429 | Rate limit or session budget exceeded |
| 502–504 | Temporarily unavailable |
The error body includes message. Rate limits may include Retry-After. Free accounts have per-minute and daily request limits. Paid accounts are limited by balance.
Streaming
Set stream: true on the chat and messages APIs. The response is Server-Sent Events and ends with data: [DONE]. The image and video task APIs do not use this field.
curl -N https://api.aimodelapi.ai/v1/chat/completions \
-H "Authorization: Bearer sk-ama-YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-latest",
"messages": [{"role": "user", "content": "Count from 1 to 3"}],
"max_tokens": 32,
"stream": true
}'