@byorouter/ai-sdk
v0.1.0
Published
BYORouter provider for Vercel AI SDK
Maintainers
Readme
@byorouter/ai-sdk
BYORouter provider for the Vercel AI SDK.
Installation
npm install @byorouter/ai-sdk aiUsage
import { createBYORouter } from '@byorouter/ai-sdk';
import { streamText } from 'ai';
// Create a BYORouter provider with the user's connection
const byorouter = createBYORouter({
apiKey: process.env.BYOROUTER_API_KEY!,
connectionId: 'conn_xxx', // from the Connect flow
});
// Use any model the user has connected
const result = await streamText({
model: byorouter('openai/gpt-4o'),
prompt: 'Hello!',
});
for await (const chunk of result.textStream) {
process.stdout.write(chunk);
}Model Format
Models are specified in provider/model format:
openai/gpt-4oopenai/gpt-4o-minianthropic/claude-3-5-sonnet-20241022google/gemini-proopenrouter/anthropic/claude-3.5-sonnet
Options
| Option | Type | Required | Description |
|--------|------|----------|-------------|
| apiKey | string | Yes | Your BYORouter API key (sk_live_xxx) |
| connectionId | string | Yes | The user's connection ID (conn_xxx) |
| baseURL | string | No | API base URL (default: https://api.byorouter.com) |
License
MIT
