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

# Migrate from OpenAI

> Same SDK, same request shapes, the migration is two constructor arguments, a model-name map, and a short list of differences to check.

**1. Swap the credentials**

Keep your OpenAI SDK and change what the constructor points at (create the key on the [API Keys](https://platform.pearlresearch.ai/api-keys) page first):

```python Python theme={null}
import os
from openai import OpenAI

# Before
# client = OpenAI()  # reads OPENAI_API_KEY, talks to api.openai.com

# After, same SDK, two constructor arguments
client = OpenAI(
    base_url="https://inference.pearlresearch.ai/v1",
    api_key=os.environ.get("PEARL_API_KEY"),
)
```

```typescript TypeScript theme={null}
import OpenAI from 'openai';

// Before
// const client = new OpenAI(); // reads OPENAI_API_KEY, talks to api.openai.com

// After, same SDK, two constructor arguments
const client = new OpenAI({
  baseURL: 'https://inference.pearlresearch.ai/v1',
  apiKey: process.env.PEARL_API_KEY,
});
```

**2. Map your model names**

Model IDs are namespaced (`vendor/model`), and capability isn't one-to-one across families, treat this as the starting map, then spot-check on your own prompts in the [playground](https://platform.pearlresearch.ai/playground):

| If you use | Start with | Why |
| - | - | - |
| Frontier reasoning / agent models (o-series, GPT-5-class) | `deepseek-ai/DeepSeek-V4-Pro-0813` | Reasoning with a 1M-token context |
| Mini / nano tiers | `zai-org/GLM-5.3-Flash` | Fast, cheap, still reasons and calls tools |
| General chat (GPT-4o-class) | `zai-org/GLM-5.3` | Strong general chat with a 1M context; returns its thinking in reasoning |
| Fast multimodal tiers (GPT-4o-mini-class) | `zai-org/GLM-5.3-Flash` | Compact and fast with image input, tools, and visible reasoning |
| Structured extraction workloads | `zai-org/GLM-5.3-Flash` | Cheap, fast JSON-mode extraction |
| Vision (image understanding) | `zai-org/GLM-5.3-Flash` | Text and image input with tools and visible reasoning |

**3. Adjust for the differences**

* **Structured outputs:** `json_object` is supported; `json_schema` is not, describe keys in the prompt and validate client-side (see [Structured outputs](/docs/json-mode.md)).
* **Images:** `image_url` accepts base64 data URIs only, the engine never fetches remote URLs (see [Vision](/docs/vision.md)).
* **Reasoning:** unlike the o-series, the chain of thought is returned to you, in `reasoning`, billed as output tokens (see [Reasoning](/docs/reasoning.md)).
* **Endpoints:** chat completions, completions, and models only, embeddings, image generation, audio, batches, and assistants aren't served, so keep those workloads where they are.
* **Extra knobs:** `top_k`, `min_p`, and the `reasoning` object exist here and don't exist on OpenAI, via `extra_body`; conversely OpenAI's `reasoning_effort` is rejected with `400` here, send `{"reasoning": {"effort": …}}` instead. Parameters outside the [documented surface](/docs/reference/chat-completions.md) aren't guaranteed.
* **Billing:** prepaid credits instead of monthly invoicing, an empty balance returns `402`, so turn on [auto-recharge](/docs/auto-recharge.md) before pointing production traffic here.

**4. Verify, then watch the numbers**

Run your own evaluation prompts side by side in the playground before cutting over, then watch the first days of traffic in [Analytics](/docs/analytics.md), cost per model tells you quickly whether the mapping you chose is the right one.

> [!TIP]
>
> Migrating an agent or tool rather than code? The [coding agent setup guide](/docs/guides/coding-agents.md) covers opencode, Aider, and IDE assistants.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.