Skip to content

How do I let an AI assistant suggest generations without letting it spend freely?

Let the assistant propose a task, then have your application validate its fields, obtain a quote and require the appropriate spending approval before creation. Keep the API key private and enforce max_credits, model permissions and ownership in trusted backend logic. Text generated by an assistant is not itself authorization to spend or access another user's media.

SHIP A RELIABLE INTEGRATIONAISwapLab team · Editorial methodPublished 2 min read
Open API documentationExplore 67 Image SkillsPrivate keys · Explicit credit approval
Article workflow: Constrain proposals; Show the concrete task; Bound subsequent work.
Workflow diagram: Constrain proposals → Show the concrete task → Bound subsequent work. Read the article for evidence and limits.

Approval must bind to the actual request

A vague instruction to make something interesting should not become an unlimited series of image and video attempts. Save the exact approved payload and ceiling, and invalidate that approval if the model, source, resolution or other material input changes. An idempotency identifier protects a task from duplication; it does not approve new tasks.

What to do next

  1. 01

    Constrain proposals

    Allow only supported models and fields, and validate any owned reference IDs against the application user. Treat prompts and retrieved text as untrusted input rather than backend policy.

  2. 02

    Show the concrete task

    Present the intended media, settings and estimated credits before the creation step. Persist approval with the immutable body and a durable identifier.

  3. 03

    Bound subsequent work

    Require a separate decision for creative retries or expanded batches. Keep automatic recovery limited to the same approved task and report unknown outcomes without silently replacing them.

A concrete example

Illustrative design: an assistant suggests three poster concepts, but the user approves only one 1K image. The backend permits that specific task and ceiling; a later assistant suggestion cannot automatically dispatch the remaining two concepts.

Before you call it ready

  • Approval covers a concrete payload.
  • Backend controls enforce the ceiling.
  • Creative expansion is separate from network recovery.

When to stop or choose another method

If your workflow relies on the model promising not to overspend, move the control into application code before launch. A prompt instruction is not an effective billing boundary.

Sources

One task. A recoverable workflow.

Check the contract, approve the quote and retain the job.

Open API documentation