> ## Documentation Index
> Fetch the complete documentation index at: https://www.tryleap.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Leap's API is at https://api.tryleap.ai. Send the key in the x-api-key header or as Authorization: Bearer; keys start with leap_.
> Take model IDs and input schemas from GET /v1/models/{creator}/{name}, or from https://api.tryleap.ai/v1/public/models without a key. Never guess an input field: unknown fields are a 400.
> Model inputs take uploaded file IDs (file_...), never URLs.
> To give a coding agent the whole API, install the Leap skill: curl -fsSL https://www.tryleap.ai/install.sh | sh
> To make media from ChatGPT, Claude or another MCP client without code, connect Leap's MCP server at https://app.tryleap.ai/api/mcp; see https://www.tryleap.ai/docs/mcp.
> The full OpenAPI 3.1 spec is at https://www.tryleap.ai/docs/openapi.json.

# Runs, files and costs

> How runs work over MCP: giving the agent photos, videos and sounds, how long it waits, retrying without paying twice, what a run costs, why one fails, and how long links last.

The MCP tools go through the same code as the [REST API](/docs/generations), so the same models, prices, limits and checks apply.

## Give the agent a file

Models that edit, animate or listen take files, by ID (`file_...`). The agent gets one with `upload_file`, from one of three places:

| Source | Use it for | Limits |
| - | - | - |
| A file you attach in ChatGPT | Photos, videos and sounds you add to the chat | ChatGPT hands Leap a link to the file, with the same limits as `url`. |
| `url`, a public link | A photo or clip that's already online | Public `https` only, up to 3 redirects. Leap has 45 seconds to download it. |
| `data`, base64 | A small image the agent can read, such as a file on your computer in Claude Code | Images only. Every character goes through the model, so keep it small. |

| Kind | Types | Size |
| - | - | - |
| Image | PNG, JPEG, WebP | Up to 4 MB |
| Video | MP4, MOV, WebM | Up to 100 MB from a link or attachment, half a second to 4 hours long |
| Sound | MP3, WAV, M4A | Up to 100 MB from a link or attachment, half a second to 4 hours long |

Leap reads the type from the file's bytes, not its name. Storing a video or a sound costs nothing, but needs some credit on your balance, and counts toward your workspace's 5 GB of uploads a day.

For a larger photo, resize it first, for example to 2048 pixels on its long side. For a video or sound over 100 MB, or one on a slow host, upload it yourself with the API's [direct uploads](/docs/files#upload-a-video-or-a-sound) (up to 1 GB of video) and give the agent its file ID. A file you uploaded through the API can go straight into a run by its ID.

Claude can't pass a file you attach in its chat to a tool. Give it a link instead.

### Use one run's output in the next

To animate, edit or continue from an image Leap made, the agent calls `keep_output` with the run's ID and the output's index. It gets back a file ID for that image, without downloading or uploading anything, and the same output always gives the same ID. It's free, and works for images only.

## Waiting for a result

`generate` waits up to 50 seconds for the run to finish, inside the 60 seconds most clients give a tool call. Most images and speech come back finished. A video usually comes back `running`, and then:

* In ChatGPT and Claude, the result view keeps checking and shows the clip when it's ready, without a new message from you.
* Any agent can call `get_generation` with `wait` set to up to 50 seconds, as many times as it takes. Each call returns as soon as the run ends.

`generate_batch` waits up to 50 seconds for the whole batch, and says how many are still running. Some presets show a still first: the run has a `preview_url` while its video renders, and can't be canceled until its `slow_at`. It's still charged only if it succeeds.

## Retrying without paying twice

`generate` and `generate_batch` need an `idempotency_key`, a new string for each new request, such as a UUID. The agent makes one up; you don't have to. If a call times out or the connection drops, the agent sends it again with the same key and gets the first run back, and nothing runs or is charged twice.

Idempotency keys belong to your workspace and never expire. A new request needs a new key: the same key with the same input returns the earlier run, even a failed one, and the same key with a different input is refused. That's why the Try again button asks for a new key.

## What a run costs

Runs cost the same over MCP as in the studio and through the API. The price is held from your balance when a run starts and charged only if it succeeds; when it fails, is refused or is canceled, the hold goes back. A batch is priced and held as a whole, so all of it starts or none of it does, and each run in it is charged only if it succeeds.

* `quote` returns a run's exact price without running anything, and `get_model` shows how the price is worked out. See [Pricing and credits](/docs/pricing#read-a-price).
* `plan` prices each option it suggests. An option with a `cost_usd` of 0 is priced by a length the words didn't give, such as a voice-over's text, so the agent quotes it before telling you a price.
* `get_account` shows the balance, what running jobs hold, and where to add credits: your workspace's Credits page, or Leap's price list in ChatGPT and Codex.

When the balance doesn't cover a run, nothing starts, and the tool refuses with where to go: `Not enough credit. Add credits to keep generating. Add credits at https://app.tryleap.ai/go/settings/credits`. In ChatGPT and Codex, it links to Leap's prices instead. New workspaces get a welcome credit, and a few [limits apply before the first top-up](/docs/pricing#before-your-first-top-up). Turn on auto top-up at [app.tryleap.ai/go/settings/credits](https://app.tryleap.ai/go/settings/credits) so a long session doesn't stop for an empty balance.

## When a run fails or is refused

A failed run comes back `failed`, with `error` saying why in words and `failure_cause` for the agent, and it isn't charged. The tool's answer also says what to do next:

| `failure_cause` | What happened | What the agent should do |
| - | - | - |
| `provider_refused` | The model's safety filter turned it down. | Change the prompt or the photo, or try another model. |
| `photo_blocked` | Leap's photo check refused a photo. | Use another photo. |
| `input_rejected` | The model couldn't use a file: too small or too large, a format it can't read, or no face. | Use another file. |
| `input_removed` | A file it needed was deleted. | Upload it again. |
| `outage` | The provider is failing for many people. | Try again in a few minutes. |
| `timeout`, `provider_error` | The run timed out or the provider failed. | Try again. |

Every retry needs a new `idempotency_key`. Some requests are refused before anything runs or is held:

* Every photo you upload is checked before a run that takes it. A photo that may show someone under 18, or that shows nudity, is refused, and nothing is held or charged. See [Photos of people](/docs/generations#photos-of-people).
* `plan` refuses an ask that names a real person who hasn't agreed to it, and suggests options with you or a new character instead.
* An input that doesn't match the model's schema is refused with the field first, such as `input.aspect_ratio: ...`, and what it accepts, so the agent can fix it and call again.

## Links expire after 24 hours

Every output link is signed and works for 24 hours, for anyone who has it. Download what you want to keep, or ask the agent to read the run again with `get_generation`, which signs fresh links. The files themselves stay in your workspace: each run's `studio_url` opens its page in the studio, with the result, its receipt and the downloads.

## Transcripts

Speech-to-text models, such as `openai/whisper-large-v3`, return the transcript to the agent as text, inside `<untrusted-transcript>` tags, with up to 20,000 characters inline. The `.txt` output has all of it. The tags tell the model that the words came from the recording, so it reads them as data and doesn't follow anything they say.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.