TurboMax AI Start creating

How an AI agent generates video and images through MCP: the full workflow

MCP · · 3 min read

The exact tool-call sequence an autonomous AI agent uses to generate video, images or music with TurboMax over MCP: choose a model, estimate cost, set a spending ceiling, start the job, poll, and handle every failure.

Most "AI video API" write-ups stop at a single request. An agent needs more: a way to choose, a way to price, a way to wait, and a way to fail safely. This is the sequence that works against TurboMax's MCP server, written so an agent (or the person configuring one) can follow it step by step.

The sequence

  1. list_models — filter by type (image, video, audio) and, if you know it, task (for example text-to-video or image-to-video). Each result lists the allowed aspectRatios, resolutions, durationRange and modes. Use these values exactly; the server rejects anything outside what a model declares rather than silently adjusting it.
  2. estimate_cost — pass modelId, and duration and resolution for video. The figure is approximate; the real amount is held when the job starts.
  3. (Optional) upload_source_media — for image-to-video, image editing or video-to-video, upload the source and keep the returned url. Only files uploaded through TurboMax are accepted as sources.
  4. generate_media — send modelId, the user's prompt, the task parameters, and maxCredits. The response contains a taskId and the exact cost that was held.
  5. get_task with waitSeconds (up to 55). Repeat while status is processing.
  6. Use the result. When status is completed, resultUrl is the file. It is a time-limited link, so download it or hand it over promptly.
{ "name": "generate_media",
  "arguments": {
    "modelId": "<id from list_models>",
    "prompt": "A paper boat drifting down a rain-soaked street, slow push-in",
    "task": "text-to-video",
    "duration": 5,
    "maxCredits": 150
  } }

Rules an agent should follow

  • Use the person's words. Do not add scenes, styles or subjects the user did not ask for. The server never writes a prompt for the caller and refuses an empty one.
  • Always set maxCredits when no human approves each call. It is checked against the exact estimate before a credit is held, and a refusal charges nothing.
  • Read before you spend. get_wallet returns the balance and today's usage against the account's daily limits.
  • Do not loop on errors that will not change. prompt_rejected, api_key_scope and payment_required need a different prompt, key or account state, not a retry.

How failures behave

SituationResultCharged?
Cost above maxCreditscost_exceeds_maxNo
Balance too lowinsufficient_credits with balance and required amountNo
Prompt violates policyprompt_rejectedNo
Rate limit or daily caprate_limited or a daily-limit codeNo
Job fails or times out upstreamstatus: failedRefunded in full
You cancel with cancel_taskstatus: canceledHold released
Job completesstatus: completedSettled to the actual cost

retry_task re-runs a failed or cancelled job as a new job with a fresh hold, so it spends credits again.

Choosing a model

Do not hard-code one. Catalogues change: models are added, repriced and retired. An agent that calls list_models each session always works from the current list, and can pick by constraint ("cheapest model that supports image-to-video at 1080p") instead of by name. For help comparing model families see the AI video model comparison and what AI video generation costs.

Giving an agent access safely

Create a read-only key first and let the agent browse. When it must generate, create a separate generate key (this requires a paid account), keep the wallet balance to what you are willing to lose, and revoke the key when the task is done. A key can never change the account, billing or settings. Setup instructions are in connecting Claude, Cursor and VS Code; the overview is in the MCP server guide.

Frequently asked questions

How can an AI agent generate a video?

Through an MCP server that exposes generation tools. With TurboMax the agent calls list_models to choose a model, estimate_cost to price it, generate_media with a maxCredits ceiling to start the job, then get_task with waitSeconds until the status is completed, and finally reads the resultUrl.

Is there an API an autonomous agent can use to create AI images and video?

Yes. TurboMax offers an MCP server at https://turbomaxai.com/mcp and the same operations over its REST API, authenticated with a personal API key. Generation is billed from a prepaid wallet, so the human owner sets the maximum exposure.

How long does an AI video generation take through the API?

It depends on the model and settings and can run from under a minute to several minutes. Generation is asynchronous: generate_media returns a taskId immediately, and get_task reports progress and can wait up to 55 seconds per call, so an agent simply calls it again until the job is completed or failed.

What happens to the cost if an agent's generation fails?

A failed, timed-out or cancelled job is refunded in full automatically. The cost is held when the job starts and settled to the real provider cost when it ends, with any difference returned.

How do I stop an agent from overspending on AI generation?

Use a read-only key unless it must generate, put only a limited amount in the wallet, and require maxCredits on every generate_media call. The server refuses any job above that ceiling before charging, and the account's daily caps still apply.

Try it with $5

Prepaid credits, no Monthly subscription, no card on file. Failed generations are refunded automatically and unused credits never expire.

Start creating