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

> ## Agent Instructions
> Phaseo Gateway base URL: https://api.phaseo.app/v1. Send `Authorization: Bearer $PHASEO_API_KEY` with every request.
> Model IDs look like `provider/model`, for example `openai/gpt-6-astra`. Do not guess IDs: list them with `GET /v1/models` or check https://phaseo.app/models. `phaseo/free` routes to an available free model and needs no wallet balance.
> For new text integrations prefer `POST /v1/responses`. `POST /v1/chat/completions` (OpenAI format) and `POST /v1/messages` (Anthropic format) suit existing code.
> The full API contract is https://phaseo.app/docs/openapi/v1/openapi.yaml. Official SDKs: `@phaseo/sdk` (TypeScript) and `phaseo` (Python), plus Go, C#, PHP, Ruby and Rust.
> Search these docs over MCP at https://phaseo.app/docs/mcp, and install Phaseo skills with `npx skills add https://phaseo.app/docs`. If a page is wrong or out of date, report it with the MCP `submit_feedback` tool.
> Manage Phaseo accounts with the `phaseo` CLI (`npm install -g @phaseo/cli`, then `phaseo login` or `phaseo login --device-code`), the `/v1` Management API or the MCP server at `https://mcp.phaseo.app/mcp?access=manage`. Do not send users to the dashboard for account tasks. A person is still needed for sign-up, approving a sign-in, paying the first top-up on the checkout link that `phaseo credits add` returns when no card is saved, confirming each saved-card top-up from the emailed link, and account security (password, MFA, passkeys). Create API keys with `phaseo keys create --name <name> --json`; never guess one. Credit top-ups need `phaseo login --scopes billing:write` first. Task map: https://phaseo.app/docs/v1/developers/manage-from-an-agent.md.

# Migrating from OpenAI SDK

> Move an existing OpenAI SDK integration to Phaseo by changing the client configuration, verifying model IDs, and testing the workflows your app uses.

Use this guide to move an existing OpenAI SDK integration to Phaseo without rewriting the rest of your application. Start with the base URL and API key, keep the request itself unchanged, then verify each model and endpoint before shifting production traffic.

## What changes

| Setting | Before | After |
| - | - | - |
| Base URL | OpenAI default | `https://api.phaseo.app/v1` |
| API key | OpenAI key | `PHASEO_API_KEY` |
| Model | OpenAI model name | A model ID returned by `GET /v1/models` |
| Request code | Existing SDK call | Usually unchanged |

**1. Create a Phaseo API key**

Create a key with `phaseo keys create` in the [Phaseo CLI](https://phaseo.app/docs/v1/guides/integrations/phaseo-cli.md) or in [Gateway Keys](https://phaseo.app/settings/keys), then add it to every environment that runs your application.

```bash theme={null}
PHASEO_API_KEY=phaseo_v1_sk_...
```

**2. Point the client at Phaseo**

Keep the OpenAI SDK and change only its credentials and base URL first.

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

const client = new OpenAI({
  apiKey: process.env.PHASEO_API_KEY,
  baseURL: "https://api.phaseo.app/v1",
});

const response = await client.chat.completions.create({
  model: "openai/gpt-4.1-mini",
  messages: [{ role: "user", content: "Reply with: migration ready" }],
});
```

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

client = OpenAI(
    api_key=os.environ["PHASEO_API_KEY"],
    base_url="https://api.phaseo.app/v1",
)

response = client.chat.completions.create(
    model="openai/gpt-4.1-mini",
    messages=[{"role": "user", "content": "Reply with: migration ready"}],
)
```

```bash cURL theme={null}
curl https://api.phaseo.app/v1/chat/completions \
  -H "Authorization: Bearer $PHASEO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "openai/gpt-4.1-mini",
    "messages": [{"role": "user", "content": "Reply with: migration ready"}]
  }'
```

**3. Verify model IDs and endpoint coverage**

List the models available through Phaseo instead of assuming every previous alias resolves unchanged.

```bash theme={null}
curl https://api.phaseo.app/v1/models \
  -H "Authorization: Bearer $PHASEO_API_KEY"
```

Check every production workflow you rely on, including streaming, tools, structured outputs, images, audio, files, or batches. Use the [API Reference](https://phaseo.app/docs/v1/api-reference/introduction.md) to confirm the matching endpoint.

**4. Test and roll out**

Run the same representative prompts against your old and new configurations. Compare output shape, latency, token usage, errors, and cost before moving traffic gradually.

## Migration checklist

* The Phaseo key is configured in development, staging, and production.
* The client base URL is `https://api.phaseo.app/v1`.
* Every production model ID appears in `GET /v1/models`.
* Non-streaming and streaming requests pass in staging.
* Tool calls and structured outputs pass if your application uses them.
* Rollback remains a configuration-only key and endpoint change.

## Next steps

* [Routing and Fallbacks](https://phaseo.app/docs/v1/guides/routing-and-fallbacks.md)
* [Models](https://phaseo.app/docs/v1/exploring/models.md)
* [Error Handling](https://phaseo.app/docs/v1/api-reference/errors.md)


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