Vercel AI SDK with 6bee.ai
The AI SDK has a provider for OpenAI-compatible APIs. Create it once with the 6bee.ai base URL and use it like any other model.
Before you start
- A Node.js project.
- Create an account with a verified email address, add prepaid balance, then create a key on the console's API keys page. Keep the key secret.
- Model IDs are listed in the console and returned by
GET https://api.6bee.ai/v1/models. Replace<model id>with one of them.
Install and create the provider
npm install ai @ai-sdk/openai-compatible import { createOpenAICompatible } from '@ai-sdk/openai-compatible';
import { streamText } from 'ai';
const sixbee = createOpenAICompatible({
name: 'sixbee',
baseURL: 'https://api.6bee.ai/v1',
apiKey: process.env.SIXBEE_API_KEY,
});
const result = streamText({
model: sixbee('<model id>'),
prompt: 'Explain this stack trace',
});
for await (const text of result.textStream) process.stdout.write(text); Good to know
- Call the API from server code only: a route handler, a server action or a script. A key in browser code is public.
- An account runs 2 requests at a time. If your app serves several users from one key, queue the calls or expect 429.
- On 429, wait for the number of seconds in the
Retry-Afterheader.
- Context
- Input plus output up to the model’s window: 128K to 1M tokens, depending on the model.
- Output
- max_tokens up to the model’s output cap: 16,384 to 131,072, depending on the model. Larger values are lowered to the cap, not rejected. If omitted: 8,192 to 32,768.
- Input tokens
- 1,000,000 uncached tokens per rolling minute. Cache hits don’t count.
- Requests
- 60 per minute.
- Concurrency
- 2 requests at a time.
- Request body
- Up to 8 MiB. n must be 1.
Troubleshooting
- HTTP 401
- The key is missing or wrong. Copy it again from the console, without spaces or quotes.
- Model not found
- The model ID does not match. List the valid IDs with
GET /v1/modelsor check the console. - HTTP 429
- You are over a per-account limit (requests, input tokens or concurrency). The
Retry-Afterheader says how long to wait. - HTTP 400 on long sessions
- The request no longer fits the model’s context window. Compact or clear the conversation, or switch to a model with a larger window.
- Request rejected for balance
- Each request first reserves its input plus
max_tokensof output. Top up, or lowermax_tokens.