Integrations
Markdown ↗

Vercel AI SDK

Server-only Chat Completions integration; reviewed AI SDK 7.

Manual setup

1. Inspect existing ai/provider versions and preserve constraints and lockfiles. For a new project the documented example is npm install ai@7 @ai-sdk/openai-compatible@3. Do not run it as an automatic major upgrade. Reviewed registry versions were ai 7.0.165 and compatible adapter 3.0.87.

2. Add the TypeScript example to server code such as src/server/zrelay.ts. Provide ZRELAY_API_KEY through runtime server secrets or a locally ignored file loaded by that runtime. Never use NEXT_PUBLIC_ or bundle this client into the browser.

3. createOpenAICompatible(...).chatModel() explicitly selects Chat Completions. Use a GPT Flex/Prime key for gpt-6.1-sol and base https://api.zrelay.net/v1. The adapter adds /chat/completions and Bearer. Calling the exported function incurs usage.

4. If @ai-sdk/openai already exists, retain it and use createOpenAI({baseURL,apiKey}).chat(model). Its default factory may use Responses. A bare model string routes through AI Gateway in the current SDK and is not this connection.

Configuration and commands

sh
npm install ai@7 @ai-sdk/openai-compatible@3
ts
import { generateText } from 'ai';
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';

export async function helloFromZrelay() {
  const apiKey = process.env.ZRELAY_API_KEY;
  if (!apiKey) throw new Error('ZRELAY_API_KEY is required');

  const zrelay = createOpenAICompatible({
    name: 'zrelay',
    baseURL: 'https://api.zrelay.net/v1',
    apiKey,
  });
  const { text } = await generateText({
    model: zrelay.chatModel('gpt-6.1-sol'),
    prompt: 'Say hello in one short sentence.',
    maxOutputTokens: 256,
    maxRetries: 0,
  });
  return text;
}

Alternative: ask an AI assistant

Copy this complete prompt into your coding assistant. It describes configuration work; installation and paid tests need your authorization.

Setup prompt
Integrate Zrelay into this project's server-side Vercel AI SDK code. Inspect the OS, runtime, package manager, installed ai/provider versions, and existing integration first. Preserve unrelated providers, settings and locked versions. Consult https://ai-sdk.dev/providers/openai-compatible-providers and https://ai-sdk.dev/providers/ai-sdk-providers/openai for the installed version. Read https://keys.zrelay.net/api/catalog and confirm the selected key's provider/pool has an enabled Chat Completions route (example: GPT, Flex or Prime, gpt-6.1-sol). Use https://api.zrelay.net/v1, createOpenAICompatible(...).chatModel(model), and generateText with maxOutputTokens: 256 and maxRetries: 0. If @ai-sdk/openai already exists, its explicit .chat(model) is suitable; do not use its default Responses factory or a bare model string. Read ZRELAY_API_KEY only inside server code; tell me how to enter it locally or in server secrets. Never request, inspect, print, commit, or expose the real credential in chat/browser code. Ask for consent before installing/upgrading packages or making any paid inference request. Implement the smallest integration and use existing offline type/lint checks without invoking generation. Report changed files, configuration evidence, checks actually run, and untested runtime/streaming/tool behavior.

Limits and verification

Use maxOutputTokens:256 and maxRetries:0 within the enforced 4096 output ceiling. process.env assumes a Node-compatible server; adapt secret access for other runtimes. Installed adapter major compatibility, streaming and tool loops require separate checks.

These recipes were reviewed against documentation and public catalog data. No client installation, authenticated request, paid inference, streaming or tool loop was executed. Validate configuration first; a later short text test does not establish complete agent compatibility.

Recheck the live catalog and your key’s provider/pool. The reviewed examples have 128000 input and 4096 output maxima unless a client limitation above prevents controlling the request. Never print, log or commit credentials.

Official sources

Documentation checked 2026-11-09; mutable sources can differ from your installed version.

https://ai-sdk.dev/providers/openai-compatible-providers

https://ai-sdk.dev/providers/ai-sdk-providers/openai

https://keys.zrelay.net/api/catalog

https://ai-sdk.dev/docs/reference/ai-sdk-core/generate-text

https://raw.githubusercontent.com/vercel/ai/main/packages/openai-compatible/src/openai-compatible-provider.ts

https://raw.githubusercontent.com/vercel/ai/main/packages/openai-compatible/src/chat/openai-compatible-chat-language-model.ts

https://registry.npmjs.org/ai/latest

https://registry.npmjs.org/@ai-sdk%2fopenai-compatible/latest

Questions about your integration? support@zrelay.net