Hosted gateway
Base URL, pz_ keys, policies, budgets and errors.
Address and keys
Hosted base URL: https://api.parezen.com/v1. Create a project, then a pz_ key that carries the project and the environment. Add your provider keys in the dashboard; Parezen never marks up the token price. Token counts come from each provider's own usage fields. Replay and switching use only providers you have connected and left enabled. The gateway runs inside the Parezen API at api.parezen.com, served only over TLS. It calls each provider with your own key and records tokens and cost from the provider's own usage fields. Provider keys are stored with envelope encryption, shown only by their last four characters and never logged, and every key and organisation is rate-limited. Parezen accepts a provider key only while all three protections are on.
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.parezen.com/v1",
apiKey: process.env.PAREZEN_API_KEY, // pz_ key. Workspace and environment come from this key.
defaultHeaders: {
"X-Parezen-Route": "support-reply",
"X-Parezen-Task": "ticket_resolved",
},
});
await client.chat.completions.create({
model: "anthropic/claude-sonnet-4.5",
messages: [{ role: "user", content: "Summarise the latest customer ticket." }],
});
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.parezen.com/v1",
api_key=os.environ["PAREZEN_API_KEY"], # pz_ key. Workspace and environment come from this key.
)
client.chat.completions.create(
model="anthropic/claude-sonnet-4.5",
messages=[{"role": "user", "content": "Summarise the latest customer ticket."}],
extra_headers={
"X-Parezen-Route": "support-reply",
"X-Parezen-Task": "ticket_resolved",
},
)
Optional per-request headers
// Optional per-request headers. The client still uses PAREZEN_API_KEY.
await client.chat.completions.create(
{
model: "anthropic/claude-sonnet-4.5",
messages: [{ role: "user", content: "Summarise the latest customer ticket." }],
},
{
headers: {
"X-Parezen-Trace": "trace_example",
"X-Parezen-Cache": "off",
},
},
);
# Optional per-request headers. The client still uses PAREZEN_API_KEY.
client.chat.completions.create(
model="anthropic/claude-sonnet-4.5",
messages=[{"role": "user", "content": "Summarise the latest customer ticket."}],
extra_headers={
"X-Parezen-Trace": "trace_example",
"X-Parezen-Cache": "off",
},
)
Default samples send X-Parezen-Route and X-Parezen-Task with defaultHeaders in Node or extra_headers in Python. Project and environment come from the pz_ key, not a header. Optional per-request headers are X-Parezen-Trace and X-Parezen-Cache: off. No-SDK snippets only work for apps already on the OpenAI format.
To skip the response cache once, send X-Parezen-Cache: off.
Auto routing (parezen/auto)
Send model: "parezen/auto" and Parezen picks the cheapest model your team has approved for that task type. Every key or team needs a usual model (default_model): it is the model Auto falls back to, and the baseline every saving is measured against. Without one, an auto request gets 400 default_model_required; requests that name a model work as before.
const reply = await client.chat.completions.create({
model: "parezen/auto",
messages: [{ role: "user", content: "Summarise this ticket" }],
}, { headers: { "X-Parezen-Task": "support-summary" } });A cheaper model is approved for a team only after it passes the team's test questions (if any) and 50 checks against the usual model's answers. Parezen then checks 2% of answers from approved models, at most 1,000 per team a day. If matched quality falls below the team's quality bar, the model is removed at once and the savings since its last passing check are not counted or charged. Checks are normal usage on your account.
The task type comes from the X-Parezen-Task header, else the X-Parezen-Route header, else the team's default task type. A cheap answer that is empty, a refusal or invalid JSON is retried on the usual model, and that retry is counted.
Cost and saving on every response
- x-parezen-model: the model that answered
- x-parezen-default-model: your usual model, the baseline
- x-parezen-cost-usd: what the call cost, at the provider's list price
- x-parezen-saved-usd: the usual model's cost minus the actual cost
- x-parezen-reason: auto (a cheaper approved model), default (your usual model), fallback (after an error or rate limit) or pinned (you named a model, saving 0)
Streams carry the same fields in the final usage chunk as usage.parezen when you set stream_options.include_usage; otherwise look the request up in Activity. A saving can be negative when an auto choice costs more on actual tokens; it is recorded as it is.
Words on screen
The dashboard uses plain words. The API and these docs keep the technical names. Each maps to one label:
| On screen | Technical name | Meaning |
|---|---|---|
| Your usual model | Default model (default_model) | The model your team would use anyway. Auto compares against it, and savings are measured against it. |
| Quality bar | Quality floor | How closely a cheaper model must match your usual model's answers before Auto uses it. |
| Approved models | Pool | The models Auto may choose from for this team, after they pass your checks. |
| Test questions | Eval set | Prompts with the answers you expect. A model must pass them before Auto uses it. |
| Matched quality | Pass rate | The share of checked answers judged as good as your usual model's. |
| Task type | Task class | A kind of work, such as support replies or document extraction, from the X-Parezen-Task header or the route. |
| Your provider keys | BYOK (bring your own keys) | Your own OpenAI, Anthropic or other accounts. The provider bills you directly. |
| Prepaid balance | Parezen credits | One Parezen key reaches every model; Parezen pays the providers from this balance. |
| Cost and saving | Receipt (x-parezen-* headers) | What each request cost and what it saved against your usual model. |
Policies and budgets
A policy is per route: cost, latency and quality. Budgets sit on the organisation, a workspace or a key, and each agent has a kill switch. A soft limit notifies. A hard limit stops spend at that scope. A shadow test runs before any quality-affecting switch.
Errors
- 401 means the pz_ key is missing or revoked.
- 429 means that key is over its rate limit. Slow down and retry after the time in the retry-after header.
- A budget hard stop or a kill switch is a 4xx. Your app must not fail open around it. Billing never returns an error on production traffic.
- A 5xx or a connection error means Parezen did not serve the call. Your app may fail open to the provider there.