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

# media

> Image, video and 3D model generation, the model catalogue, stock photo search, video clipping and the audio routes — client.media.

Four generators — images, videos, sound effects and music — a catalogue, and — further down — `stock`, a free search over a licensed photo library, `clips`, the video-clipping job, `audio`, transcription, speech and speech-to-speech, and `skills`, a skill built from short videos. An image, sound effect or song renders in one call and comes back as [files](https://vetta.sh/docs/sdk/files.md); a video is a **media job** you read back until it finishes. The catalogue belongs to the provider and changes without a release of ours, so it is a **search**, not a constant.

## images.generate

```ts theme={"system"}
client.media.images.generate(body: {
  prompt: string;
  model?: string;
  image_urls?: string[];   // fil_ ids or public URLs
  character?: string;      // chr_ id or name of a ready character
  n?: number;
  aspect_ratio?: string;   // W:H, e.g. "16:9"; at most 8:1 either way
  seed?: number;
}): Promise<ImageGeneration>
```

[`POST /v1/media/images`](https://vetta.sh/docs/api/images), synchronous. Every output is a file:

```ts theme={"system"}
{ object: "image_generation", model: string, files: FileObject[], cost_micro_usd: number }
```

`model` left out picks the platform's default image model — with `image_urls`, the first that takes an image input; with `character`, one that pins it. `image_urls` edits or restyles images — stored `fil_` ids or public URLs — instead of rendering from nothing. `character` renders as a trained [character](https://vetta.sh/docs/sdk/characters.md) and is not combined with `image_urls`. `aspect_ratio` that is not `W:H`, or wider than `8:1` / `1:8`, is refused with `validation_failed` on `aspect_ratio` before anything renders or is billed. `n` is 1–4, default 1; when some fail, the ones that rendered are still returned and billed. The client sends the required [`Idempotency-Key`](https://vetta.sh/docs/api/overview#idempotency) for you.

```ts theme={"system"}
const out = await client.media.images.generate({ prompt: "a paper kite over a grey harbour", n: 2 });
const png = await client.files.downloadBytes(out.files[0].id);
```

## videos.generate

```ts theme={"system"}
client.media.videos.generate(body: {
  model?: string;
  prompt: string;
  image_urls?: string[];   // one first frame: a fil_ id or a public URL
  seconds?: number;
  aspect_ratio?: string;
  seed?: number;
}): Promise<MediaJob>
```

[`POST /v1/media/videos`](https://vetta.sh/docs/api/video) — answers at once with the job in `queued`. `model` is optional: omitted, it is the first of the platform's video defaults — the standard video model, `black-forest-labs/flux-3-max`, `minimax/hailuo-3`, `bytedance/seedance-2.5`, then `alibaba/wan-3.0/text-to-video` — that this deploy's catalogue publishes. Not every deploy publishes the first, so check [`listModels({ kind: "video" })`](#listmodels) before pinning one; the job's `model` names the one that ran. `image_urls` is one first frame — a stored still's `fil_` id (one rendered as a character, say) or a public URL. `seconds` is 1–60.

## meshes.create

```ts theme={"system"}
client.media.meshes.create(body: {
  model?: string;
  prompt?: string;         // or image_urls, not both
  image_urls?: string[];   // 1–4 photos of one object: fil_ ids or public https URLs
  texture?: boolean;       // default true
  rig?: boolean;           // default false; a prompt only
  seed?: number;
}): Promise<MediaJob>
```

[`POST /v1/media/meshes`](https://vetta.sh/docs/api/meshes) — a 3D model, answered at once with the job (`kind: "mesh"`) in `queued`. Read it back with [`get`](#get); a completed job's `result.files[0]` is a GLB (`model/gltf-binary`). Priced for the options used, at completion; a failed job is free.

```ts theme={"system"}
let job = await client.media.meshes.create({ prompt: "a weathered bronze lantern" });
while (job.status === "queued" || job.status === "processing") {
  await new Promise((r) => setTimeout(r, 10_000));
  job = await client.media.get(job.id);
}
const glb = await client.files.downloadBytes(job.result!.files[0].file_id); // binary-safe: the GLB as bytes
```

## soundEffects.generate

```ts theme={"system"}
client.media.soundEffects.generate(body: {
  prompt: string;              // 1–500 characters
  duration_seconds?: number;   // 0.5–30; omitted, fit to the prompt
  loop?: boolean;              // default false
}): Promise<SoundGeneration>
```

[`POST /v1/media/sound-effects`](https://vetta.sh/docs/api/audio#sound-effects), synchronous — a text prompt to a short generated clip, saved as a [file](https://vetta.sh/docs/sdk/files.md):

```ts theme={"system"}
{ object: "sound_generation", file: FileObject, duration_seconds: number | null, cost_micro_usd: number }
```

Turns a description into an effect (ambience, foley, a sting), so it takes no `voice` and no `model`. `loop` makes the clip loop seamlessly for backgrounds. The client sends the required [`Idempotency-Key`](https://vetta.sh/docs/api/overview#idempotency) for you.

```ts theme={"system"}
const sound = await client.media.soundEffects.generate({
  prompt: "a heavy wooden door slamming shut, echoing",
  duration_seconds: 3,
});
await writeFile("door.mp3", await client.files.downloadBytes(sound.file.id));
```

## music.generate

```ts theme={"system"}
client.media.music.generate(body: {
  prompt: string;              // 1–2 000 characters
  length_seconds?: number;     // 3–300; omitted, 30
  instrumental?: boolean;      // default false
}): Promise<MusicGeneration>
```

[`POST /v1/media/music`](https://vetta.sh/docs/api/audio#music), synchronous — a text prompt to an original song, saved as a [file](https://vetta.sh/docs/sdk/files.md):

```ts theme={"system"}
{ object: "music_generation", file: FileObject, duration_seconds: number | null, cost_micro_usd: number }
```

Turns a description into a song (any genre, mood or instrumentation), so it takes no `voice` and no `model`. `instrumental` forces a track with no vocals. The client sends the required [`Idempotency-Key`](https://vetta.sh/docs/api/overview#idempotency) for you.

```ts theme={"system"}
const song = await client.media.music.generate({
  prompt: "an upbeat synthwave track with driving bass and bright arpeggios",
  length_seconds: 30,
});
await writeFile("track.mp3", await client.files.downloadBytes(song.file.id));
```

## get

```ts theme={"system"}
client.media.get(id: string): Promise<MediaJob>
```

`GET /v1/media/{id}`. Any `med_` of yours, a clipping job's included. Poll until `status` is `completed` or `failed`; a completed video job's `result.files[].file_id` is the rendered video, a completed clipping job's `result.clips` are its clips (see [`clips.get`](#clipsget)).

```ts theme={"system"}
let job = await client.media.videos.generate({ model: "heygen/heygen-video-1", prompt: "waves at dusk", seconds: 4 });
while (job.status === "queued" || job.status === "processing") {
  await new Promise((r) => setTimeout(r, 5_000));
  job = await client.media.get(job.id);
}
if (job.status === "failed") throw new Error(job.error?.message);
```

## list

```ts theme={"system"}
client.media.list(query?: {
  kind?: "video" | "clip" | "transcription" | "mesh";
  status?: "queued" | "processing" | "completed" | "failed";
  session_id?: string;
  limit?: number;
  after?: string;
}): Promise<Page<MediaJob>>
```

`GET /v1/media`, newest first. `session_id` narrows to what one session's agent submitted; API-submitted jobs carry `session_id: null`. `kind: "clip"` answers the same jobs as [`clips.list`](#clipslist) — clipping jobs submitted through the API — so with `session_id` it answers none.

## listModels

```ts theme={"system"}
client.media.listModels(query: {
  kind: "image" | "video" | "mesh" | "stt" | "tts" | "s2s";
  search?: string;
  limit?: number;
  after?: string;
}): Promise<Page<MediaModel>>
```

`GET /v1/media/models`. `kind` is required: each is its own capability with its own catalogue. `stt`, `tts` and `s2s` are the [audio](https://vetta.sh/docs/api/audio.md#the-catalogues) models — the managed alias for the direction first, then pinned models.

Each entry:

**id** `string`

The model id you pass as `model` above, or to [`generate_image` / `generate_video`](https://vetta.sh/docs/capabilities/tools#generation-tools), or pin on an agent as `tools.configs.<tool>.config.models`.

**name** `string`

The model's display name.

**kind** `"image" | "video" | "stt" | "tts" | "s2s"`

Which capability it serves.

**description** `string`

What the model is good at.

```ts theme={"system"}
const video = await client.media.listModels({ kind: "video", search: "reel" });
await client.agents.update(agentId, {
  tools: {
    default_config: { permission: "allow" },
    configs: {
      generate_video: { enabled: true, permission: "allow", config: { models: [video.data[0].id] } },
    },
  },
});
```

No price is on the object. A generation is billed what it actually cost, once it has finished — see [Pricing](https://vetta.sh/docs/platform/pricing.md#media-generation--per-finished-job-media-component).

## stock.search

```ts theme={"system"}
client.media.stock.search(query: {
  query: string;
  count?: number;                                   // 1–30, default 10
  orientation?: "landscape" | "portrait" | "square";
  color?: string;                                   // a name or a hex value
  size?: "small" | "medium" | "large";            // which size `url` points at
}): Promise<{ data: StockPhoto[] }>
```

[`GET /v1/media/stock`](https://vetta.sh/docs/api/images). Not a cursor page: the library pages by number, and `count` is the whole page.

Each `StockPhoto`:

**id** `string`

The library's own id. Opaque, unprefixed, not a Naive Managed Agents resource.

**width** `number`

Pixel width of the original.

**height** `number`

Pixel height of the original.

**url** `string`

A direct image URL at the requested `size`.

**preview\_url** `string`

A small thumbnail.

**alt** `string | null`

A one-line description of the photo.

**photographer** `string | null`

Who took it — show this credit wherever the photo is used.

**attribution\_url** `string | null`

The page to link the credit to.

**dominant\_color** `string | null`

The average colour as a hex value.

**file\_name** `string`

A neutral name to save the photo under, `stock-<id>.<ext>`. Absent only from an API older than this field.

```ts theme={"system"}
const { data } = await client.media.stock.search({ query: "office workspace", count: 3, orientation: "landscape" });
const hero = data[0];
// <img src={hero.url} alt={hero.alt ?? ""} />  Photo by <a href={hero.attribution_url}>{hero.photographer}</a>
```

A result is a URL, not a file; to hold the bytes as a `fil_`, import `url` through [`client.files`](https://vetta.sh/docs/sdk/files) under `file_name`, with the credit in `description` so it travels with the file:

```ts theme={"system"}
await client.files.import({ url: hero.url, name: hero.file_name, description: `Photo by ${hero.photographer} (${hero.attribution_url})` });
```

The search is free and is booked as a `search` line at 0 credits. A deploy with no stock photo library configured rejects with `feature_not_configured`.

## edits.create

```ts theme={"system"}
client.media.edits.create(body: EditRequest): Promise<EditJob>
```

`POST /v1/media/edits`. Submits a Mira edit and returns it `queued`. `video` is a `fil_` id, a public `http(s)` URL of a video file, or a public post or video link from Instagram, YouTube, X, Vimeo or Facebook, which the platform downloads (one that cannot be fetched fails `bad_source` and costs nothing). A TikTok link is `validation_failed` before anything is held: TikTok blocks automated downloads, so upload the video as a file, `prompt` is what to change, and `references` is up to four pictures. A `fil_` `video` that is not a video, or a `fil_` reference that is not an image, is `validation_failed` before anything is held. `mode` picks the [kind of edit](https://vetta.sh/docs/capabilities/tools.md#two-kinds-of-edit-edit-and-motion_transfer): `edit` (the default; left out means the same) is the regular editor, and `scene`, `outfit_or_object`, `person_swap` or `recast` narrow it; `motion_transfer` copies the clip's exact motion onto the characters in 1–3 `fil_` image `references` and keeps the place. An `Idempotency-Key` is sent for you. Read the job with `client.media.edits.get(id)` (`GET /v1/media/edits/{id}`) until `status` is `completed`; `result.file_id` is the edit, and `rendered_as` says how it was made (`motion_transfer` or `edit`). The job answers `mode: null` for the default `edit`. `client.media.edits.cancel(id)` (`POST /v1/media/edits/{id}/cancel`) stops it at 0 credits while `cancellable` is `true`, that is before its render starts; after that it is `409 state_conflict`, and the edit runs on and is charged only if it comes out right.

```ts theme={"system"}
const job = await client.media.edits.create({
  video: "fil_...",
  prompt: "the same people, on a rooftop at dusk",
  mode: "scene",
});
```

A motion transfer works best on 5–15 s clips of fights, dances and stunts. With 2–3 photos, start the prompt with one `<CharacterN>` tag per photo, in order, naming who in the clip it replaces, then a new line. `person_swap`, `recast` and `motion_transfer` without a reference, or with a URL reference, reject with `validation_failed` on `references`. A clip under 5 s, more than 3 photos, or a motion transfer that fails is made by the regular editor instead, so the job still completes, with `rendered_as: "edit"`. It costs 50 credits a second (750 credits for 15 s), or the regular editor's price when it falls back — see [pricing](https://vetta.sh/docs/platform/pricing.md#priced-tools).

```ts theme={"system"}
let edit = await client.media.edits.create({
  video: "fil_...",
  references: ["fil_dog...", "fil_husky..."],
  mode: "motion_transfer",
  prompt:
    "<Character1>the boxer in the red and white striped shorts<Character2>the boxer in the blue shorts\n" +
    "Turn them into a golden retriever and a husky.",
});
while (edit.status === "queued" || edit.status === "processing") {
  await new Promise((r) => setTimeout(r, 15_000));
  edit = await client.media.edits.get(edit.id);
}
// edit.rendered_as === "motion_transfer", edit.cost_micro_usd === 150000 for a 15 s clip
```

## clips.create

```ts theme={"system"}
client.media.clips.create(body: ClipCreate): Promise<MediaJob>
```

`POST /v1/media/clips`. Submits a clipping job and returns it `queued`; the whole video is read and its best moments arrive as [files](https://vetta.sh/docs/sdk/files.md) when it completes — see [how clips are picked and framed](https://vetta.sh/docs/api/clips.md#how-clips-are-picked-and-framed). `ClipCreate` is the [request body](https://vetta.sh/docs/api/clips.md#submit-a-clipping-job): `video_url` (public `http(s)` only), and optional `aspect_ratio` (`9:16` framed per shot, the default, or `16:9` kept as shot), `remove_silence`, `caption_preset` (`none | clean | bold | karaoke`; **defaults to `none`**, no captions), `language`, `min_seconds`, `max_seconds`, `title`. An `Idempotency-Key` is sent for you, so a retry replays rather than re-queues.

```ts theme={"system"}
const job = await client.media.clips.create({
  video_url: "https://cdn.example.com/keynote.mp4",
  caption_preset: "bold",
  language: "en",
  max_seconds: 45,
});
```

## clips.get

```ts theme={"system"}
client.media.clips.get(id: string): Promise<MediaJob>
```

`GET /v1/media/clips/{id}`. The job as it stands; once `status` is `completed`, `result.clips` holds each clip's `file_id`, `title`, `start_seconds` / `end_seconds` (the source window it was cut from, lead-in included), `duration_seconds` (the finished length, shorter with `remove_silence`), `virality` scores and ready-to-post copy (`hook`, `hook_text`, `tiktok_caption`, `instagram_caption`, `youtube_title`, each `string | null`), and `cost_micro_usd` is what it cost. A `failed` job's `error.code` says whether to retry: the `source_*` codes fail again on the same link ([codes](https://vetta.sh/docs/api/clips.md#when-a-job-fails)).

```ts theme={"system"}
const job = await client.media.clips.get(id);
console.log(job.status); // queued | processing | completed | failed
```

To poll until it finishes, use [`clips.wait`](#clipswait); to be told instead, subscribe a [webhook](https://vetta.sh/docs/sdk/webhooks.md) to `media.job.completed` / `media.job.failed`.

## clips.wait

```ts theme={"system"}
client.media.clips.wait(id: string, options?: { intervalMs?: number; timeoutMs?: number }): Promise<MediaJob>
```

Reads `GET /v1/media/clips/{id}` every `intervalMs` (default 5 s) until the job is `completed` or `failed`, and answers it. Past `timeoutMs` (default 65 minutes, longer than the 60 minutes a job may queue and run) it answers the job as it stands, still `queued` or `processing`, rather than throwing — check `status`.

```ts theme={"system"}
const queued = await client.media.clips.create({ video_url: "https://cdn.example.com/keynote.mp4", caption_preset: "bold" });
const job = await client.media.clips.wait(queued.id);
if (job.status === "failed") throw new Error(`${job.error?.code}: ${job.error?.message}`);
if (job.result && "clips" in job.result) {
  for (const clip of job.result.clips) console.log(clip.title, clip.tiktok_caption, clip.file_id);
}
```

## clips.list

```ts theme={"system"}
client.media.clips.list(query?: {
  status?: "queued" | "processing" | "completed" | "failed";
  limit?: number;
  after?: string;
}): Promise<Page<MediaJob>>
```

`GET /v1/media/clips`. Newest first. Only jobs submitted through the API are listed; what an agent's `clip_video` tool cuts inside a session lands in that session as files.

## audio.transcribe

```ts theme={"system"}
client.media.audio.transcribe(body: {
  file_id?: string;      // exactly one of file_id / url
  url?: string;
  model?: string;
  language?: string;     // ISO 639-1 hint
  timestamps?: boolean;  // default true
}): Promise<MediaJob>
```

`POST /v1/media/audio/transcriptions`. Answers a [`media_job`](https://vetta.sh/docs/api/audio#the-transcription-job) of `kind: "transcription"` — usually already `completed`, with `result.text` filled in; a long recording the provider queues comes back `processing`, to be re-read with `audio.get`. `result.segments`, `language` and `duration_seconds` are filled only by a model that reports them; the default model returns the text alone (empty `segments`, `null` language and duration).

```ts theme={"system"}
const job = await client.media.audio.transcribe({ url: "https://cdn.example.com/call.mp3", language: "en" });
if (job.status === "completed" && job.result && "text" in job.result) console.log(job.result.text);
```

## audio.get

```ts theme={"system"}
client.media.audio.get(id: string): Promise<MediaJob>
```

`GET /v1/media/audio/transcriptions/{id}` — the same job, re-read.

## audio.speak

```ts theme={"system"}
client.media.audio.speak(body: {
  text: string;                    // 1–4 096 characters
  model?: string;
  voice?: string;
  format?: "mp3" | "wav" | "ogg";  // default mp3; a preference, see below
  speed?: number;                  // 0.5–2
}): Promise<SpeechGeneration>
```

`POST /v1/media/audio/speech`. `model` omitted is [the default speech model](https://vetta.sh/docs/api/audio.md#speak) — the first row of `listModels({ kind: "tts" })`, `openai/gpt-audio-mini` in the voice `alloy`. The catalogue's models answer **WAV** whatever `format` asks; `speech.file.content_type` says what you got. Synchronous; the reply's `file` is the stored [file](https://vetta.sh/docs/sdk/files.md), so the bytes are one `client.files.downloadBytes(speech.file.id)` away.

```ts theme={"system"}
const speech = await client.media.audio.speak({ text: "Your order has shipped." });
await writeFile("shipped.wav", await client.files.downloadBytes(speech.file.id));
```

## audio.converse

```ts theme={"system"}
client.media.audio.converse(body: {
  file_id: string;                 // a stored recording of one spoken turn
  model?: string;
  voice?: string;
  format?: "mp3" | "wav" | "ogg";  // default mp3
}): Promise<SpeechGeneration>
```

`POST /v1/media/audio/conversations`. Synchronous, and the same `SpeechGeneration` as `speak`: the spoken reply to the turn in `file_id`, stored as a [file](https://vetta.sh/docs/sdk/files.md). The input is a stored file — `client.files.upload` or `client.files.import` a recording first.

```ts theme={"system"}
const turn = await client.files.import({ url: "https://cdn.example.com/question.wav" });
const reply = await client.media.audio.converse({ file_id: turn.id, format: "wav" });
await writeFile("reply.wav", await client.files.downloadBytes(reply.file.id));
```

## skills

```ts theme={"system"}
client.media.skills.create(body: { urls: string[]; name?: string; description?: string }): Promise<MediaSkillBuild>
client.media.skills.revise(id: string, body: { feedback: string }): Promise<MediaSkillBuild>
client.media.skills.get(id: string): Promise<MediaSkillBuild>
client.media.skills.list(query?: { state?: "setup" | "building" | "ready"; limit?: number; after?: string }): Promise<Page<MediaSkillBuild>>
```

[Media skill builds](https://vetta.sh/docs/api/media-skills.md): `create` (`POST /v1/media/skills`) studies 1–3 public short-video links (`urls`) and writes an organization [skill](https://vetta.sh/docs/sdk/skills.md) that captures their format; `revise` sends the same route a `build_id` and your `feedback` and runs the next round. Both send the required `Idempotency-Key` for you, need a live key and a balance above zero, and answer the build in `building`. `get` (`GET /v1/media/skills/{id}`) moves the build forward as it reads it, so poll it until `state` is `ready`; `skill` is then `{ id, slug, version }`, the saved skill. `list` (`GET /v1/media/skills`) is newest first and does not move builds. A revision while a round runs is `version_conflict`.

```ts theme={"system"}
let build = await client.media.skills.create({ urls: ["https://www.instagram.com/reel/DeimezNsQRN/"], name: "Slow feast" });
while (build.state !== "ready") {
  await new Promise((r) => setTimeout(r, 30_000));
  build = await client.media.skills.get(build.id);
}
console.log(build.skill?.slug, build.skill?.version);
```


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