Vercel AI SDK

Vercel's AI SDK is the standard toolkit for building AI features in TypeScript. Point its @ai-sdk/openai-compatible provider at Synthorai and every model in the catalog becomes available behind one key, with the Claude, GPT, Gemini and open-weight families side by side.

Before you start

Create an API key at Console → API Keys. Copy it immediately - it is only shown once.

Step 1 - Install the packages

npm i ai @ai-sdk/openai-compatible

Synthorai speaks the OpenAI Chat Completions wire format, so no Synthorai-specific package is needed - the official OpenAI-compatible provider is the supported path.

Step 2 - Create the provider instance

import { createOpenAICompatible } from '@ai-sdk/openai-compatible';

const synthorai = createOpenAICompatible({
  name: 'synthorai',
  baseURL: 'https://synthorai.io/v1',
  apiKey: process.env.SYNTHORAI_API_KEY,
});

The name value is a label used in traces and error messages; it does not affect routing. Routing is decided by baseURL and the model ID you pass in.

⚠

The base URL must end in /v1. The provider appends paths such as /chat/completions so a base URL without it resolves to the wrong path.

Step 3 - Generate and stream text

import { generateText } from 'ai';

const { text } = await generateText({
  model: synthorai('claude-sonnet-5-5'),
  prompt: 'Tell me about yourself in one sentence.',
});

console.log(text);

The first argument is a model ID from the catalog. Streaming works through the same provider instance with no extra configuration:

import { streamText } from 'ai';

const result = streamText({
  model: synthorai('claude-sonnet-5-5'),
  prompt: 'Write a short haiku about routing.',
});

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

Picking a model

Any model ID in the catalog works. These are reasonable defaults:

ParameterTypeDescription
claude-opus-5-5agenticA strong choice for long agentic sessions and code editing.
gpt-5.4reasoningGeneral-purpose reasoning across mixed workloads.
gpt-5.4-minifastFast and inexpensive - good for classification and short completions.
deepseek-v4-flashcheapestAmong the least expensive models in the catalog - good for high-volume work.

Using the Anthropic surface instead

The same key also serves the Anthropic Messages format at a different path, which the AI SDK reaches through its Anthropic provider. Use that when you want Anthropic-native features, and the OpenAI-compatible provider above for everything else.

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

const synthoraiAnthropic = createAnthropic({
  baseURL: 'https://synthorai.io/v1',
  apiKey: process.env.SYNTHORAI_API_KEY,
});
⚠

Note the difference from the raw Anthropic SDK: that one takes the host root and appends /v1/messages itself, while the AI SDK's Anthropic provider expects a prefix that already contains /v1. Passing the bare host here resolves to the wrong path.

Troubleshooting

404 on every call. The base URL must end in /v1. The provider appends paths such as /chat/completions so a base URL without it resolves to the wrong path.

401 Unauthorized. The environment variable is read at module load, so a key exported after the process started will not be picked up. Restart the process after setting it.

Model not found. Model IDs are case-sensitive and must match the catalog exactly. List what your key can reach with: curl https://synthorai.io/v1/models -H "Authorization: Bearer $SYNTHORAI_API_KEY"

Every model ID and its price is listed in the model price comparison.