# Pika H3 Flex

Generate a video with native audio from ordered image, video and audio references. Choose any whole-second duration from 5 to 15, 480p or 768p resolution, and one of 11 aspect ratios. Prompt rewriting is enabled by default; set rewrite=false to use the original prompt. 1080p/2k/4k generates at 768p and upscales once with Pika Upsampler V1, preserving audio and frame rate. Combined pricing is per actual output second; the quote reserves the native frame-count duration bound. Reference video seconds are billed at the same rate in addition to output seconds; image and audio references add no duration charge.

- Model ID: `pika/pika-h3-flex/reference-to-video`
- Provider: Pika
- Modality: image → video
- Type: Reference to Video
- Status: stable
- Delivery: async
- Max resolution: 4k
- Output format: mp4
- Aspect ratios: auto, 21:9, 16:9, 3:2, 4:3, 5:4, 1:1, 4:5, 3:4, 2:3, 9:16, 9:21

## Authentication

Send your API key in the `X-API-Key` header.

The same key reads the org balance at `GET https://api.dev.pika.art/billing/balance`, which is free to call and confirms the request can be paid for before you submit it.

## Endpoint

```
POST https://api.dev.pika.art/v1/media/pika/pika-h3-flex/reference-to-video
```

## Reference uploads

To use a local file (image, audio, or video) as a model input, first request a presigned upload URL: `POST /v1/media/uploads` with the `X-API-Key` header and a JSON body `{ "content_type": "image/png", "size_bytes": 12345 }`, where `size_bytes` is the file's exact byte length. The response returns `upload_url` (temporary, valid for 5 minutes), `headers`, and `url` (the permanent Pika URL). PUT the file bytes to `upload_url` sending the returned `headers` verbatim — both `Content-Type` and `Content-Length` are signed, and storage returns a bare 403 if either is missing or differs. Then pass `url` into fields such as `image`, `image_url`, `end_image_url`, `image_urls`, `first_frame_image`, or `mask_image_url`.

## Generate

`POST /v1/media/pika/pika-h3-flex/reference-to-video`

```bash
curl -X POST https://api.dev.pika.art/v1/media/pika/pika-h3-flex/reference-to-video \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "prompt": "A 15-second multi-shot product commercial for the chunky clear lip gloss tube with crimson jelly gloss from reference image 1 (exact same faceted clear cap, ridged neck and deep crimson gloss, no label), served like a luxury dessert.\nSHOT 1 (0-3s): Overhead crane move descending onto a duck-egg blue table as a polished silver cloche lifts off a white plate, revealing the pink panna cotta with the gloss tube resting on it. The cloche's mirror surface reflects only the pale blue room and soft light — no people, no camera, no crew reflected anywhere.\nSHOT 2 (3-6s): Extreme macro side angle: the panna cotta wobbles gently, light rolling across its glossy surface and through the crimson gloss inside the clear tube.\nSHOT 3 (6-10s): Hard cut to a clean, empty, seamless pale duck-egg blue background — no plate, no dessert, nothing else in frame. The gloss tube floats upright in soft light and opens by itself: the faceted clear cap slowly unscrews and lifts away, drawing the applicator wand up out of the tube, a thick glossy string of crimson gloss stretching between the doe-foot tip and the tube neck and catching the light. Slow-motion macro, camera arcing smoothly around it. No hands, no people.\nSHOT 4 (10-12s): Same clean duck-egg blue background: macro on the glossy crimson doe-foot applicator tip, a single drop of gloss gathering and glistening, light refracting through the faceted cap.\nSHOT 5 (12-15s): Hard cut back to the table: low dolly gliding across and settling on the final hero frame exactly like reference image 1.\nSOUND: refined restaurant ambience, the metallic lift of the cloche, a soft wobble, the satisfying twist-and-pull sound of the cap opening, a glossy stretch, then a chic playful French-pop instrumental. LOOK: high-end cinematic beauty/tech commercial, editorial and refined, Jacquemus / Loewe campaign energy. Soft pale true-colour grounds against deep saturated hero colours, large soft diffused light, shadows soft but present, low-to-moderate contrast, creamy highlights, subtle 35mm film grain, shallow depth of field, anamorphic feel. CAMERA is always moving with bold confident motion — dollies, macro orbits, crane moves, motion blur on fast moves — never static. Product always tack-sharp and recognisable. Hard cuts between shots, each shot a different angle and scale, one clear story from start to end. Correct real-world physics. NO text, NO titles, NO captions, NO logos, NO subtitles anywhere. Audio: no voiceover, no dialogue, only a polished commercial soundtrack plus crisp tactile sound design.",
  "duration": 15,
  "resolution": "768p",
  "seed": 0,
  "rewrite": true,
  "output_mode": "video",
  "channel_mode": "stereo",
  "references": [
    {
      "type": "image",
      "url": "https://example.com/input.png"
    },
    {
      "type": "video",
      "url": "https://example.com/reference.mp4"
    },
    {
      "type": "audio",
      "url": "https://example.com/input.mp3"
    }
  ]
}'
```

