Polling
Call GET /v1/media/jobs/{id} every few seconds. Statuses: queued → running → completed, failed or cancelled. If you're at your concurrency limit, the job simply waits in queued.
The Pika API lets your app, script or AI agent generate H3 Flex videos with synchronized audio. This guide goes from zero to a downloaded MP4: create a key, authenticate, send a server-side request, choose a generation mode, poll (or use webhooks), check billing, download the result and handle errors safely. It includes working Python and Node.js examples.
Sign in at dev.pika.art/login. Signing in creates your organization.
Generate one at dev.pika.art/keys, where you can also rotate and revoke keys.
Generation is prepaid. Top up at dev.pika.art/billing, or a submit fails with insufficient_balance. The membership is $10 a month, returned as $10 of API credits.
Save it as an environment variable named PIKA_API_KEY. Never put it in browser code, URLs or source control.
| Need | Where |
|---|---|
| Sign in | dev.pika.art/login |
| API keys | dev.pika.art/keys |
| Add funds | dev.pika.art/billing |
| Webhooks | dev.pika.art/webhooks |
| Model catalog | dev.pika.art/models |
| Pricing | dev.pika.art/pricing |
| OpenAPI spec | dev.pika.art/openapi.json |
| API base URL | https://api.dev.pika.art |
| Support | api@pika.art |
From Pika's developer docs index at dev.pika.art/llms.txt. Pika also offers an agent onboarding prompt for coding agents such as Claude Code, Codex or Cursor.
Every call to https://api.dev.pika.art sends your key in a header. Pika accepts either:
X-API-Key: YOUR_KEY (used in Pika's model docs)Authorization: Bearer YOUR_KEYThe x-goog-api-key header is not accepted. The public catalog at api.dev.pika.art/catalog/apis is the only listed endpoint that needs no key.
# Test your key: check your balance (free)
curl https://api.dev.pika.art/billing/balance \
-H "X-API-Key: $PIKA_API_KEY"
# Response (micro-USD: 1 USD = 1,000,000)
{ "balance_micro_usd": 10000000, ... }
Postpaid organisations compare against postpaid.cycle.remaining_micro_usd instead.
All six run as async jobs. Submit to POST https://api.dev.pika.art/v1/media/pika/pika-h3-flex/{mode}.
| Mode | Key inputs | Price |
|---|---|---|
text-to-video | prompt, duration 3 to 15, resolution, aspect_ratio | $0.01 to $0.08 / s |
image-to-video | prompt + first frame, last frame, or both | $0.01 to $0.08 / s |
reference-to-video | prompt + references (up to 9 images, 3 videos, 3 audio) | $0.03 to $0.10 / s, plus reference video seconds |
draft-to-video | draft_job_id or video + resolution (1080p/2k/4k) | Pay the difference |
prompt-rewriter | prompt, mode (fl2va / ref2va), optional refs | $0.02 / request |
audio-stems | request_id or input_url (up to 120 s) | $0.001 / stem-second |
| Common parameter | Values | Default |
|---|---|---|
duration | Whole seconds, 3 to 15 | 5 |
resolution | 480p, 768p (native) · 1080p, 2k, 4k (upscaled) | 768p |
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 | auto with rewrite on |
rewrite | true / false | true |
seed | Integer, or omit for random (result reports the seed) | Random |
output_mode | video or audio-stems (adds a separation fee) | video |
webhook_url | Optional top-level URL for this job's completion event | None |
From Pika's model specs for text to video, image to video, reference to video, draft to video, prompt rewriter and audio stems. The seed's minimum value is listed differently in two specs, so omitting it for a random seed is the safest option.
Example outputs © Pika, from the Pika H3 Flex research post.
A 5-second 768p text-to-video job costs $0.10. Here's the full flow: check balance, submit, poll, download.
GET /billing/balance is free and confirms the key can pay.
POST your prompt with an Idempotency-Key header. The response is a job with status queued. Store its id.
GET /v1/media/jobs/{id} until the status is completed, failed or cancelled. Or receive a webhook instead.
Read output.video.url, or call GET /v1/media/jobs/{id}/content, and save the file to your own storage.
Log spend only when billing.state is settled, using charge_micro_usd keyed by job ID.
curl -X POST \
https://api.dev.pika.art/v1/media/pika/pika-h3-flex/text-to-video \
-H "X-API-Key: $PIKA_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-d '{
"prompt": "A red fox trots through fresh snow at dawn, slow tracking shot. Sound: crunching snow, distant birds. No music. No subtitles.",
"duration": 5,
"resolution": "768p",
"aspect_ratio": "16:9",
"rewrite": false
}'
# → { "id": "media_...", "status": "queued", ... }
Minimal server-side scripts for the full flow. Adapt the error handling and storage for production.
import os, time, uuid, requests
API = "https://api.dev.pika.art"
H = {"X-API-Key": os.environ["PIKA_API_KEY"]}
# 1. Balance check
bal = requests.get(f"{API}/billing/balance", headers=H).json()
print("Balance (USD):", bal.get("balance_micro_usd", 0) / 1e6)
# 2. Submit
body = {
"prompt": "A red fox trots through fresh snow at dawn, "
"slow tracking shot. Sound: crunching snow. No subtitles.",
"duration": 5, "resolution": "768p", "aspect_ratio": "16:9",
}
r = requests.post(
f"{API}/v1/media/pika/pika-h3-flex/text-to-video",
headers={**H, "Idempotency-Key": str(uuid.uuid4())},
json=body,
)
r.raise_for_status()
job = r.json()
job_id = job["id"]
# 3. Poll
while job["status"] not in ("completed", "failed", "cancelled"):
time.sleep(5)
job = requests.get(f"{API}/v1/media/jobs/{job_id}", headers=H).json()
if job["status"] != "completed":
raise SystemExit(f"Job ended: {job['status']} {job.get('error')}")
# 4. Download
url = job["output"]["video"]["url"]
with open("first-h3-flex.mp4", "wb") as f:
f.write(requests.get(url).content)
# 5. Billing
print("Billing:", job.get("billing"))
import { randomUUID } from "node:crypto";
import { writeFile } from "node:fs/promises";
const API = "https://api.dev.pika.art";
const H = { "X-API-Key": process.env.PIKA_API_KEY };
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
// Submit
let res = await fetch(
`${API}/v1/media/pika/pika-h3-flex/text-to-video`, {
method: "POST",
headers: { ...H, "Content-Type": "application/json",
"Idempotency-Key": randomUUID() },
body: JSON.stringify({
prompt: "A red fox trots through fresh snow at dawn, " +
"slow tracking shot. Sound: crunching snow. No subtitles.",
duration: 5, resolution: "768p", aspect_ratio: "16:9",
}),
});
if (!res.ok) throw new Error(`Submit failed: ${res.status}`);
let job = await res.json();
// Poll
const done = ["completed", "failed", "cancelled"];
while (!done.includes(job.status)) {
await sleep(5000);
job = await (await fetch(
`${API}/v1/media/jobs/${job.id}`, { headers: H })).json();
}
if (job.status !== "completed")
throw new Error(`Job ${job.status}: ${JSON.stringify(job.error)}`);
// Download
const mp4 = await fetch(job.output.video.url);
await writeFile("first-h3-flex.mp4",
Buffer.from(await mp4.arrayBuffer()));
console.log("Saved. Billing:", job.billing);
Field names follow Pika's published job schema (id, status, output.video.url, billing). Confirm against openapi.json before production. These examples are ours, not official Pika SDK code. Pika's docs don't list an official SDK.
Inputs are passed as URLs. If your file is public, use its URL directly. For local files, use Pika's presigned upload flow:
POST /v1/media/uploads with content_type and size_bytes.
Upload the bytes to upload_url using the returned headers exactly as given, within 5 minutes.
urlPass that permanent URL as your image, video or reference input.
POST /v1/media/pika/pika-h3-flex/reference-to-video
{
"prompt": "References: @Image1 is the character. @Video1 supplies only the dance motion. @Image1 dances in a record shop. Audio: funk groove. No subtitles.",
"duration": 8,
"resolution": "768p",
"aspect_ratio": "9:16",
"references": [
{ "type": "image", "url": "https://…/character.png", "role": "identity" },
{ "type": "video", "url": "https://…/dance.mp4" }
]
}
Pika's reference-to-video page shows both a references array and separate image_urls/video_urls/audio_urls fields. Confirm which your account accepts. Limits: images up to 9 (PNG, JPEG, WebP), videos and audio up to 3 each (2 to 15 s, 15 s combined), each original file up to 50 MiB. See H3 Flex references.
Call GET /v1/media/jobs/{id} every few seconds. Statuses: queued → running → completed, failed or cancelled. If you're at your concurrency limit, the job simply waits in queued.
Add webhook_url to one submit, or register an endpoint for all jobs at dev.pika.art/webhooks. Deliveries follow the Standard Webhooks signing scheme and retry for about 55 hours.
Verify every signature and deduplicate on the webhook-id header. Only an owner or admin can read the signing secret on the Webhooks page, not an API key. Past deliveries: GET /v1/webhooks/deliveries.
Full receiver details in Pika's webhook specification.
balance_micro_usd and charge_micro_usd.billing.state is settled. If it's pending, re-check after 1, 2, then 5 seconds. If it's unavailable, wait at least 30 seconds. A null billing value means no charge was recorded, not that the job was free.| Sample job | Cost |
|---|---|
| 5 s text to video, 768p | $0.10 |
| 15 s image to video, 768p | $0.30 |
| 12 s text to video, 2K | $0.48 |
| 15 s text to video, 4K | $1.20 |
| 5 s reference to video, 768p | $0.30 |
| Prompt rewrite | $0.02 |
Full breakdown: H3 Flex pricing.
output.video.url. GET /v1/media/jobs/{id}/content returns { "url": "..." }, or a 409 if the job isn't finished yet.DELETE /v1/media/jobs/{id} erases the job's stored media and its captured request (prompt and parameters).draft-to-video. See the 4K guide.audio-stems on the completed job. See the audio guide.
Pika returns HTTP errors for bad requests and a failed job envelope for problems found at submit time. Branch on error.code.
| Error | What it means | What to do |
|---|---|---|
| HTTP 422 | Validation failed; the message names the field | Fix the field (duration, resolution, references…) and resubmit |
invalid_input | Inputs rejected (format, size, limits) | Check file types, sizes and reference limits |
insufficient_balance | Not enough prepaid funds | Top up at dev.pika.art/billing; check balance before submitting |
content_moderation | Prompt or media blocked by policy | Revise the content; see Pika's Acceptable Use Policy |
HTTP 429 / rate_limited | Per-minute or per-day limit hit | Wait for Retry-After, then resubmit with a fresh key |
provider_error | Upstream or unknown failure | Retry with backoff and a fresh Idempotency-Key |
timed_out | The job took too long | Retry, or try a shorter duration or lower resolution |
| HTTP 409 | Idempotency-Key reused with a different body, or content requested too early | Use a new key for new requests; wait for completed before fetching content |
Send a unique Idempotency-Key with each new submit. Reusing a key returns the existing job, even a failed one, so retries need a fresh key.
Use exponential backoff with jitter for 429 and provider errors, and always honour Retry-After.
Call the free balance endpoint before large batches, and don't submit if the balance can't cover the job.
Write spend to your ledger only when billing.state is settled, keyed by job ID.
Error codes and retry rules from Pika's H3 Flex model specs and the developer docs index. Pika doesn't publish the exact rate-limit values. Enterprise plans offer higher concurrency.