APIها
Task API
Create image, video and music generations as tasks, follow them to a final status, and understand what each one costs.
این صفحه هنوز ترجمه نشده است. نسخه انگلیسی نمایش داده میشود.
A task is one generation request: an image, a video or a song. Generation takes from seconds to minutes, so the API is asynchronous. You create a task, get it back at once with the status queued, and then either poll it or let a webhook tell you when it ends.
| Method and path | What it does |
|---|---|
POST /v1/tasks | Create a task |
GET /v1/tasks/{id} | Get a task |
GET /v1/tasks | List tasks, newest first |
POST /v1/tasks/{id}/cancel | Cancel a task that is still queued |
Create a task
POST /v1/tasks with a JSON body:
| Field | Type | Description | |
|---|---|---|---|
model | string | required | The model ID, such as google/veo-3.1-fast. See the model reference. |
input | object | required | The model's parameters. Each model has its own; the model reference lists them. Parameters you leave out take the model's defaults. |
callback_url | string | optional | An https URL that Minu calls once when the task ends. See Webhooks. |
metadata | object | optional | Your own data, for example an order ID. It is returned with the task and in webhooks. At most 4,000 characters of JSON. |
curl https://api.minu.ai/v1/tasks \
-H "Authorization: Bearer $MINU_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-8421-video" \
-d '{
"model": "google/veo-3.1-fast",
"input": {
"prompt": "A slow dolly shot through a bamboo forest in morning fog"
},
"callback_url": "https://your-app.example/hooks/minu",
"metadata": { "order_id": "8421" }
}'const task = await fetch('https://api.minu.ai/v1/tasks', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.MINU_API_KEY}`,
'Content-Type': 'application/json',
'Idempotency-Key': 'order-8421-video',
},
body: JSON.stringify({
model: 'google/veo-3.1-fast',
input: { prompt: 'A slow dolly shot through a bamboo forest in morning fog' },
callback_url: 'https://your-app.example/hooks/minu',
metadata: { order_id: '8421' },
}),
}).then((response) => response.json());import os
import requests
task = requests.post(
"https://api.minu.ai/v1/tasks",
headers={
"Authorization": f"Bearer {os.environ['MINU_API_KEY']}",
"Idempotency-Key": "order-8421-video",
},
json={
"model": "google/veo-3.1-fast",
"input": {"prompt": "A slow dolly shot through a bamboo forest in morning fog"},
"callback_url": "https://your-app.example/hooks/minu",
"metadata": {"order_id": "8421"},
},
).json()The response has status 200 and is the task object, with "status": "queued".
The request is checked before anything is reserved: the model must exist and be allowed for your key, input must match the model's parameters, and your available balance must cover the price. A request that fails a check gets an error and creates no task.
Retry safely with Idempotency-Key
A network error can leave you not knowing whether a task was created. Send an Idempotency-Key header with a value that is unique to the request, up to 200 characters, and retry with the same value:
- The same key with the same body returns the task that was created the first time. It is not run or charged twice.
- The same key with a different body is refused with
409 idempotency_conflict.
Keys are scoped to your organization. Use a fresh value, such as a UUID or your own order ID, for every new request.
The task object
{
"id": "task_1k8r2m4p0a7c9e3g5j6n8q2s",
"object": "task",
"model": "google/veo-3.1-fast",
"status": "succeeded",
"input": { "prompt": "A slow dolly shot through a bamboo forest in morning fog" },
"outputs": [
{ "index": 0, "type": "video", "url": "https://…", "mime": "video/mp4", "bytes": 5120733 }
],
"error": null,
"estimated_cost_usd": "0.250000",
"cost_usd": "0.250000",
"metadata": { "order_id": "8421" },
"created_at": 1796169600,
"started_at": 1796169602,
"completed_at": 1796169671
}| Field | Type | Description |
|---|---|---|
id | string | Identifier of the task, starting with task_. |
object | string | Always "task". |
model | string | The model ID. |
status | string | See Statuses. |
input | object | The parameters the task runs with: yours, plus the model's defaults for the ones you left out. |
outputs | array | The results that were delivered. Empty until the task ends. See Outputs. |
error | object or null | code and message when the task did not succeed. See task errors. |
estimated_cost_usd | string | The amount reserved from your balance when the task was created. |
cost_usd | string or null | The amount charged. null while the task is in progress. |
metadata | object or null | What you sent in metadata. |
created_at | integer | When the task was created, in Unix seconds. |
started_at | integer or null | When generation started. |
completed_at | integer or null | When the task reached its final status. |
Outputs
Each entry of outputs is one delivered result:
| Field | Description |
|---|---|
index | Position of the result, from 0. |
type | image, video, audio or text. |
url | Where to download the file. null for a text output. |
mime, bytes | Media type and size of the file. |
text | The text itself, for a text output. |
An output can carry more facts about the result beside these, depending on the model, such as a duration, a title or lyrics. Read the fields you know and ignore the rest.
Files are served from Minu's storage and are kept for 14 days by default; an organization's owner or admin can set the retention between 1 and 30 days in the console. Download what you need to keep.
Statuses
| Status | Final | Meaning |
|---|---|---|
queued | no | Accepted and waiting for a free slot. |
running | no | Being generated. |
finalizing | no | Generated; the results are being stored. |
succeeded | yes | Every requested result was delivered. |
partially_succeeded | yes | Some of the requested results were delivered. You are charged for those only. |
failed | yes | No result. Not charged. error says why. |
canceled | yes | Canceled before it started. Not charged. |
expired | yes | Did not finish in time. Not charged. |
Get a task
curl https://api.minu.ai/v1/tasks/task_1k8r2m4p0a7c9e3g5j6n8q2s \
-H "Authorization: Bearer $MINU_API_KEY"Returns the task object, or 404 not_found when no task with that ID belongs to your organization.
When you poll, a request every two to five seconds is plenty. Polling requests count against your rate limit; with many tasks in flight, a webhook is the better tool.
List tasks
curl "https://api.minu.ai/v1/tasks?limit=20&status=succeeded" \
-H "Authorization: Bearer $MINU_API_KEY"| Query parameter | Description |
|---|---|
limit | Tasks per page, 1 to 100. Default 20. |
before | The id of the last task of the previous page. Returns the tasks created before it. |
status | Only tasks with this status. |
model | Only tasks of this model. |
{
"object": "list",
"data": [
{ "id": "task_1k8r2m4p0a7c9e3g5j6n8q2s", "object": "task", "status": "succeeded" }
],
"has_more": true
}Each entry of data is a full task object (shortened here). Tasks come newest first. While has_more is true, pass the last id as before to get the next page.
Cancel a task
curl -X POST https://api.minu.ai/v1/tasks/task_1k8r2m4p0a7c9e3g5j6n8q2s/cancel \
-H "Authorization: Bearer $MINU_API_KEY"Only a task that is still queued can be canceled. It becomes canceled, its reserved amount is released, and nothing is charged. Once a task has started it runs to its end, and the call answers 409 not_cancelable.
How tasks are billed
- At creation, the price is reserved.
estimated_cost_usdis taken out of your available balance but not yet charged. If the available balance cannot cover it, the request is refused with402 insufficient_balanceand no task is created. - When the task ends, you are charged for what was delivered.
cost_usdis the amount charged; anything reserved beyond it is released.
What "delivered" means depends on how the model is priced:
- Models priced per image, per video or per second charge each delivered result on its own. Ask for four images and receive three, and the task is
partially_succeededwithcost_usdat three images. - Models priced per request, such as songs, charge the request in full once it delivers a result.
A task that is failed, canceled or expired has cost_usd of "0.000000". There is no refund step, because nothing was charged.
GET /v1/balance shows the effect at any moment:
{
"object": "balance",
"currency": "usd",
"balance_usd": "49.750000",
"reserved_usd": "0.250000",
"available_usd": "49.500000"
}available_usd is balance_usd less reserved_usd, and is what new requests can spend.
Waiting and time limits
- Concurrency. Each organization runs a limited number of tasks at once. Further tasks stay
queueduntil a slot is free. The queue is bounded: when it is full,POST /v1/tasksanswers429 queue_fullwith aRetry-Afterheader. - Time limits. Every model has a time limit. A task that does not finish within it becomes
expired, with the error codetimeout. A task that waits in the queue too long without getting a slot becomesfailed, with the error codecapacity_timeout. Neither is charged.
If the default limits do not fit your workload, talk to us.