### Request body

| Param | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| `prompt` | string | yes | - | Prompt |
| `duration` | integer (5 – 15) | no | 5 | Video duration in whole seconds, from 5 to 15. |
| `aspect_ratio` | enum | no | - | Output aspect ratio. Auto selects from the original prompt and reference video, even when rewrite is false; with a keyframe it follows the first supplied keyframe. A fixed ratio always wins. When omitted, rewriting enables Auto; without rewriting, the first supplied keyframe sets the ratio, or 16:9 without a keyframe. Keyframes are resized and center-cropped to fit. |
| `resolution` | enum | no | 768p | 480p/768p are native. 1080p/2k/4k generates at 768p, then upscales once with the V1 model, preserving audio and frame rate. |
| `seed` | integer (0 – 9223372036854776000) | no | 0 | Seed |
| `rewrite` | boolean | no | true | Improve the prompt before generation; disable to use the original prompt. |
| `output_mode` | enum | no | video | audio-stems (Flex in production, every H3 family in staging) returns the original video with audio plus Dialogue, Score, SFX, Foley and Ambience WAV files. Uses standard retention and adds the catalog's separation fee. Flex bills the sum of all decoded output-stem durations, without a channel multiplier. The default returns only the video. |
| `channel_mode` | enum | no | stereo | Audio stems only: stereo preserves both channels; mono downmixes before separation. The video's audio is unchanged. |
| `references` | object[] (1 – 12) | yes | - | Ordered reference media: up to 9 images, 3 videos and 3 audio files, 12 total. At least one image or video is required. Each file is limited to 24 MiB, with a combined 64 MiB base64 limit (approximately 48 MiB raw). Images must be PNG, JPEG or WebP, up to 40 million source pixels; images above 16 million pixels are proportionally resized. Videos are proportionally resized to the model's pixel budget; source limits are 16 million pixels per frame, 4 billion total pixels and 2000 frames. clips must be 2–15 seconds, at most 15 seconds combined per video/audio type. Reference rewriting uses image previews and sparse video frames, not audio transcription. One of 3 item shapes, see below. |

#### references[] item — type = image

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `references[].type` | string | yes | Always `image`. |
| `references[].url` | string | yes | Url |

#### references[] item — type = video

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `references[].type` | string | yes | Always `video`. |
| `references[].url` | string | yes | Url |

#### references[] item — type = audio

| Field | Type | Required | Description |
| --- | --- | --- | --- |
| `references[].type` | string | yes | Always `audio`. |
| `references[].url` | string | yes | Url |

#### Example body

```json
{
  "prompt": "A 15-second multi-shot product commercial for the chunky clear lip gloss tube with crimson jelly gloss from reference image 1 (exact same faceted clear cap, ridged neck and deep crimson gloss, no label), served like a luxury dessert.\nSHOT 1 (0-3s): Overhead crane move descending onto a duck-egg blue table as a polished silver cloche lifts off a white plate, revealing the pink panna cotta with the gloss tube resting on it. The cloche's mirror surface reflects only the pale blue room and soft light — no people, no camera, no crew reflected anywhere.\nSHOT 2 (3-6s): Extreme macro side angle: the panna cotta wobbles gently, light rolling across its glossy surface and through the crimson gloss inside the clear tube.\nSHOT 3 (6-10s): Hard cut to a clean, empty, seamless pale duck-egg blue background — no plate, no dessert, nothing else in frame. The gloss tube floats upright in soft light and opens by itself: the faceted clear cap slowly unscrews and lifts away, drawing the applicator wand up out of the tube, a thick glossy string of crimson gloss stretching between the doe-foot tip and the tube neck and catching the light. Slow-motion macro, camera arcing smoothly around it. No hands, no people.\nSHOT 4 (10-12s): Same clean duck-egg blue background: macro on the glossy crimson doe-foot applicator tip, a single drop of gloss gathering and glistening, light refracting through the faceted cap.\nSHOT 5 (12-15s): Hard cut back to the table: low dolly gliding across and settling on the final hero frame exactly like reference image 1.\nSOUND: refined restaurant ambience, the metallic lift of the cloche, a soft wobble, the satisfying twist-and-pull sound of the cap opening, a glossy stretch, then a chic playful French-pop instrumental. LOOK: high-end cinematic beauty/tech commercial, editorial and refined, Jacquemus / Loewe campaign energy. Soft pale true-colour grounds against deep saturated hero colours, large soft diffused light, shadows soft but present, low-to-moderate contrast, creamy highlights, subtle 35mm film grain, shallow depth of field, anamorphic feel. CAMERA is always moving with bold confident motion — dollies, macro orbits, crane moves, motion blur on fast moves — never static. Product always tack-sharp and recognisable. Hard cuts between shots, each shot a different angle and scale, one clear story from start to end. Correct real-world physics. NO text, NO titles, NO captions, NO logos, NO subtitles anywhere. Audio: no voiceover, no dialogue, only a polished commercial soundtrack plus crisp tactile sound design.",
  "duration": 15,
  "resolution": "768p",
  "seed": 0,
  "rewrite": true,
  "output_mode": "video",
  "channel_mode": "stereo",
  "references": [
    {
      "type": "image",
      "url": "https://example.com/input.png"
    },
    {
      "type": "video",
      "url": "https://example.com/reference.mp4"
    },
    {
      "type": "audio",
      "url": "https://example.com/input.mp3"
    }
  ]
}
```

