Migrate
From OpenAI
Move an OpenAI client to plaingateway.
Change two settings and the model ID:
| Setting | Before | After |
|---|---|---|
| Base URL | https://api.openai.com/v1 |
https://api.plaingateway.com/api/v1 |
| Key | sk-... |
sk-pg-v1-... |
| Model | gpt-5.6-luna |
openai/gpt-5.6-luna |
python
import os from openai import OpenAI client = OpenAI(base_url="https://api.plaingateway.com/api/v1", api_key=os.environ["PLAINGATEWAY_API_KEY"])
Chat completions, Completions and Responses keep OpenAI's shapes.
/responses on a non-OpenAI model is translated to chat completions; there previous_response_id and non-function tools return 400.
Read usage.cost for the charge and X-PG-Host for the host. On a stream, read usage.cost in the final usage chunk.