> ## 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 Vercel AI Gateway

> Replace Vercel AI Gateway routing with Phaseo Gateway while preserving AI SDK or OpenAI-compatible application behavior.

If you already use Vercel AI Gateway through the Vercel AI SDK or an OpenAI-compatible client, the safest migration path is to keep your app logic the same and swap only the provider boundary first.

## What changes

| Setting | Before | After |
| - | - | - |
| Gateway URL | `https://ai-gateway.vercel.sh/v1` | `https://api.phaseo.app/v1` |
| API key | Vercel AI Gateway key | `PHASEO_API_KEY` |
| AI SDK provider | Existing provider setup | `@phaseo/ai-sdk-provider` when using the AI SDK directly |
| Application flow | Existing generation logic | Keep unchanged for the first migration pass |

## Before you start

* Current Vercel AI Gateway base URL and key configuration.
* `PHASEO_API_KEY` available in local, staging, and production environments.
* A small prompt set or integration suite that covers non-streaming, streaming, and any tool-calling paths you rely on.

## 1) Document your current gateway boundary

Find the single place where your app creates model providers or API clients. That is the preferred migration point.

* Locate the provider/client factory used by your app.
* List the model IDs currently used in production.
* Record retry, timeout, and fallback defaults.
* Note whether both edge and server runtimes need the same config change.
* Identify any shared prompt or parameter defaults that should become Gateway presets instead of remaining embedded in individual AI SDK call sites.

## 2) Swap endpoint and key

For most OpenAI-compatible client paths, this is a base URL and key replacement only.

```typescript TypeScript theme={null}
// OpenAI-compatible client before
import OpenAI from "openai";

const before = new OpenAI({
  apiKey: process.env.VERCEL_AI_GATEWAY_API_KEY,
  baseURL: "https://ai-gateway.vercel.sh/v1",
});
```

```typescript TypeScript theme={null}
// OpenAI-compatible client after
import OpenAI from "openai";

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

```typescript TypeScript theme={null}
// Official Phaseo provider for the Vercel AI SDK
import { generateText } from "ai";
import { createPhaseo } from "@phaseo/ai-sdk-provider";

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

const { text } = await generateText({
  model: phaseo("openai/gpt-4.1-mini"),
  prompt: "Generate a migration checklist.",
});
```

```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) Confirm behavior parity

Run the same prompt set against old and new paths, then compare latency, output format, and token usage.

* Verify non-streaming text generation.
* Verify streaming chunk handling through the same code path your app uses in production.
* Verify tool-calling paths if your app depends on them.
* Confirm application-level error mapping is unchanged.
* Move durable routing defaults and provider restrictions into [Presets](https://phaseo.app/docs/v1/guides/presets.md) or [Routing and Fallbacks](https://phaseo.app/docs/v1/guides/routing-and-fallbacks.md) instead of rebuilding them ad hoc in every model factory.

## 4) Vercel AI SDK and gateway checklist

Use this checklist before promoting traffic:

* Base URL updated to `https://api.phaseo.app/v1`.
* `PHASEO_API_KEY` configured in every runtime that previously used the Vercel gateway key.
* Official `@phaseo/ai-sdk-provider` wired in if your app uses the Vercel AI SDK directly.
* Primary AI SDK text generation path passes in staging.
* One app-level streaming test passes unchanged.
* Tool-calling and structured-output flows rechecked if used.
* Old/new outputs compared for a small prompt suite.
* Rollback remains possible through config or feature-flag change only.
* 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) Release plan for low risk

1. Ship behind a feature flag or percentage rollout.
2. Start with internal traffic or a very small production slice.
3. Monitor latency, error rate, and token/cost drift.
4. Keep both configs available for at least one release window.

## 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 your app's primary text-generation integration test.
* Run one streaming test in staging.
* Compare old/new outputs for your top prompts before full rollout.

## Next steps

* [Migration from OpenRouter](https://phaseo.app/docs/v1/migration-guides/from-openrouter.md)
* [Quickstart](https://phaseo.app/docs/v1/quickstart.md)
* [Examples](https://phaseo.app/docs/v1/guides/examples.md)


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