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
The Vercel AI SDK 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:
ai7.0.173,@ai-sdk/openai-compatible3.0.92,@ai-sdk/openai4.0.118,@ai-sdk/anthropic4.0.105,@ai-sdk/google4.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. 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:
npm install ai @ai-sdk/openai-compatible
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.
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 |
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/openaiuses the Responses API by default. Only some models support/v1/responses(see the compatibility matrix); for the others useopenai.chat("id"), or the OpenAI Compatible provider above.@ai-sdk/anthropictakes abaseURLwith/v1, unlike Claude Code'sANTHROPIC_BASE_URL=https://qd.zsopc.com(no/v1). If that variable is already set for Claude Code, passbaseURLexplicitly in code.@ai-sdk/google: the current docs usecreateGoogle; the old namecreateGoogleGenerativeAIstill works. ItsbaseURLincludes/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 exactly |
402 quota_exceeded | Balance exhausted. Every key shares one account balance — top up on the Top up page |
Full error reference: Error codes.