Skip to main content

Migrating from OpenAI

Primex is OpenAI-compatible, so migrating is usually a two-line change: point the SDK at the Primex base URL and use your prx- key.

1. Change base URL + key​

from openai import OpenAI

client = OpenAI(
base_url="https://gateway.primexos.com/v1", # was https://api.openai.com/v1
api_key="prx-YOUR_KEY", # your Primex key, not sk-...
)

The same applies to the Node SDK (baseURL) and any tool that lets you set an OpenAI-compatible base URL. Both Authorization: Bearer prx-… and x-api-key: prx-… are accepted.

2. Map model names​

Primex uses its own model IDs, not OpenAI's. Don't hard-code a name from an old guide. Instead, fetch the live list:

curl https://gateway.primexos.com/v1/models -H "Authorization: Bearer prx-YOUR_KEY"

This call is free and works at zero balance. Pick the ID you want and pass it as model. See Models and Live Catalogue and Model Discovery.

3. What's the same​

  • /v1/chat/completions, /v1/responses, /v1/embeddings, /v1/images/generations, and /v1/audio/* accept the standard OpenAI parameters (see each endpoint page).
  • Streaming, tool/function calling, and structured outputs work unchanged. See Guides.

4. What's different​

  • Billing is post-paid per request from your Primex balance. Failed requests aren't billed; successfully delivered usage is metered. See Billing & Credits and Errors & Limits.
  • Built-in Responses tools (e.g. web_search) are metered/gated. See Tool & Function Calling.
  • Model availability and pricing are dynamic; always read the live catalogue.
  • Organization/project headers and OpenAI-only account endpoints don't apply.

Anthropic clients too​

If you use the Anthropic SDK or Claude Code, point them at the Anthropic-compatible base URL instead. See Client Setup → Claude Code and Messages.