Skip to content
publik.
Browse appsBrowsePricing
+Publish a repoPublish
Browse appsHow it worksPublish a repoGet helpPricingDevelopersGitHubPrivacy
© 2026 publik

Looking for plans and prices? See pricing →

publik API for builders

One key, every app, priced in dollars.

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.

Models

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.

    Served by
    z-ai/glm-5.3-flash
    Also answers to
    gpt-4o-mini, claude-haiku-4-5
  • publik-balanced

    The default. publik-default is a synonym.

    Served by
    xiaomi/mimo-v2.6-pro
    Also answers to
    gpt-4o, claude-sonnet-4-6
  • publik-smart

    The strongest tier. Needs a computer linked to a publik account.

    Served by
    openai/gpt-6-sol
    Also answers to
    claude-opus-5
Model tiers, what serves each one, and the names it answers to
TierServed byUse it forAlso answers to
publik-fastz-ai/glm-5.3-flashQuick answers, cleanup, classification. The cheapest tier.gpt-4o-mini, claude-haiku-4-5
publik-balancedxiaomi/mimo-v2.6-proThe default. publik-default is a synonym.gpt-4o, claude-sonnet-4-6
publik-smartopenai/gpt-6-solThe strongest tier. Needs a computer linked to a publik account.claude-opus-5

Base URL

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.

curl https://publikhq.com/api/v1/chat/completions \
  -H "Authorization: Bearer pk_live_…" \
  -H "Content-Type: application/json" \
  -d '{"model":"publik-balanced","messages":[{"role":"user","content":"Hello"}]}'

Endpoints

Every path is under the base URL. The realtime socket has its own host.

  • POST /chat/completionsOpenAI Chat Completions, streaming included
  • POST /responsesOpenAI Responses
  • POST /messagesAnthropic Messages, translated
  • POST /embeddingsthe provider’s price, nothing added
  • POST /audio/transcriptionsthe provider’s price, nothing added · the multipart form takes files up to about 4 MB; a larger form gets a 413 (plain text from the host over about 4.5 MB), so send larger audio through the upload flow, where JSON with chirp-3 starts a job · Long audio
  • POST /audio/uploadsan upload URL for one audio file, up to 2 GB · Long audio
  • GET /audio/transcriptions/{id}a long-audio job, and its transcript when it is done · Long audio
  • POST /audio/speechthe provider’s price, nothing added
  • POST /images/generationsthe provider’s price, nothing added
  • POST /videosstart a video job: 202 with the job · Video
  • GET /videos/{id}poll a video job · Video
  • GET /videos/{id}/content302 to the MP4, a link valid 1 hour · Video
  • POST /searchweb results for a query · one cent a search, whatever the count
  • GET /modelsthe tiers and every alias, OpenAI list shape
  • GET /walletbalance, plan usage and budget, reset time · Fields
  • wss://realtime.publikhq.com/v1/realtimerealtime voice over one WebSocket · Realtime voice

What a call costs

Every field and header that ends in micros is in millionths of a dollar: 1000000 is $1.00.

Where to read what a call cost
ReadWhat it tells you
x-publik-charge-micros headerWhat 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 headerThe 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 jobThe final cost of a video, once status is completed. A failed job shows 0.
billed_minutes on the transcription jobThe final cost of long audio is billed_minutes × $0.016. A failed job costs nothing.
x-publik-balance headerYour 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.

GET /wallet

The money behind the key that asks. The fields you need most:

GET /wallet fields
FieldWhat it means
balance_microsThe 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_microsThe same number as balance_micros.
pack.remaining_microsMoney left from packs you bought. It does not include the starter, a grant or the plan.
grant.remaining_micros, grant.expires_atFellowship 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.
starterThe free starter money: remaining_micros and expires_at.
plankind 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_atThe 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_atWhat 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_percentPrepaid 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_providersWhat 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_microsWhat 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_microsThe 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_epochThe 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_idThe 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.

Errors

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"}}
Error types
type · statusWhat it means
invalid_request · 400A field is missing or wrong. param names it when it can.
invalid_request_error · 400POST /messages only: the body is not a valid Anthropic request.
unknown_model · 400The model is not a tier or an alias.
upstream_error · 400, 502The provider refused the request (400, with upstream_status) or failed (502).
invalid_api_key, key_revoked · 401The key is missing, unknown or revoked.
insufficient_credit, model_requires_claim · 402The balance cannot pay, or publik-smart needs a linked account. top_up_url is the fix.
app_blocked, video_unavailable · 403This line is turned off for this app.
not_found, upload_not_found · 404No 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 · 409The 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 · 410It was deleted: a video after 7 days, an unused upload after 2 hours.
file_too_large · 413An upload over 2 GB, or a url file over 200 MB.
request_too_large · 413A 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 · 429Too many calls a minute, a daily spending cap, or the plan budget is spent. Retry-After says when to try again.
gateway_unavailable, unavailable · 503publik API cannot answer now. Try again after Retry-After.
upstream_timeout · 504The provider did not finish in time.

