Migrate from OpenAI
Move an OpenAI integration to Panward by changing the base URL and the key, then handle the few differences.
Change two settings#
Set the base URL to https://api.panward.ai/v1 and the key to your Panward key. Where the SDK reads its settings from the environment, change nothing in the code:
$ export OPENAI_BASE_URL=https://api.panward.ai/v1 $ export OPENAI_API_KEY="$PANWARD_API_KEY"
from openai import OpenAI client = OpenAI() # reads OPENAI_BASE_URL and OPENAI_API_KEY raw = client.chat.completions.with_raw_response.create( model="z-ai/glm-5.3", messages=[{"role": "user", "content": "Summarise this discharge note."}], ) print(raw.parse().choices[0].message.content) print(raw.headers["panward-receipt-id"]) # store it with your record
import OpenAI from "openai"; const client = new OpenAI({ baseURL: "https://api.panward.ai/v1", apiKey: process.env.PANWARD_API_KEY, }); const { data, response } = await client.chat.completions .create({ model: "z-ai/glm-5.3", messages: [{ role: "user", content: "Summarise this discharge note." }], }) .withResponse(); console.log(data.choices[0].message.content); console.log(response.headers.get("panward-receipt-id")); // store it with your record
curl -i 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": "Summarise this discharge note."}]}'
Choose models#
Map each model you use to a model of the catalog by capability and context length. Model ids are canonical vendor/name ids; aliases are not resolved, and an unknown id is refused with 404 model_not_found. Choose a Sealed model where the data requires it (Tiers and models).
Check parameters#
Run your requests. A parameter the model cannot honour is refused with 400 unsupported_parameter before any upstream call, so nothing is billed; an unknown field is refused with 400 invalid_request. Reasoning is controlled with reasoning or its shorthand reasoning_effort (Reasoning).
param to see which parameter was refused. What is not available yet.Check what you read from responses#
Responses have no system_fingerprint and no service_tier. Reasoning text arrives in reasoning_content. Check the finish_reason values and ids your code relies on against the response differences.
Update error handling#
Every error has the body {"error": {"type", "message", "param", "request_id", "doc_url"}}. Branch on type, not on message, treat an unknown type by its HTTP status, and retry only what the limits page says can be retried (Errors).
Features to replace#
Some OpenAI endpoints are not offered, among them the Responses API, Assistants, fine-tuning, batch, realtime and moderations. The endpoint table lists what is offered.
Add what Panward gives you#
- Store the
panward-receipt-idof each response with your record (Receipts and verification). - Verify receipts in your pipeline (Verify in CI).
- Set a project policy, for example Sealed only (Policies).
Roll out#
Send a copy of your traffic to Panward first and compare the outputs, then switch a growing share of requests. Use one key per environment, so staging and production can be told apart and revoked separately.
Checklist#
- Base URL and key changed in every environment (how)
- Every model mapped to a canonical id (how)
- No request refused with unsupported_parameter or invalid_request (how)
- Code no longer reads system_fingerprint or service_tier (how)
- Errors handled by type (how)
- Receipt ids stored with your records (how)
- One key per environment (how)