Package Exports
- @sdkrouter/client
Readme
@sdkrouter/client
TypeScript SDK for SDKRouter — unified API gateway for LLM and Audio providers.
Install
npm install @sdkrouter/clientHow it works
SDKRouter proxies requests to multiple AI providers (OpenAI, Anthropic, Google, etc.) through a single API. The client handles authentication, routing, and provides a unified interface for:
- Chat completions — buffered and streaming, with tool calls support
- Text-to-Speech — buffered (full audio) and streaming (chunked playback)
- Speech-to-Text — audio file transcription via Whisper-compatible API
- Model aliases — tier-based routing (
@standard,@smart,@fast) instead of hardcoded model names
Quick Start
import { SDKRouterClient } from '@sdkrouter/client';
const client = new SDKRouterClient({
apiKey: 'your-api-key',
});
// Chat
const response = await client.chat.create({
model: '@standard',
messages: [{ role: 'user', content: 'Hello' }],
});
// Streaming chat
for await (const chunk of client.chat.stream({
model: '@smart',
messages: [{ role: 'user', content: 'Hello' }],
})) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
}
// Text-to-Speech
const { audioEl } = await client.audio.speech({
model: '@balanced',
input: 'Hello world',
voice: 'nova',
});
audioEl.play();
// Speech-to-Text
const result = await client.audio.transcribe({
file: audioBlob,
model: '@fast',
});
console.log(result.text);Model Aliases
Instead of hardcoding provider-specific model names, use tier-based aliases that resolve server-side:
import { Model, AudioModel } from '@sdkrouter/client';
// LLM
Model.standard() // "@standard"
Model.smart({ vision: true, code: true }) // "@smart+vision+code"
// Audio
AudioModel.balanced({ streaming: true }) // "@balanced+streaming"Configuration
const client = new SDKRouterClient({
apiKey: 'your-api-key',
llmUrl: 'https://...', // default: https://llm.sdkrouter.com/v1
audioUrl: 'https://...', // default: https://audio.sdkrouter.com
env: 'development', // use localhost URLs for local dev
timeout: 60000,
});License
MIT