Realtime voice ends a session with a close code instead. The codes are under Realtime voice.

Long audio

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. 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. 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. 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. 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.
  • For word times, add "timestamp_granularities": ["word"] with verbose_json. Each item of words is {"word", "start", "end"}, in seconds.
  • Segments the size of a caption need "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.
  • chirp-3 often returns little punctuation, so fewer segments end at a sentence. whisper-1 punctuates more, but it takes only short files, on the multipart form.
  • Results are best up to 1 hour of audio a file, and up to 20 minutes with word times. Google stops at 8 hours.
  • language: a code such as en-US. Leave it out and the model finds the language.
  • At the start we hold the estimated minutes from the file size. When the job ends, you pay for the real length, and the rest of the hold comes back.
  • The final cost is billed_minutes × $0.016.
  • An upload that no job uses is deleted after 2 hours. We delete the audio when a read of the job, or our check every 15 minutes, sees the job end. The transcript stays with the job for 7 days after the job ends, so every read in that time returns it. Then we delete it: a read after that has empty text and "transcript_deleted": true. Save the text when you get it.
  • The multipart form (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.

Realtime voice

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()));

The key

  • Send it in the Authorization header from a server or a script.
  • A browser cannot set that header. There, send the subprotocols realtime and openai-insecure-api-key.pk_live_…. Use this only with a key that belongs to the person at the browser.
  • A key in the URL query string is refused with close code 4401. URLs end up in logs.

Prices

  • Audio you send$0.0045 a minute
  • Audio the model speaks$0.018 a minute
  • Text you sendabout $0.001 per 1,000 words
  • Text the model writesabout $0.006 per 1,000 words
  • A minute where both sides talk costs about $0.0225.
  • Each answer also reads the conversation so far. A long session costs more a minute than a short one.
  • A session sets aside $0.225 (10 minutes) of your balance when it opens, and more as it runs. You pay only for what it used.
  • A session runs for 60 minutes at most.

Close codes

  • 4401No key, a wrong or revoked key, or a key in the URL.
  • 4402The balance cannot pay for one more minute. Add money on your Wallet page.
  • 4403This key or app may not use realtime voice.
  • 4408The session reached 60 minutes. Open a new one.
  • 4429The daily spending cap on the wallet or the key is reached.
  • 1011A server error. Try again.
  • 1012The voice server ended the connection. Reconnect and send session.update again.

Add it with your coding agent

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.
  • /skills/setup.md — the whole setup, the prompt above: list the app, add Sign in with publik and usage counting, add publik API where the app uses AI, and prove it with a call from the built app.
  • /skills/api.md — add the publik module to an app that is listed already: token, module, sign-in gate, proof call. Prompt: 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.
  • /skills/publish.md — list an app on publik from its GitHub repository. Prompt: 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.

Video

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.

Price per second of video, sound included

Video price per second for each model and size
Model1280x720, 720x12801920x1080Use it for
veo-3.1-fast$0.10 a second$0.12 a secondQuick drafts and social clips
veo-3.1$0.40 a second$0.40 a secondThe 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.

1. Start the job

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".

2. Poll until it is done

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_filteredGoogle’s safety filters stopped the video. The message gives Google’s reason.
  • upstream_unavailableGoogle’s video service had a temporary error. Send the same request again.
  • timeoutThe video was not ready within 2 hours.
  • generation_failedAny other failure.

3. Download the MP4

/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.

Sending a request again

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:

  • Keep the 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.
  • Give the POST 60 seconds to answer before you stop it. That is the longest the route runs; most of it is the wait for Google to accept the job (30 seconds at most).
  • If the POST times out, you cannot look up the job it may have started. Before you send it again, read GET /wallet: while that job runs, its hold keeps balance_micros lower by the video’s price.

Fields

  • modelveo-3.1 or veo-3.1-fast. Required.
  • promptWhat happens in the video, up to 4,000 characters. Required.
  • seconds4, 6 or 8, as a number or a string ("8"). Default 8.
  • size1280x720, 1920x1080 or 720x1280 (portrait). Default 1280x720.
  • input_reference{"image_url": "https://…"} or {"image_b64": "…", "mime_type": "image/png"}: the first frame, a JPEG or PNG. Optional.
  • generate_audioDefault true: every video has sound, and the price includes it. false gets a 400 invalid_request with param generate_audio, because publik does not offer video without sound.

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.

Where your prompts go

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:

  • Video: the prompt stays with the job, and the MP4 in publik’s storage, for 7 days after the job ends. Then publik deletes the MP4 and clears the prompt.
  • Long audio: the audio file stays in publik’s storage until the job ends. A read of the job, or publik’s check every 15 minutes, sees the end and deletes the file. An upload that no job uses is deleted after 2 hours. The storage deletes every file 7 days after it arrives, whatever else happens.
  • The transcript of a long-audio job stays with the job in publik’s database, so every read of the job returns it. publik does not delete it on a schedule.

The model provider’s own abuse-monitoring retention applies. Every app that uses publik API also lets you use your own key instead.

Request size

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.

Open your Wallet →Browse the apps