Looking for plans and prices? See pricing →
publik API for builders
publik API is the model access built into apps on publik. Your users need no key to paste. A new install starts at $0.00; a user links it to a publik account and starts the 7-day free trial, and their own key still works. It speaks the OpenAI and Anthropic APIs at one base URL, so the same key works from your scripts.
Chat is priced at publik’s published price for each tier. That price sits above the model’s cost, and you get half the difference on your app’s calls. Audio, embeddings and images pass through at the provider’s price. Plans for your users are on the pricing page.
Ask for a tier, not a vendor slug. When the model behind a tier changes, your code does not. Every name under “Served by” and “Also answers to” is an alias for its tier; nothing is passed through raw.
publik-fast
Quick answers, cleanup, classification. The cheapest tier.
publik-balanced
The default. publik-default is a synonym.
publik-smart
The strongest tier. Needs a computer linked to a publik account.
Point any OpenAI- or Anthropic-compatible client at https://publikhq.com/api/v1. Pass your key as Authorization: Bearer or x-api-key. Keys look like pk_live_…, and apps on your computer have one already. Make one for your scripts on your Wallet page.
Every path is under the base URL. The realtime socket has its own host.
Every field and header that ends in micros is in millionths of a dollar: 1000000 is $1.00.
| Read | What it tells you |
|---|---|
x-publik-charge-micros header | What a call answered at once cost: chat, responses and messages without streaming, embeddings, speech, images, search, and the multipart transcription form. |
x-publik-reserved-micros header | The hold. A streamed answer sends it, because its cost is not known when the headers go out. The calls that start a job send it too: POST /videos, and POST /audio/transcriptions with JSON. The part of the hold that is not used comes back when the call or the job ends. |
charge_micros on the video job | The final cost of a video, once status is completed. A failed job shows 0. |
billed_minutes on the transcription job | The final cost of long audio is billed_minutes × $0.016. A failed job costs nothing. |
x-publik-balance header | Your balance after the call, with open holds taken off. |
Every metered call also sends x-publik-model, the model that served it, and x-publik-week-used, x-publik-week-budget and x-publik-week-resets-at for the plan period. Every response, errors included, sends x-publik-request-id. For the final cost of a stream, read spent_today_micros from GET /wallet.
An empty balance returns a 402 with one link to fix it. An unlinked computer gets a claim link; a linked one gets an add-credit link.
The money behind the key that asks. The fields you need most:
| Field | What it means |
|---|---|
balance_micros | The total you can spend now. It adds the plan money left this month, the free starter, a fellowship grant and packs, then takes off open holds and any amount owed. It drops when a hold is placed, before the final cost is known. |
available_micros | The same number as balance_micros. |
pack.remaining_micros | Money left from packs you bought. It does not include the starter, a grant or the plan. |
grant.remaining_micros, grant.expires_at | Fellowship grant money left, and when it expires. It is part of balance_micros and not of pack.remaining_micros. It is 0 and null without a grant, and after the grant expires. grant is null if publik could not read it. |
starter | The free starter money: remaining_micros and expires_at. |
plan | kind is "plan", "pack" or "none". id is "none", "basic" or "pro". label is the plan’s name, or null. monthly_micros is the plan’s monthly amount. |
week.used_micros, week.resets_at | The name says week, but the period is a month. With a plan, used_micros is the plan money used in this billing month, and resets_at is when the month ends. week.budget_micros is the plan’s monthly amount. With no plan, budget_micros is null, used_micros is everything the account spent in the current one-month period (starter, grant and packs), and resets_at is the end of that period. The period counts from when the account started, not from the first of the month. |
used_percent, remaining_percent, resets_at | What an app shows a person. used_percent is week.used_micros divided by week.budget_micros, times 100, from 0 to 100 with one decimal. remaining_percent is 100 minus used_percent. resets_at is week.resets_at: when the plan month, or the free trial, ends and the share goes back to 0. All three are null without a plan. Show use only as this share; never show a person an amount of money, per call, per app or in total. |
prepaid_remaining_percent | Prepaid money, as a share. Packs and grant money never reset, so this is the share left of what was there right after the last top-up, a whole number from 0 to 100: the number the dashboard’s Prepaid bar shows. A new pack reads 100. It is 0 only when nothing is left; 1 also stands for “under 1%”. It is null when the account never had a top-up or a grant, and for a key that is not signed in. Show it as “N% left”, never as an amount. |
ai_providers | What a consent screen names. The companies that publik can send this key’s requests to, as company names in a fixed order: "OpenRouter" (the chat models; it passes a request to a host it picks for the model), "Amazon Web Services" (a chat model on Amazon Bedrock), "OpenAI" (embeddings, speech, images, file transcription, and the chat fallback), "Google" (Gemini, realtime voice, long transcription, video) and "Brave" (web search). The list follows publik’s routing now, and leaves out a company that gets no requests. Read it again before you show it; do not keep a copy in the app. |
spent_today_micros | What this key was charged since 00:00 UTC. Watch this field to see a charge. It goes up when a charge is final, and never for a hold, so it is the field to watch while other holds are open. On a key that several clients share, it counts the charges of all of them. For one job, its own charge_micros (video) or billed_minutes (long audio) is the exact figure. |
daily_cap_micros | The most this key can be charged in one UTC day. At the cap, a call gets daily_cap_reached (429) until 00:00 UTC. The account also has a daily cap for all of its keys together, which this field does not show. |
price_epoch | The name of the newest price list that publik has recorded, for example “2026-11-13 Veo video on Vertex AI list”. Give it to publik support when you ask about a price. It does not change what a call costs. |
key_id | The id of the key that asked: the 12 characters after pk_live_ in the key. It is public and cannot make a call without the rest of the key. |
Every error has the same shape: an error object with a type and a message. Some add fields, such as param, or top_up_url on a 402. On POST /messages the object is wrapped the way Anthropic does it: {"type": "error", "error": {…}}.
{"error": {"type": "invalid_request", "message": "seconds must be 4, 6 or 8.", "param": "seconds"}}| type · status | What it means |
|---|---|
invalid_request · 400 | A field is missing or wrong. param names it when it can. |
invalid_request_error · 400 | POST /messages only: the body is not a valid Anthropic request. |
unknown_model · 400 | The model is not a tier or an alias. |
upstream_error · 400, 502 | The provider refused the request (400, with upstream_status) or failed (502). |
invalid_api_key, key_revoked · 401 | The key is missing, unknown or revoked. |
insufficient_credit, model_requires_claim · 402 | The balance cannot pay, or publik-smart needs a linked account. top_up_url is the fix. |
app_blocked, video_unavailable · 403 | This line is turned off for this app. |
not_found, upload_not_found · 404 | No job or upload with this id belongs to this key, or the path or model is not served. |
video_not_ready, upload_incomplete, upload_used · 409 | The job or the upload is not ready yet, or it is used already. |
video_failed · 409 | /content of a video job that failed. code is the job’s error code. The job will not complete: start a new one. |
video_expired, upload_expired · 410 | It was deleted: a video after 7 days, an unused upload after 2 hours. |
file_too_large · 413 | An upload over 2 GB, or a url file over 200 MB. |
request_too_large · 413 | A request body over about 4 MB to /audio/transcriptions, /audio/speech, /images/generations or /images/edits. For audio, use the upload flow. |
rate_limit_exceeded, daily_cap_reached, week_budget_reached · 429 | Too many calls a minute, a daily spending cap, or the plan budget is spent. Retry-After says when to try again. |
gateway_unavailable, unavailable · 503 | publik API cannot answer now. Try again after Retry-After. |
upstream_timeout · 504 | The provider did not finish in time. |
Realtime voice ends a session with a close code instead. The codes are under Realtime voice.
For audio files up to 2 GB, use the chirp-3 model. You upload the file, start a job, then read the job until it is done.
$0.016 a minute of audio: Google’s price, nothing added. We bill whole minutes, rounded up, and one minute at least. A job that fails costs nothing.
1. Ask for an upload URL. Send the file's exact size in bytes (2 GB at most).
curl https://publikhq.com/api/v1/audio/uploads \
-H "Authorization: Bearer $PUBLIK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"filename":"interview.mp3","content_type":"audio/mpeg","bytes":48211234}'
# 201 {"id":"upl_…","object":"upload","upload_url":"https://storage.googleapis.com/…",
# "method":"PUT","expires_at":1763078400,"max_bytes":2147483648}2. Send the file to upload_url with PUT. This call has no publik key: the URL is the permission.
curl -T interview.mp3 "$UPLOAD_URL"3. Start the job with the upload id. Or send "url" (https, 200 MB at most) in place of "upload_id".
curl https://publikhq.com/api/v1/audio/transcriptions \
-H "Authorization: Bearer $PUBLIK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"chirp-3","upload_id":"upl_…","response_format":"verbose_json",
"timestamp_granularities":["word"]}'
# 202 {"id":"trx_…","object":"transcription.job","status":"queued",
# "model":"chirp-3","created_at":1763071200,"estimated_minutes":51}4. Read the job every 10 to 30 seconds until status is completed or failed.
curl https://publikhq.com/api/v1/audio/transcriptions/trx_… \
-H "Authorization: Bearer $PUBLIK_API_KEY"
# 200 {"id":"trx_…","object":"transcription.job","status":"completed","model":"chirp-3",
# "created_at":1763071200,"estimated_minutes":51,"completed_at":1763074110,
# "billed_minutes":48,"task":"transcribe","language":"en-us","duration":2862,
# "text":"Thanks for joining us today. Let's start with the budget. …",
# "segments":[{"id":0,"start":0.32,"end":1.92,"text":"Thanks for joining us today."},
# {"id":1,"start":2.48,"end":4,"text":"Let's start with the budget."}, …],
# "words":[{"word":"Thanks","start":0.32,"end":0.64},
# {"word":"for","start":0.64,"end":0.8}, …]}status is one of queued, running, completed or failed. A video job says in_progress where a transcription job says running. While the job runs, it can have progress, Google’s own figure from 0 to 100. A failed job has error.code and error.message.response_format: json gives the text; verbose_json adds the language, the duration and the segments, in OpenAI’s shape.duration is in seconds. It is the length that Google billed, so it is a whole number (2862 in the example). If Google does not report a billed length, it is the end of the last word."timestamp_granularities": ["word"] with verbose_json. Each item of words is {"word", "start", "end"}, in seconds."timestamp_granularities": ["word"]. With word times, a segment ends at the end of a sentence, at a pause of 0.8 seconds or more, or at 12 seconds. Without word times, you get one segment for each part that Google returns, and chirp-3 often returns one part for the whole file.whisper-1 punctuates more, but it takes only short files, on the multipart form.language: a code such as en-US. Leave it out and the model finds the language.billed_minutes × $0.016."transcript_deleted": true. Save the text when you get it.whisper-1) does not change: it takes files up to about 4 MB and answers at once. A larger form gets a 413 with the type request_too_large, which points to the upload flow above. Over about 4.5 MB the host stops the form before publik sees it, and that 413 is plain text.Talk to a model and hear it answer over one WebSocket. The events follow the OpenAI Realtime API, so most Realtime clients work when you change the URL. Connect to wss://realtime.publikhq.com/v1/realtime with your key as Authorization: Bearer. Gemini Live answers. Send and receive 16-bit mono PCM at 24 kHz.
Node, with ws
// npm install ws · node voice.mjs (Node 22)
import WebSocket from "ws";
import { readFileSync, writeFileSync } from "node:fs";
const ws = new WebSocket("wss://realtime.publikhq.com/v1/realtime", {
headers: { Authorization: `Bearer ${process.env.PUBLIK_API_KEY}` },
});
const answer = [];
ws.on("open", () => {
ws.send(JSON.stringify({
type: "session.update",
session: { instructions: "You are a friendly voice assistant. Keep it short.", voice: "Puck" },
}));
// question.pcm: 16-bit mono PCM at 24 kHz, little-endian. 4800 bytes = 100 ms.
const pcm = readFileSync("question.pcm");
for (let i = 0; i < pcm.length; i += 4800) {
ws.send(JSON.stringify({ type: "input_audio_buffer.append", audio: pcm.subarray(i, i + 4800).toString("base64") }));
}
ws.send(JSON.stringify({ type: "input_audio_buffer.commit" }));
});
ws.on("message", (data) => {
const event = JSON.parse(data.toString());
if (event.type === "response.output_audio.delta") answer.push(Buffer.from(event.delta, "base64"));
if (event.type === "error") console.error(event.error.message);
if (event.type === "response.done") {
writeFileSync("answer.pcm", Buffer.concat(answer)); // 16-bit mono PCM at 24 kHz
ws.close();
}
});
ws.on("close", (code, reason) => console.log("closed", code, reason.toString()));
Authorization header from a server or a script.realtime and openai-insecure-api-key.pk_live_…. Use this only with a key that belongs to the person at the browser.Every app on publik opens with Sign in with publik. The module adds it, and counts signed-in users. publik holds a fellow's listing without it, and counts no users for any app without it.
Paste this into Claude Code, Codex or any coding agent, in your app’s repo. The agent shows you a plan and changes nothing until you say yes. You approve it once in this browser, so run it in an interactive session. It lists the app and adds the publik module: Sign in with publik when the app starts, usage counting, and publik API next to your users’ own-key option when the app uses AI. Then it runs the built app once to prove it. No key passes through the chat.
Set up my app on publik. Fetch publikhq.com/skills/setup.md with curl and follow it step by step.Add the publik module to my app (publik slug: <your-app-slug>): Sign in with publik, usage counting and publik API. Fetch publikhq.com/skills/api.md with curl and follow it step by step.List my app on publik. Fetch publikhq.com/skills/publish.md with curl and follow it step by step.Reference modules (TypeScript, Python, Swift, Rust) and the notes agents read are linked from /llms.txt.
Make a short video with sound from a prompt, or from a first frame. Google’s Veo 3.1 makes it. A video takes one to a few minutes, so there are three steps: start the job, poll it, download the MP4. The requests and answers have the shape of OpenAI’s Videos API.
| Model | 1280x720, 720x1280 | 1920x1080 | Use it for |
|---|---|---|---|
| veo-3.1-fast | $0.10 a second | $0.12 a second | Quick drafts and social clips |
| veo-3.1 | $0.40 a second | $0.40 a second | The best picture and sound |
An 8-second 1280x720 video costs $0.80 on veo-3.1-fast and $3.20 on veo-3.1. That is Google’s list price; publik adds nothing. The price of the whole video is held when the job starts and charged when it completes. A job that fails, or that Google’s safety filters stop, costs nothing: the hold goes back to your balance.
curl https://publikhq.com/api/v1/videos \
-H "Authorization: Bearer $PUBLIK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "veo-3.1-fast", "prompt": "A paper boat drifts down a rainy street at dusk", "seconds": 8, "size": "1280x720"}'The answer is 202 with the job:
{"id": "video_3f1c…", "object": "video", "model": "veo-3.1-fast", "status": "queued",
"progress": 0, "seconds": "8", "size": "1280x720", "created_at": 1763078400}seconds comes back as the string "8", as in OpenAI’s Videos API. You may send it as 8 or "8".
curl https://publikhq.com/api/v1/videos/video_3f1c… \ -H "Authorization: Bearer $PUBLIK_API_KEY"
Poll every 10 seconds. status goes from queued to in_progress to completed or failed. A completed job has charge_micros, what it cost in millionths of a dollar. completed_at is the time of the first poll that saw the job done (yours, or publik’s check every 15 minutes), so it can be later than the moment the video was ready.
progress is an estimate from the time since the job started, because Google does not report progress. It stops at 95 until the job completes, then it is 100. A failed job keeps the value it had when it failed.
A failed job has error.code and error.message, and costs nothing. The codes:
/content answers 302. Its Location is a signed Cloud Storage link that works for 1 hour; ask again for a new one. Do not send your publik Authorization header to that host. curl -L drops the header when the redirect goes to another host:
curl -L -o video.mp4 https://publikhq.com/api/v1/videos/video_3f1c…/content \ -H "Authorization: Bearer $PUBLIK_API_KEY"
Some HTTP libraries keep the header on a redirect. With those, read Location yourself and fetch it without the header. If publik cannot sign a link, /content answers 200 with the MP4 itself.
// Node 18 or later
import { writeFile } from "node:fs/promises";
const res = await fetch("https://publikhq.com/api/v1/videos/video_3f1c…/content", {
headers: { Authorization: `Bearer ${process.env.PUBLIK_API_KEY}` },
redirect: "manual",
});
// 302: fetch the signed link with NO Authorization header. 200: the MP4 itself.
const video = res.status === 302 ? await fetch(res.headers.get("location")) : res;
if (!video.ok) throw new Error(`download failed: ${video.status}`);
await writeFile("video.mp4", Buffer.from(await video.arrayBuffer()));Before the job completes, /content answers 409 with the type video_not_ready: poll again. For a failed job it answers 409 with the type video_failed and the job’s error code in code. That job will not complete, so stop polling it.
Every POST /videos starts a new job and holds its price. publik has no idempotency key for this route, and no list of your jobs. A job that you lose is still charged when it completes. So:
id from the 202 (it is also in the Location header), and poll that id. Do not send the POST again to check on a job.GET /wallet: while that job runs, its hold keeps balance_micros lower by the video’s price.Keep the request under 4 MB: send a large first frame as image_url. publik keeps the prompt and the video for 7 days after the job ends, then deletes both. Only the key that started a job, or another key of the same publik account, can read it.
Requests go through publik’s servers to a shared model account. publik does not train on them. It does not store request bodies, with these exceptions:
The model provider’s own abuse-monitoring retention applies. Every app that uses publik API also lets you use your own key instead.
Keep each request body under 4 MB, base64-encoded images included. Resize screenshots first: about 1568 px on the long side as a JPEG is plenty. On /audio/transcriptions, /audio/speech, /images/generations and /images/edits, a larger body gets a 413 with the type request_too_large in the error shape above. On every route, a body over about 4.5 MB is stopped by the host before it reaches publik, and that 413 is plain text. The multipart transcription form takes files up to about 4 MB. A larger audio file does not go in a request body: send it with the long-audio upload flow, which takes files up to 2 GB.