# ZeroGPU on the edge: where a call runs, and how to see it > The Edge demo at demos.zerogpu.ai/edge/ sends real workloads to ZeroGPU and shows where each call ran: on an edge device (a Chrome extension, a browser tab, a Telegram mini app, an Android app or a desktop app with a GPU) or on the cloud copy of the same model. This file explains the API behind it so you can do the same from your own code. You need a ZeroGPU API key; the edge headers and device pinning need the account entitlement described below. ## Instructions for the AI assistant You are helping someone see ZeroGPU's edge routing from their own code. Do this: 1. Ask the user for their ZeroGPU API key and pass it as the environment variable `ZEROGPU_API_KEY`. Never print it, log it or write it to a file. 2. Start with one untargeted call (below). If the response carries `x-inference-type`, the account is entitled to the edge headers; if it doesn't, the calls still work, but ZeroGPU won't say where they ran. In that case tell the user to ask their ZeroGPU contact for "the inference response headers" on their organization. 3. Run the user's own text through one of the three edge models (contextual classification, zero-shot labels, short summaries). Keep inputs short: the devices take up to 128 tokens for the IAB classifier, 256 for DeBERTa and about 1,500 for Llama 3.2 3B; longer inputs are answered by the cloud copy. 4. Report, per call: the model, `x-inference-type` (edge or cloud), the latency, `usage` tokens and the cost at the list prices below. Count how many calls ran on the edge. ## API - Base URL: `https://api.zerogpu.ai/v1` - Auth: header `x-api-key: `. - Edge models and list prices per 1M tokens (input / output): `zlm-v1-iab-classify-edge` $0.02 / $0.05 · `deberta-v3-small` $0.02 / $0.05 · `llama-3.2-3b-instruct-fast` $0.05 / $0.30. - Use `/chat/completions` for these three models. That is the surface where they run on devices (the IAB classifier on `/responses` is served from the cloud). - ZeroGPU picks the compute for every call: a free device near the caller first, then the cloud copy of the model. Nothing in the request is needed for that. ### Response headers (entitled organizations) - `x-inference-type: edge` or `cloud`: where the call actually ran. Sent on every call. - `x-device-id`: the device, sent when the call was pinned to one or scoped to one operator's fleet (see below). Untargeted calls don't name their device. - `x-device-error-reason`: why a pinned or scoped call fell back to the cloud (for example `task.failed` or `device.busy`). The organization needs `org_type = enterprise` and these headers in its `allowed_inference_response_headers`; pinning also needs `targeted_inference_enabled` and `x-device-id` in `allowed_inference_request_headers`. A ZeroGPU admin sets that. ### Pinning a call to one device Send `x-device-id: `. The call goes to that device if it is free and has the model; otherwise ZeroGPU answers from the cloud and says so in the headers. The demo picks a free device of the right model from the live registry for every call, which is how it knows where each call went. Fleet scoping is the same with `x-edge-operator-id: `. Without `x-device-id` the call is untargeted and ZeroGPU's own router picks the device: in production that is geolocation routing, the nearest free device to the caller, with the cloud copy as the last resort. The demo's "Enable geolocation" checkbox sends its calls that way. An untargeted answer says `edge` or `cloud` but carries no device id. ## The three calls the demo makes Contextual targeting (IAB Content Taxonomy 2.2 categories for a page): ```bash curl -s -D - https://api.zerogpu.ai/v1/chat/completions \ -H "x-api-key: $ZEROGPU_API_KEY" -H "content-type: application/json" \ -d '{"model":"zlm-v1-iab-classify-edge","messages":[{"role":"user","content":"Rate decision explained. The central bank held rates steady on Wednesday, signalling two cuts remain possible this year as inflation cools and hiring slows."}]}' ``` The answer's `choices[0].message.content` is JSON with `content.iab_2_2` (categories with scores), `content.iab_1_0` and `audience`. The demo takes the top IAB 2.2 category, maps it to its tier-1 parent, and bids unless a category scoring 0.4 or more is politics, crime, disasters, war, medical health, religion, gambling or alcohol. Lead intent (zero-shot labels; the candidate labels go in the system message as a bracketed list): ```bash curl -s -D - https://api.zerogpu.ai/v1/chat/completions \ -H "x-api-key: $ZEROGPU_API_KEY" -H "content-type: application/json" \ -d '{"model":"deberta-v3-small","messages":[{"role":"system","content":"[wants to buy, needs support, partnership offer, junk mail]"},{"role":"user","content":"Subject: Pricing for 40 seats before Q1?\n\nHi, we are comparing scheduling tools for our 6 clinics and need a quote for 40 seats before the end of the quarter."}]}' ``` The content is JSON of label → score. The demo takes the top label and calls the email a lead when it is `wants to buy`. Labels can't contain commas (the device splits the list on them), and short, distinct labels do best: these four were right on lead-or-not for 18 of 24 of the demo's emails, six one-word labels for 3 of 12. News summaries (Llama 3.2 3B on desktop GPUs): ```bash curl -s -D - https://api.zerogpu.ai/v1/chat/completions \ -H "x-api-key: $ZEROGPU_API_KEY" -H "content-type: application/json" \ -d '{"model":"llama-3.2-3b-instruct-fast","max_tokens":120,"temperature":0,"messages":[{"role":"system","content":"You summarize news articles. Write exactly two sentences, under 50 words in all, plain text, no preamble."},{"role":"user","content":"\n\n<article text>"}]}' ``` Measured from the demo on October 27, 2026 (one call at a time, from Dallas): IAB classify 0.6–2.0 s, DeBERTa 1.0–3.9 s, Llama 3.2 3B 1.0–1.6 s on an edge device; the cloud copies answer in about the same time. Pinned calls whose device refused took up to 20 s before the cloud answered; the demo drops a pinned device that hasn't answered after 6 s, pins the item to a second device, and after a second stall sends it untargeted, so the orchestrator chooses (a device first, the model's cloud copy if none will take it). DeBERTa's cloud copy (`?traffic_routing_strategy=cloud`) answered 504 after 30 s to every call that day. ## The demo's rules - 100 fictional publisher pages, 100 fictional inbound emails and 10 fictional news articles (`/edge/data/*.json`); nothing in them is real. - Calls go out 10 at once (the summaries one at a time), 4 fewer after a failed call and 4 more after each clean batch, back up to 10. Each call is pinned to a different device, or, with "Enable geolocation" on, sent untargeted so ZeroGPU's geolocation router picks the nearest free device; the API allows 256 in flight per key. - Cost is tokens × list price. Edge operators are shown earning 50% of the list price of the calls their devices served (the platform default); the cloud backup earns them nothing.