Cmoso

Vercel AI SDK Setup

The Vercel AI SDK is a TypeScript toolkit for building AI apps. This guide connects it to the API in about 3 minutes.

1. Create an API key

  1. Sign up on the registration page.
  2. In the console, open the API token page, create a token, and copy the key. It starts with sk-.

2. Connect the Vercel AI SDK

Install the OpenAI-compatible provider:

npm install ai @ai-sdk/openai-compatible

Create a provider instance and call a model:

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

const gateway = createOpenAICompatible({
  name: 'gateway',
  baseURL: 'https://api.cmoso.com/v1',
  apiKey: process.env.GATEWAY_API_KEY,
  includeUsage: true,
});

const { text } = await generateText({
  model: gateway('claude-sonnet-5-5'),
  prompt: 'Say hello in one sentence.',
});
console.log(text);

streamText, tool calling and reasoning work the same way. Pass providerOptions: { gateway: { reasoningEffort: 'high' } } to set the reasoning effort.

3. Pick a model and test

Run the script with GATEWAY_API_KEY set. It prints the reply.

Popular model IDs: claude-sonnet-5-5, gpt-5.4, gemini-3.1-flash-lite, deepseek-v4-pro, qwen3.5-plus.

Troubleshooting

  • 401 Unauthorized: the API key is wrong or disabled. Copy it again from the console.
  • Model not found: check the model ID spelling. IDs are case-sensitive.
  • Connection error: check that the base URL ends with /v1 and has no trailing slash.