SDKs
Which libraries to use with Panward, and how to read Panward's headers and keep the raw bytes with them.
Use the OpenAI SDK you already have#
Any OpenAI SDK works with Panward when you change two settings: the base URL becomes https://api.panward.ai/v1 (or a regional host) and the key becomes your Panward key. The samples on these pages use the official Python and Node SDKs.
$ pip install openai
$ npm install openai
The compatibility page lists what differs from OpenAI.
Read Panward's headers#
Panward adds nothing to the response body. What it tells you about a request is in the response headers, so ask the SDK for the raw response: with_raw_response in Python, .withResponse() or .asResponse() in Node.
import os from openai import OpenAI client = OpenAI( base_url="https://api.panward.ai/v1", api_key=os.environ["PANWARD_API_KEY"], ) raw = client.chat.completions.with_raw_response.create( model="z-ai/glm-5.3", messages=[{"role": "user", "content": "Hello"}], ) for name in ("panward-request-id", "panward-receipt-id", "panward-tier", "panward-region", "panward-model"): print(name, raw.headers.get(name)) request_bytes = raw.http_response.request.content # hashed in request.received response_bytes = raw.http_response.content # hashed in response.emitted reply = raw.parse()
import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.panward.ai/v1", apiKey: process.env.PANWARD_API_KEY, }); const response = await client.chat.completions .create({ model: "z-ai/glm-5.3", messages: [{ role: "user", content: "Hello" }], }) .asResponse(); for (const name of ["panward-request-id", "panward-receipt-id", "panward-tier", "panward-region", "panward-model"]) console.log(name, response.headers.get(name)); const responseBytes = Buffer.from(await response.arrayBuffer()); // hashed in response.emitted const reply = JSON.parse(responseBytes.toString("utf8"));
curl -s -D headers.txt -o response.bin https://api.panward.ai/v1/chat/completions \ -H "Authorization: Bearer $PANWARD_API_KEY" \ -H "Content-Type: application/json" \ -d '{"model": "z-ai/glm-5.3", "messages": [{"role": "user", "content": "Hello"}]}' grep -i '^panward-' headers.txt # response.bin holds the bytes hashed in response.emitted
| Header | What it holds |
|---|---|
| panward-request-id | The request id. Quote it to support. |
| panward-receipt-id | The id of the request's receipt, streamed or not. |
| panward-tier | sealed or routed: the tier that served the request. |
| panward-region | The code of the region that served the request. |
| panward-model | The model that answered. |
Step 4 of verification compares the hashes of the exact request and response bytes with the receipt. Keep the raw bytes when you need that step: a parsed and re-serialised body does not match (Verification guide).
Panward SDKs#
panward (Python) and @panward/sdk (JavaScript) are not published. Everything on these pages works with the OpenAI SDKs and plain HTTP. What is not available yet.Verifier packages#
Verification does not depend on an SDK. warden is the open-source verifier of receipts and attestations, with a command line, a JavaScript front end (@panward/warden) and a Python front end (panward-warden) over one Rust core.
warden command line from the gateway repository (Warden command line). What is not available yet.Configuration#
- Read the key from the
PANWARD_API_KEYenvironment variable or your secret manager. Never put it in source control, a browser or a mobile app. - Use a regional host (
https://api.eu.panward.ai/v1) when your organization pins regions (Regions and residency). - Set the client's timeout for your longest request, and stream long answers (Timeouts).
- Retry only what the limits page says can be retried, with back-off, and wait at least
Retry-Afterwhen it is sent.
Other languages#
Any HTTP client works. Send Authorization: Bearer with your key and Content-Type: application/json, and optionally panward-tier, panward-fallback, panward-hold-until-verified and X-Request-Id (Request headers). Write the body to a file and send that file, so the bytes you keep are the bytes that were sent.
cat > request.json <<'EOF' {"model": "z-ai/glm-5.3", "messages": [{"role": "user", "content": "Summarise this discharge note."}]} EOF curl https://api.eu.panward.ai/v1/chat/completions \ -D headers.txt -o response.bin \ -H "Authorization: Bearer $PANWARD_API_KEY" \ -H "Content-Type: application/json" \ -H "panward-tier: sealed" \ -H "X-Request-Id: order-4711" \ --data-binary @request.json grep -i '^panward-' headers.txt
Versions#
The API is versioned in its path (/v1) and changes additively. Warden and the receipt and attestation formats are versioned too (Versioning and notice).