Generate an image with your AI assistant #

View this page as Markdown

On this page

Prompt:

Draw a logo for my recipe app and save it where I can get at it.

Also works:

  • "Make me a cover picture for the landing page."
  • "Draw three icons for the menu."

Ask your AI assistant to make the picture in this conversation. Use the example prompt above or describe the picture you need. If your deployed application should make pictures for its users, read Generate an image with AI instead.

What you need #

  • A Turn Zero account. You need no application.
  • An AI assistant signed in as you, or an account-wide token (Connect your AI assistant). This call refuses tokens restricted to one application or to actions allowed by a grant. Device sign-in and an application's platform credential also cannot make this call.
  • No provider account and no provider key.

Before your AI starts #

Image Gen is available through MCP only at https://dev.turnzero.ai/mcp, the turnzero connection. Claude Code and Codex use that address. In claude.ai or ChatGPT, add it as a custom connector. This connection also brings the hosting tools.

Check the following before starting:

  • Only if you want the picture saved in an application's storage: its identifier, from list_applications.
  • The month's use, from read_account on your own sign-in: image_generation gives used, free_images and resets_at. used counts delivered images. It also counts blocked or failed calls if the platform could not remove them from the monthly count. free_images is the month's free count. A token minted for a job does not receive that member. An authorized computer's token does.

Steps #

1. Generate the image #

Your AI assistant calls generate_image with prompt. With no application, the picture is saved in your account for seven days. A prompt holds at most 8,000 characters. The prompt goes to the model's provider, and the platform keeps nothing about it.

These inputs are optional:

  • resolution is 1K, the default, or 2K. The platform uses one model, and you don't choose it.
  • application saves the picture in that application's storage instead, until you delete it.
  • environment is development or production, and is allowed only with application. Absent, the file goes to the environment the application's deploys go to.

An AI assistant that can't run a shell command also passes inline: true.

2. Get the file #

A saved picture's result gives its name, mime_type and bytes. Keep the name with the result; export_account also lists each picture still kept in your account under images, with its name and metadata but no file or download link.

A picture saved in your account #

The result normally includes a link that opens in a browser, and commands.curl and commands.powershell to download the file. Anyone holding the link can read the picture without signing in until expires_at. It lasts one hour, or until kept_until if that comes sooner. You can use it more than once while it lasts.

To get a new link, your AI assistant calls renew_image_link with the picture's name. The new link ends the old one at once. This call counts no image and does not extend kept_until. If the original result says no link could be made, the picture still stays saved and counted; use this same call to get its link.

A picture saved in an application #

The result gives the private file's address and normally two download commands, commands.curl and commands.powershell. Your AI coding agent runs the one for its shell. Each sends a read-only grant that works until expires_at, five minutes after the call. Treat a command as you would a password while it works.

If the grant cannot be created, the picture stays saved and counted. The result includes no download commands, and its detail says how else to read the file. The address alone downloads nothing, because the file is private. It is not a browser link; renew_image_link serves only pictures saved without an application.

After the grant expires, use your application's backend to read the saved file or issue another download grant. The backend checks access first (Store files). No MCP tool call creates a new download grant for an existing file.

A picture in the conversation #

With inline: true over MCP, a saved picture also appears in the result if it is at most 256 KiB. When you renew the link to an image saved in your account, renew_image_link also accepts inline: true. A larger picture stays saved. Open its account link in a browser, or use a download command. For an application picture, an AI assistant with no shell needs another tool that can run the command.

3. Keep or delete it #

A picture saved in your account is kept for seven days, until kept_until. Download it before then if you want to keep it. From that instant it cannot be read or given a new link; the daily cleanup deletes it afterwards. The account store keeps PNG, JPEG and WebP pictures. It uses none of an application's stored-data quota.

The account store has no call to delete one picture early. Deleting the account deletes its pictures. An account export includes their metadata, not the picture files, so download those separately before their keep ends.

With application, the file stays in the area images-<application id> until you delete it, as any stored file. It counts in that application's stored data. A repeat generation never replaces an earlier picture. Store files says how to read and delete application files.

4. Know what counts #

Every account can generate images. The first images of each UTC month are free; later images are charged per image from the account's balance, at the rate for their level and resolution. Read the current rates on the pricing page, or call read_rate_card. A call that delivers no image is charged nothing. Both storage choices use the same account count, which read_account returns in image_generation.

A delivered image increases used. A blocked or failed call normally gives its place back and uses no free image. If giving the place back fails, the call stays counted; the answer says so. Either way, it is charged nothing. If the provider blocks the request, generate_image returns blocked: true with the reason and saves no file.

A call that reaches the provider and delivers no image counts toward the account's limit on such calls in the last hour. At that limit, a call is refused image_generation_limited before it is sent; wait until resets_at.

There is no monthly image cap on an account. After its free images, a paused account's call is refused account_paused before the provider is called. A free image is still made while the account is paused and draws nothing from its balance.

Expected result #

After a delivered image, the answer shows used one higher, and the downloaded file opens as a picture of about the size you asked for. A blocked or failed call leaves the count unchanged unless giving its place back fails. The answer says when it stays counted, with nothing charged.

Refusals #

See the refusals reference for other platform errors.

Refusal Status Cause Remedy
invalid_request 400 A member is malformed, or environment was given without application. Correct the member named in detail. Leave both out for account storage, or name the application with its environment.
no_such_application 404 The call names an application the account does not hold. Use an identifier from list_applications, or omit application to save the picture in your account.
image_not_found 404 renew_image_link found no picture under this account and name. Use the name returned for a picture saved without an application, in the same account.
image_expired 410 The picture's kept_until has passed. Use a saved copy or ask the picture's owner for a replacement. The owner can call generate_image and use application to keep the replacement in application storage until deleted. Renewing a link cannot restore an expired picture.
image_link_spent 403 The download link is invalid, has expired, or has been replaced. Ask the picture's owner for a fresh link. Before kept_until, the owner can call renew_image_link with the picture's name or read it under an admitted account connection. After expiry, ask the owner for a replacement.
environment_not_created 409 The application doesn't have the environment the call named. Name production, or call create_environment first.
usage_over_quota 429 A call naming application found it over its stored-data limit, so nothing was saved or counted. Delete stored files and wait for the next daily check. This refusal does not apply to account storage.
image_generation_busy 429 The server handling this request has no image slot available. Nothing was counted. Repeat the request after a few seconds.
image_generation_limited 429 The account reached its limit on image calls that reached the provider in the last hour and delivered no image. This request was not sent, counted or charged. Wait until resets_at before trying again. The hourly count resets on its own. A changed prompt can help with a provider block. Quote the reference with submit_feedback if failures continue.
image_generation_failed 502 The call failed or passed 45 seconds; no image was saved and nothing was charged. Its place is given back unless that fails; the answer says when it stays counted. Repeat the request. Where it keeps happening, quote the reference with submit_feedback.
image_generation_unavailable 503 The platform has no key for image generation or cannot make images right now. Its key could not be read, it has no current model price, the provider refused before any picture, or the platform's monthly limit was reached. Read the detail. If the platform cannot make images, wait for its operator to restore service. If the provider refused the request, wait before trying again and check whether the detail says that call still counts.