### Accepted values

| Param | Values | Default |
| --- | --- | --- |
| `aspect_ratio` | `auto`, `21:9`, `16:9`, `3:2`, `4:3`, `5:4`, `1:1`, `4:5`, `3:4`, `2:3`, `9:16`, `9:21` | — |
| `resolution` | `480p`, `768p`, `1080p`, `2k`, `4k` | `768p` |
| `output_mode` | `video`, `audio-stems` | `video` |
| `channel_mode` | `stereo`, `mono` | `stereo` |
| `references[].type` | `image`, `video`, `audio` | — |

### Referencing inputs in the prompt

Reference inputs are attached as flat URL arrays and cited positionally inside the `prompt` text:

- `image_urls[]` (up to 9) → cite as `@Image1`, `@Image2`, …
- `video_urls[]` (up to 3) → cite as `@Video1`, `@Video2`, …
- `audio_urls[]` (up to 3) → cite as `@Audio1`, `@Audio2`, …

At most 12 files combined across the three arrays. Follow the model request schema for supported reference combinations.

Returns a job object, not the final output — normally with status `queued`. If you're at your concurrency limit, the job stays `queued` until a slot frees up, then starts on its own. Store the `id` and poll until a terminal state. A rejected submit (insufficient balance, rate limit, unpriceable input) still returns the job object, with status `failed` and `error` set. An `Idempotency-Key` replay returns the existing job in its current state — including `failed`, so retry a failure with a fresh key, never the same one.

### Response

**200 OK · queued**

```json
{
  "id": "media_8f3a2c91-5b7d-4e0a-9c26-31d4f2a8e6b0",
  "status": "queued"
}
```

## Poll status

`GET /v1/media/jobs/{request_id}`

```bash
curl https://api.dev.pika.art/v1/media/jobs/{request_id} \
  -H "X-API-Key: YOUR_API_KEY"
```

Poll the job by id until it reaches a terminal state: `completed` or `failed`.

### The job object

- `id` (string): Unique identifier for the job.
- `status` (enum): One of `queued`, `running`, `completed`, `failed`.
- `output` (object): Present once the job completes.
  - `media_type` (enum): `video`.
  - `output.video.url` (string): URL of the generated video.
