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: 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. The examples read it from the PLATFORM_API_KEY environment variable.

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#

ProviderCreate withbaseURLRequests
@ai-sdk/openaicreateOpenAI({ baseURL, apiKey })https://qd.zsopc.com/v1openai("id") uses /v1/responses; openai.chat("id") uses /v1/chat/completions
@ai-sdk/anthropiccreateAnthropic({ baseURL, apiKey })https://qd.zsopc.com/v1/v1/messages
@ai-sdk/googlecreateGoogle({ 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/openai uses the Responses API by default. Only some models support /v1/responses (see the compatibility matrix); 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#

SymptomWhat to check
404Compare 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_keyWhether the key was copied in full (76 characters), and whether the environment variable reaches the process
400 model_not_foundModel ID spelling — it must match Models exactly
402 quota_exceededBalance exhausted. Every key shares one account balance — top up on the Top up page

Full error reference: Error codes.

  • LangChain — Python / JS app framework
  • LiteLLM — a unified calling layer and proxy
  • Streaming — SSE details, cancellation and timeouts