> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aireserve.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Migrating from OpenAI

> Two lines in client construction — the base URL and the API key. Everything else passes through verbatim.

Migration is intentionally boring. If you call OpenAI through the official
`openai` package, the change is **two lines in client
construction** — the base URL and the API key. Message shapes, tool definitions,
streaming loops, `temperature` and every other request field pass through
the gateway verbatim, so nothing else in your codebase changes.

| OpenAI concept                        | AI Reserve equivalent                                                                                              |
| ------------------------------------- | ------------------------------------------------------------------------------------------------------------------ |
| API key from `platform.openai.com`    | API key from your AI Reserve workspace (`aireserve_api_…`) — see [Authentication](/getting-started/get-an-api-key) |
| `OPENAI_API_KEY` environment variable | `AUDACITY_API_KEY`, or pass the key to the constructor                                                             |
| `https://api.openai.com/v1`           | `https://api.aireserve.com/v1` (keep the `/v1` suffix)                                                             |
| OpenAI models only                    | Every [gateway model](/models) — Claude, Gemini, Grok, Llama, … answer the same `chat.completions` call            |
| OpenAI error objects                  | Same shapes on standard HTTP statuses (400/401/404/429/5xx) — see [Errors & retries](/api-reference/errors)        |

<CodeGroup>
  ```diff Python theme={"dark"}
   import os
   from openai import OpenAI

   client = OpenAI(
  -    api_key=os.environ["OPENAI_API_KEY"],
  +    base_url="https://api.aireserve.com/v1",  # note the /v1 suffix
  +    api_key=os.environ["AUDACITY_API_KEY"],
   )

   # Everything below is unchanged — and now works with any gateway model:
   res = client.chat.completions.create(
  -    model="gpt-4o-mini",
  +    model="gpt-5.4-mini",   # or claude-sonnet-4-6, gemini-2.5-flash, …
       messages=[{"role": "user", "content": "hello"}],
   )

   # Streaming call sites are identical:
   for chunk in client.chat.completions.create(model=…, messages=…, stream=True):
       print(chunk.choices[0].delta.content or "", end="")
  ```

  ```diff TypeScript theme={"dark"}
   import OpenAI from "openai";

   const client = new OpenAI({
  -  apiKey: process.env.OPENAI_API_KEY,
  +  baseURL: "https://api.aireserve.com/v1", // note the /v1 suffix
  +  apiKey: process.env.AUDACITY_API_KEY,
   });

   // Everything below is unchanged — and now works with any gateway model:
   const res = await client.chat.completions.create({
  -  model: "gpt-4o-mini",
  +  model: "gpt-5.4-mini", // or claude-sonnet-4-6, gemini-2.5-flash, …
     messages: [{ role: "user", content: "hello" }],
   });
  ```
</CodeGroup>

Prefer one dependency across all of your model traffic? The
[AI Reserve SDKs expose the OpenAI format natively](/api-reference/sdk-wire-formats) (v0.5.0 in
all five languages), with the gateway's [retry policy and exception
taxonomy](/api-reference/errors) built in. The calling convention is identical — only the import and
constructor change:

```python theme={"dark"}
from audacity import Audacity

client = Audacity()   # reads AUDACITY_API_KEY

response = client.chat.completions.create(   # same calling convention
    model="gpt-5.4-mini",
    messages=[{"role": "user", "content": "Hello!"}],
)
```

<Note>
  **What carries over verbatim.** Messages, `tools` /
  `tool_choice`, `response_format`, sampling parameters, and
  streaming loops — requests pass through unmodified, and streams still end at
  `data: [DONE]`. What changes: the key and its environment variable, the
  base URL, and the model namespace — every gateway model is now callable from the same
  code, and `GET /v1/models` enumerates the live catalog.
</Note>
