> ## 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.

# OpenAI SDK

> Point the official openai package — or any OpenAI-compatible framework — at the gateway with a base-URL swap.

Keep the official `openai` package: change the base URL, use your AI Reserve API key,
and every gateway model — not just GPT — answers the same call.

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

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

  # Works with GPT models — and with Claude/Gemini/... model IDs too.
  res = client.chat.completions.create(
      model="gpt-4o-mini",
      messages=[{"role": "user", "content": "hello"}],
  )
  print(res.choices[0].message.content)

  # Streaming works unchanged too:
  for chunk in client.chat.completions.create(
      model="claude-sonnet-4-6",  # cross-provider: Claude via the OpenAI SDK
      messages=[{"role": "user", "content": "hello"}],
      stream=True,
  ):
      print(chunk.choices[0].delta.content or "", end="")
  ```

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

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

  // Works with GPT models — and with Claude/Gemini/... model IDs too.
  const res = await client.chat.completions.create({
    model: "gpt-4o-mini",
    messages: [{ role: "user", content: "hello" }],
  });
  ```
</CodeGroup>

## Vercel AI SDK (and other OpenAI-compatible providers)

```typescript theme={"dark"}
import { createOpenAI } from "@ai-sdk/openai";
import { streamText } from "ai";

const audacity = createOpenAI({
  baseURL: "https://api.aireserve.com/v1", // /v1 suffix
  apiKey: process.env.AUDACITY_API_KEY,
});

const result = streamText({
  model: audacity.chat("gpt-4o-mini"),
  prompt: "hello",
});
```

Migrating an existing OpenAI codebase? The [Migrating from OpenAI](/migrate/from-openai)
guide covers the full concept mapping — keys, error shapes, and what carries over verbatim.
