Skip to content
Need an API key for this client? One token for Claude, GPT-6.2, Gemini 4 & DeepSeek V4 — top up via USDT or Alipay

Connect Vercel AI SDK to byesu API ​

Use the Vercel AI SDK (ai in TypeScript / Next.js / Node.js) with byesu to stream text, extract Zod-validated structured objects, and run tool-calling agents across Claude, GPT, Gemini, DeepSeek, and Grok using a single pay-as-you-go API key.

Quick configuration

  • @ai-sdk/openai baseURL: https://byesu.com/v1 (calls any vendor model with one provider instance)
  • @ai-sdk/anthropic baseURL: https://byesu.com/v1 (include /v1 — @ai-sdk/anthropic appends /messages, unlike Claude Code CLI!)
  • Environment variable: BYESU_API_KEY=sk-... (created in the default auto group)
  • Recommended models: claude-sonnet-5-5, claude-opus-5-5, gpt-6.2-sol, deepseek-v4-pro, gemini-4-argon

Prerequisites ​

  1. Create an sk-... token in the byesu Console under the default auto group (see Choosing a Group).
  2. Install the core AI SDK, provider packages, and Zod:
bash
npm install ai @ai-sdk/openai @ai-sdk/anthropic zod
  1. Add your key to .env.local (Next.js) or export it in your shell:
bash
BYESU_API_KEY="sk-your-byesu-token"

Option 1: @ai-sdk/openai (Multi-Vendor streamText & generateObject) ​

Point createOpenAI at https://byesu.com/v1 to call Claude, GPT, DeepSeek, Gemini, and Grok models without creator/ model slug prefixes.

Use byesu.chat(modelId) when routing non-OpenAI models (claude-sonnet-5-5, deepseek-v4-pro, gemini-4-argon) through /v1/chat/completions, or byesu('gpt-6.2-sol') when targeting OpenAI /v1/responses in AI SDK v5+:

typescript
import { createOpenAI } from '@ai-sdk/openai';
import { streamText, generateObject } from 'ai';
import { z } from 'zod';

const byesu = createOpenAI({
  baseURL: 'https://byesu.com/v1',
  apiKey: process.env.BYESU_API_KEY,
});

// 1. Stream tokens from Claude, GPT, DeepSeek, or Gemini
export async function streamReleaseNotes(diff: string) {
  const result = streamText({
    model: byesu.chat('claude-sonnet-5-5'), // swap to 'gpt-6.2-sol', 'deepseek-v4-pro', 'gemini-4-argon'
    prompt: `Write concise engineering release notes for this diff:\n\n${diff}`,
  });

  for await (const chunk of result.textStream) {
    process.stdout.write(chunk);
  }
}

// 2. Type-safe structured extraction with Zod
export async function auditPullRequest(diff: string) {
  const { object } = await generateObject({
    model: byesu.chat('gpt-6.2-sol'),
    schema: z.object({
      riskLevel: z.enum(['low', 'medium', 'high']),
      summary: z.string(),
      blockingIssues: z.array(z.string()),
    }),
    prompt: `Audit this pull request diff for production risks:\n\n${diff}`,
  });

  return object;
}

In a Next.js App Router endpoint (app/api/chat/route.ts), raise maxDuration so deep-reasoning models (gpt-6.2-sol, claude-opus-5-5, deepseek-v4-pro) never get cut off mid-thought:

typescript
import { createOpenAI } from '@ai-sdk/openai';
import { streamText } from 'ai';

export const maxDuration = 120;

const byesu = createOpenAI({
  baseURL: 'https://byesu.com/v1',
  apiKey: process.env.BYESU_API_KEY,
});

export async function POST(req: Request) {
  const { messages } = await req.json();
  const result = streamText({
    model: byesu.chat('claude-sonnet-5-5'),
    messages,
  });
  return result.toDataStreamResponse();
}

Option 2: @ai-sdk/anthropic (Native /v1/messages & 0.1x Prompt Caching) ​

When building Claude-first agents with large system instructions, repository context, or native thinking blocks, use @ai-sdk/anthropic:

Critical baseURL rule for @ai-sdk/anthropic

@ai-sdk/anthropic's default baseURL is https://api.anthropic.com/v1 because the package only appends /messages (not /v1/messages). Unlike Claude Code CLI or Python anthropic.Anthropic — which take https://byesu.com — @ai-sdk/anthropic expects https://byesu.com/v1. Omitting /v1 sends requests to https://byesu.com/messages and returns 404.

byesu forwards Anthropic cache_control breakpoints unchanged, so repeated prefixes (~1,024+ tokens) bill cache reads as low as 0.1x (see Prompt Caching):

typescript
import { createAnthropic } from '@ai-sdk/anthropic';
import { streamText } from 'ai';

const anthropic = createAnthropic({
  baseURL: 'https://byesu.com/v1', // @ai-sdk/anthropic appends /messages -> /v1/messages
  apiKey: process.env.BYESU_API_KEY,
});

export async function askWithCachedContext(repoSpec: string, userQuestion: string) {
  const result = streamText({
    model: anthropic('claude-opus-5-5'),
    messages: [
      {
        role: 'system',
        content: repoSpec, // Static 1,024+ token prefix kept byte-identical across turns
        providerOptions: {
          anthropic: { cacheControl: { type: 'ephemeral' } },
        },
      },
      {
        role: 'user',
        content: userQuestion,
      },
    ],
  });

  const text = await result.text;
  const meta = await result.providerMetadata;
  console.log('Anthropic cache usage:', meta?.anthropic);
  // { cacheCreationInputTokens: ..., cacheReadInputTokens: ... }
  return text;
}

Production Engineering Notes ​

  • Omit legacy sampling overrides on Claude 5.5 & GPT-6.2: Anthropic API version 2026-10-21 rejects temperature, topP, and topK with HTTP 400, and GPT-6.2 reasoning models also reject fixed sampling overrides. Leave temperature and topP unset in streamText / generateObject (Claude 400 sampling fix).
  • Dedicated token groups: The default auto group covers Claude, GPT, Gemini, DeepSeek, and Grok. To call glm-5.3, kimi-k3, or image generation models (gpt-image-2, gemini-3.1-flash-image-ultra), create dedicated tokens in the Glm, Kimi, or media group.
  • Pay-as-you-go billing: Text and code usage is metered per token with no monthly subscription; check live per-model rates in the byesu Console after sign-in.

Troubleshooting & Benchmarks ​

Got a problem? Contact support or join our group.