# Vercel AI SDK

> Connect with one baseURL through @ai-sdk/openai-compatible, or use the openai, anthropic and google providers for each vendor's protocol

Source: https://qd.zsopc.com/en/docs/integrations/vercel-ai-sdk

> The [Vercel AI SDK](https://ai-sdk.dev) is a TypeScript toolkit for AI apps. These steps were checked against the official docs for AI SDK 7 (npm versions as of 2026-11-13: `ai` 7.0.173, `@ai-sdk/openai-compatible` 3.0.92, `@ai-sdk/openai` 4.0.118, `@ai-sdk/anthropic` 4.0.105, `@ai-sdk/google` 4.0.121). AI SDK 7 needs Node.js 22 or later and ESM imports.

## Get an API key

Create one at [qd.zsopc.com/dashboard/keys](https://qd.zsopc.com/dashboard/keys). The examples read it from the `PLATFORM_API_KEY` environment variable.

## Recommended: the OpenAI Compatible provider

One provider reaches every text model on the platform, over `/v1/chat/completions`:

```bash
npm install ai @ai-sdk/openai-compatible
```

```ts
import { createOpenAICompatible } from "@ai-sdk/openai-compatible";
import { generateText, streamText } from "ai";

const platform = createOpenAICompatible({
  name: "xiaozhan",
  baseURL: "https://qd.zsopc.com/v1",
  apiKey: process.env.PLATFORM_API_KEY, // sent as Authorization: Bearer
  includeUsage: true,                   // token usage on streams too
});

const { text } = await generateText({
  model: platform("claude-sonnet-4-6"),
  prompt: "Introduce yourself in one sentence",
});
console.log(text);

const result = streamText({ model: platform("gpt-6.1-sol"), prompt: "Write a short poem" });
for await (const part of result.textStream) process.stdout.write(part);
```

Swap in `gemini-3.1-pro-low`, `deepseek-v4.1-flash` or any other model ID; the gateway translates the protocol for non-OpenAI models. Full list: [Models](../reference/models.md).

## Per-vendor protocols

| Provider | Create with | `baseURL` | Requests |
|---|---|---|---|
| `@ai-sdk/openai` | `createOpenAI({ baseURL, apiKey })` | `https://qd.zsopc.com/v1` | `openai("id")` uses `/v1/responses`; `openai.chat("id")` uses `/v1/chat/completions` |
| `@ai-sdk/anthropic` | `createAnthropic({ baseURL, apiKey })` | `https://qd.zsopc.com/v1` | `/v1/messages` |
| `@ai-sdk/google` | `createGoogle({ baseURL, apiKey })` | `https://qd.zsopc.com/v1beta` | `/v1beta/models/{id}:generateContent` |

```ts
import { createAnthropic } from "@ai-sdk/anthropic";

const anthropic = createAnthropic({
  baseURL: "https://qd.zsopc.com/v1", // this provider's baseURL includes /v1
  apiKey: process.env.PLATFORM_API_KEY,
});
const { text } = await generateText({ model: anthropic("claude-sonnet-4-6"), prompt: "Hello" });
```

Watch out for:

- **`@ai-sdk/openai` uses the Responses API by default.** Only some models support `/v1/responses` (see the [compatibility matrix](../reference/compatibility-matrix.md)); for the others use `openai.chat("id")`, or the OpenAI Compatible provider above.
- **`@ai-sdk/anthropic` takes a `baseURL` with `/v1`**, unlike Claude Code's `ANTHROPIC_BASE_URL=https://qd.zsopc.com` (no `/v1`). If that variable is already set for Claude Code, pass `baseURL` explicitly in code.
- **`@ai-sdk/google`**: the current docs use `createGoogle`; the old name `createGoogleGenerativeAI` still works. Its `baseURL` includes `/v1beta`.

## Troubleshooting

| Symptom | What to check |
|---|---|
| 404 | Compare `baseURL` with the table above: all three providers need the version segment (`/v1` or `/v1beta`) |
| 503 `no_channel_available` | `@ai-sdk/openai`'s default call hit a model without `/v1/responses` support — use `openai.chat()` |
| 401 `invalid_api_key` | Whether the key was copied in full (76 characters), and whether the environment variable reaches the process |
| 400 `model_not_found` | Model ID spelling — it must match [Models](../reference/models.md) exactly |
| 402 `quota_exceeded` | Balance exhausted. Every key shares one account balance — top up on the [Top up page](https://qd.zsopc.com/dashboard/billing) |

Full error reference: [Error codes](../reference/errors.md).

## Related pages

- [LangChain](./langchain.md) — Python / JS app framework
- [LiteLLM](./litellm.md) — a unified calling layer and proxy
- [Streaming](../guides/streaming.md) — SSE details, cancellation and timeouts
