Hosted Quickstart wizard
Hosted gateway
$ npm install openaiinstalled openai$ 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." }],$ });200 · first request · metadata onlyHosted Quickstart for startups
Existing projects: Code review, Agent runner.
If Parezen is unavailable
Example only
Node
// Example only: code you own. Calls sent direct are not routed, recorded, budget-checked or billed.
// Use the provider's own model name (gpt-4.1): Parezen accepts it, so the same request works direct.
import OpenAI from "openai";
const viaParezen = new OpenAI({
baseURL: "https://api.parezen.com/v1",
apiKey: process.env.PAREZEN_API_KEY,
// The timeout covers the whole answer, so keep it longer than your slowest reply.
// A short one would resend slow answers to the provider and pay for them twice.
timeout: 120_000,
maxRetries: 0,
});
const direct = new OpenAI({ apiKey: process.env.OPENAI_API_KEY });
// After 3 failures in a row, go direct for 60 seconds instead of waiting on Parezen each time.
let failures = 0;
let directUntil = 0;
function parezenDown(err) {
// Connection, DNS, TLS and timeout errors, or a 5xx. Never a 4xx such as a budget hard stop.
return err instanceof OpenAI.APIConnectionError || (err?.status ?? 0) >= 500;
}
export async function chat(params) {
if (Date.now() < directUntil) return direct.chat.completions.create(params);
try {
const reply = await viaParezen.chat.completions.create(params);
failures = 0;
return reply;
} catch (err) {
if (!parezenDown(err)) throw err; // a 4xx, including a budget hard stop, must not be bypassed
failures += 1;
if (failures >= 3) directUntil = Date.now() + 60_000;
return direct.chat.completions.create(params);
}
}
Python
# Example only: code you own. Calls sent direct are not routed, recorded, budget-checked or billed.
# Use the provider's own model name (gpt-4.1): Parezen accepts it, so the same request works direct.
import os
import time
import openai
from openai import OpenAI
via_parezen = OpenAI(
base_url="https://api.parezen.com/v1",
api_key=os.environ["PAREZEN_API_KEY"],
# The timeout covers the whole answer, so keep it longer than your slowest reply.
# A short one would resend slow answers to the provider and pay for them twice.
timeout=120,
max_retries=0,
)
direct = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
# After 3 failures in a row, go direct for 60 seconds instead of waiting on Parezen each time.
failures = 0
direct_until = 0.0
def parezen_down(err):
# Connection, DNS, TLS and timeout errors, or a 5xx. Never a 4xx such as a budget hard stop.
return isinstance(err, (openai.APIConnectionError, openai.InternalServerError))
def chat(**params):
global failures, direct_until
if time.monotonic() < direct_until:
return direct.chat.completions.create(**params)
try:
reply = via_parezen.chat.completions.create(**params)
failures = 0
return reply
except Exception as err:
if not parezen_down(err):
raise # a 4xx, including a budget hard stop, must not be bypassed
failures += 1
if failures >= 3:
direct_until = time.monotonic() + 60
return direct.chat.completions.create(**params)
Example only. Calls sent direct are not routed, recorded in the ledger, budget-checked or billed. Do not bypass a 4xx: a budget hard stop must hold. Billing never returns an error on production traffic.