Vercel AI SDK setup
The Vercel AI SDK works with Claudech through its OpenAI-compatible provider, or through the Anthropic provider with a custom base URL.
Before you start#
- A Claudech API key from API keys, stored as
CLAUDECH_API_KEY. API access unlocks after your first purchase.
OpenAI-compatible provider#
TypeScript
// npm install ai @ai-sdk/openai-compatible
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { generateText } from 'ai';
const claudech = createOpenAICompatible({
name: 'claudech',
apiKey: process.env.CLAUDECH_API_KEY!,
baseURL: 'https://api.claudech.com/v1',
});
const { text } = await generateText({
model: claudech('claude-opus-5-5'),
prompt: 'Summarise the plot of Hamlet in one paragraph.',
});Streaming in a Next.js route handler#
TypeScript
// app/api/chat/route.ts
import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { streamText } from 'ai';
const claudech = createOpenAICompatible({
name: 'claudech',
apiKey: process.env.CLAUDECH_API_KEY!,
baseURL: 'https://api.claudech.com/v1',
});
export async function POST(req: Request) {
const { prompt } = await req.json();
const result = streamText({ model: claudech('claude-sonnet-5'), prompt });
return result.toTextStreamResponse();
}Anthropic provider#
If your code already uses @ai-sdk/anthropic, point it at Claudech instead:
TypeScript
// npm install ai @ai-sdk/anthropic
import { createAnthropic } from '@ai-sdk/anthropic';
const claudech = createAnthropic({
apiKey: process.env.CLAUDECH_API_KEY!,
baseURL: 'https://api.claudech.com/v1',
});Here the base URL includes /v1, because the Anthropic provider appends /messages to it.
Things to know#
- Tool calling, streaming and JSON output work with every Claudech model.
- Claudech does not offer embeddings or image generation, so
embedand image helpers need another provider.
See all integrations for other frameworks. Claudech is an independent service and is not affiliated with Vercel.