- `error` (object): Present if the job failed. `error.code` is the stable machine-readable value to branch on — one of `invalid_input`, `content_moderation`, `provider_error`, `provider_timeout`, `provider_unavailable`, `rate_limited`, `insufficient_balance`, `membership_required`, `cycle_limit_exceeded`, `admission_suspended`, `timed_out`, `internal`. Unrecognized values normalize to `provider_error`. `error.message` is diagnostic text and varies.
- `usage` (object): Units the provider reported for the job, such as `video_output_tokens`, `image_output_tokens`, `input_tokens`, or `output_seconds`. Present once the job is terminal, carries only the units the job reports, and is `null` when nothing was reported. It may not reproduce the charge, because some pricing components are fixed by the request; the charge is authoritative.
- `billing` (object): What the job charged. Present once the job is terminal, `null` on the submit response and on webhooks. `billing.state` is one of `settled`, `pending`, `unavailable`. `settled` carries `charge_micro_usd`, the amount collected in micro-USD (the balance's unit), `0` included. `pending` means the charge is still settling: retry at 1s, 2s, then 5s. `unavailable` means the billing read failed on Pika's side: retry no sooner than 30s. Record spend only when `state` is `settled`, keyed by job id; a `billing` of `null` is not a charge.

### Response

**200 OK · running**

```json
{
  "id": "media_8f3a2c91-5b7d-4e0a-9c26-31d4f2a8e6b0",
  "status": "running"
}
```

**200 OK · completed**

```json
{
  "id": "media_8f3a2c91-5b7d-4e0a-9c26-31d4f2a8e6b0",
  "status": "completed",
  "output": {
    "media_type": "video",
    "video": {
      "url": "https://api.dev.pika.art/v1/files/video_8f3a2c91.mp4",
      "content_type": "video/mp4"
    }
  },
  "usage": {
    "video_output_tokens": 50638
  },
  "billing": {
    "state": "settled",
    "charge_micro_usd": 372189
  }
}
```

**200 OK · failed**

```json
{
  "id": "media_8f3a2c91-5b7d-4e0a-9c26-31d4f2a8e6b0",
  "status": "failed",
  "error": {
    "code": "provider_error",
    "message": "upstream generation failed"
  },
  "billing": {
    "state": "settled",
    "charge_micro_usd": 0
  }
}
```

A completed job carries its download URL in `output`. `GET /v1/media/jobs/{request_id}/content` returns that same URL as `{ "url": "..." }` for clients that only kept the id; it answers `409` until the job completes.

## Errors

Errors use conventional HTTP status codes and always return JSON, in one of two shapes. Request-level errors (auth, unknown path, schema validation, idempotency conflict) are `{"message": "..."}`. Submit rejections that occur after the job row is created (insufficient balance, rate limit, unpriceable input, dispatch unavailable) return the full failed job envelope — branch on `error.code`, and retry with a fresh `Idempotency-Key`, since a failed job replays on its key.

- 401 Unauthorized — The API key is missing or invalid. Body: `{"message":"Invalid API key"}`
- 403 Forbidden — An inactive key is rejected with a `{"message"}` body. A submit that the org balance or postpaid cycle limit cannot cover is rejected after the job row exists and returns the failed job envelope. `GET /billing/balance` separates the two: a `200` means the key is active, so the rejection was the balance or the cycle limit. Body: `{"id":"media_8f3a2c91-5b7d-4e0a-9c26-31d4f2a8e6b0","status":"failed","error":{"code":"insufficient_balance","message":"Insufficient org balance"}}`
- 404 Not Found — No job with that id exists in your org, or the media path names an unknown vendor/model/function. Body: `{"message":"media job not found"}`
- 409 Conflict — The result was requested before the job completed, or an Idempotency-Key header was reused with a different body. Body: `{"message":"media job is not ready"}`
- 422 Unprocessable Entity — The request body failed validation: an invalid enum value, a missing required field, a wrong type, or malformed JSON. The JSON message names the offending field. A schema-valid parameter combination that cannot be priced instead fails after job creation and returns the failed job envelope with error code `invalid_input`. Body: `{"message":"duration: Input should be less than or equal to 15"}`
- 429 Too Many Requests — You've hit your per-minute or per-day request limit, or your org's job queue is full. Returned as the failed job envelope. If there's a Retry-After header, wait that long, then retry with a fresh Idempotency-Key. Body: `{"id":"media_8f3a2c91-5b7d-4e0a-9c26-31d4f2a8e6b0","status":"failed","error":{"code":"rate_limited","message":"rate limit exceeded: rpm"}}`
- 503 Service Unavailable — The model rail or a backend dependency is temporarily unavailable. Returned as the failed job envelope; retry with backoff and a fresh Idempotency-Key. Body: `{"id":"media_8f3a2c91-5b7d-4e0a-9c26-31d4f2a8e6b0","status":"failed","error":{"code":"provider_unavailable","message":"media dispatch unavailable"}}`

## Pricing

- Output · 480p: $0.03 per second
- Output · 480p · 5s: $0.03 per second
- Output · 480p · 10s: $0.03 per second
- Output · 480p · 15s: $0.03 per second
- Output · 768p: $0.06 per second
- Output · 768p · 5s: $0.06 per second
- Output · 768p · 10s: $0.06 per second
- Output · 768p · 15s: $0.06 per second
- Output · 1080p: $0.075 per second
- Output · 2k: $0.08 per second
- Output · 4k: $0.1 per second
- Video input · 480p: $0.03 per second
- Video input · 768p: $0.06 per second
- Video input · 1080p: $0.075 per second
- Video input · 2k: $0.08 per second
- Video input · 4k: $0.1 per second

Only successful generations are charged.

Check the balance against this price before submitting: `GET https://api.dev.pika.art/billing/balance` returns `balance_micro_usd`, which is US dollars multiplied by 1,000,000, and `postpaid` when the org bills by invoice instead. For an active postpaid org, compare the price against `postpaid.cycle.remaining_micro_usd` rather than the prepaid balance. Report a shortfall to the user rather than submitting a request the balance cannot cover.

---

Model page: https://dev.pika.art/models/pika/pika-h3-flex/reference-to-video
API index: https://dev.pika.art/llms.txt
