> ## 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 LLM Gateway

> Move from LLMGateway to Phaseo Gateway with an OpenAI-compatible endpoint swap, model-ID verification, and staged rollout validation.

If your app already uses LLM Gateway through an OpenAI-compatible client, most teams can keep their request payloads unchanged and migrate by replacing only the gateway boundary first.

## What changes

| Setting | Before | After |
| - | - | - |
| Base URL | `https://api.llmgateway.io/v1` | `https://api.phaseo.app/v1` |
| API key | `LLM_GATEWAY_API_KEY` | `PHASEO_API_KEY` |
| Model aliases | Existing gateway aliases | Verify against `GET /v1/models` or normalize in one boundary layer |
| Request payload | Existing OpenAI-compatible request | Keep unchanged for the first migration pass |

## Before you start

* Your existing LLM Gateway endpoint and API key configuration.
* `PHASEO_API_KEY` added to local, staging, and production environments.
* A baseline sample of output quality, latency, and error rate.

## 1) Inventory integration points

Identify the exact files that create and configure your LLM Gateway client.

* Locate all `LLM_GATEWAY_*` env var usage.
* Find all base URL references in runtime config.
* Capture the currently active model IDs and fallback chains.
* Note any shared prompt defaults, provider allow/deny logic, or parameter presets that should move into Gateway presets.

## 2) Switch endpoint and credentials

Keep payloads unchanged first. Start with a pure endpoint and key migration to reduce risk.

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

const before = new OpenAI({
  apiKey: process.env.LLM_GATEWAY_API_KEY,
  baseURL: "https://api.llmgateway.io/v1",
});
```

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

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

```bash cURL theme={null}
curl -s "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":"Hello"}]
  }'
```

## 3) Validate model compatibility

Query the Phaseo model catalog and verify every model used in production.

If your current setup uses unprefixed aliases such as `gpt-4o`, normalize them at one boundary layer instead of changing every caller.

If your current gateway layer also centralizes request defaults or provider restrictions, map that behavior into [Presets](https://phaseo.app/docs/v1/guides/presets.md) and [Routing and Fallbacks](https://phaseo.app/docs/v1/guides/routing-and-fallbacks.md) during the migration instead of re-implementing it per caller.

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

## 4) LLMGateway migration checklist

* All `LLM_GATEWAY_*` env vars mapped or removed.
* Base URL updated to `https://api.phaseo.app/v1`.
* `PHASEO_API_KEY` configured in all deployment environments.
* Production model IDs verified against `/v1/models`.
* One non-streaming and one streaming request validated in staging.
* Invalid-key and invalid-model failure handling rechecked.
* Shared prompt/routing defaults moved into presets where appropriate.
* Generation lookups rechecked through `GET /v1/generations?id=<request_id>` so failed requests can be replayed from the stored `replay_request` payload when `replay_supported=true`.

## 5) Validate and roll out

1. Run your golden prompt suite and compare quality, latency, and cost metrics to baseline.
2. Confirm failed staging requests can be recovered through the replay payload returned by `GET /v1/generations`.
3. Release behind a canary flag and move from a low percentage of traffic to full traffic once stable.
4. Observe production metrics for at least one release cycle before removing old configuration.

## Validation commands

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

Then:

* Run one non-streaming and one streaming request in staging.
* Replay your golden prompts and compare to baseline.

## Next steps

* [Migration from OpenRouter](https://phaseo.app/docs/v1/migration-guides/from-openrouter.md)
* [Migrating from Vercel AI Gateway](https://phaseo.app/docs/v1/migration-guides/from-vercel.md)
* [Quickstart](https://phaseo.app/docs/v1/quickstart.md)


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