Build
Migrating from OpenAI
Change the base URL, the key and the model id. What stays the same, and the few things to check.
The change
import os
from openai import OpenAI
client = OpenAI(
base_url="https://sovereign.paranine.com/v1", # was api.openai.com
api_key=os.environ["P9_API_KEY"], # sk_p9_… instead of sk-…
)
client.chat.completions.create(
model="paranine/gpt-oss-120b(Global)", # a Paranine model id
messages=[{"role": "user", "content": "Hello"}],
)Frameworks that wrap the OpenAI client (LangChain, LlamaIndex, the Vercel AI SDK's OpenAI-compatible provider and most agent toolkits) take the same two settings, usually as base_url or baseURL and api_key.
What stays the same
- Chat completions requests and responses:
messages,stream,max_tokens,temperature,tools,usage,finish_reason. - Streaming as server-sent events ending in
data: [DONE]. - Embeddings on
/v1/embeddings. - The error envelope (
message,type,code,param) and what401,429and5xxmean.
What to check
| Area | On Paranine |
|---|---|
| Model names | Use Paranine model ids from the catalogue, verbatim. There is no gpt-4o: pick the open-weight model that fits. |
| Parameters | n must be 1. Parameters outside OpenAI's chat completions API are refused with 400 rather than ignored. |
| Reply length | Without max_tokens, replies are capped at the model's default length. Set max_tokens when you expect long answers. |
| Balance errors | 402 when your balance or the key's credit cap can't cover a request. OpenAI has no equivalent: handle it explicitly. |
| Rate limits | 60 requests per minute per key by default, adjustable per key. A model at capacity answers 429 whichever key you use. |
models.list() | Not available yet (404). Keep the model id in configuration. |
| Not available | Images, files, assistants, /v1/completions and /v1/responses. |
A safe rollout
- Create a key with a credit cap, and with allowed models set to the one model you're moving to, so the trial can't overspend.
- Point a staging deployment at Paranine with that key, and compare output and latency in the request logs.
- Move production to its own key and cap, so its spend and errors show on a line of their own.
Further reading
- What OpenAI-compatible actually means: what the phrase covers, and where compatibility usually stops.
- Moving an OpenAI-compatible codebase to P/9: the same move as a narrative, with the traps.
Something unclear or wrong on this page? Tell us. Machine-readable copies: llms.txt.