UNPKG

@tokenrouter/sdk

Version:

TypeScript/JavaScript SDK for TokenRouter - Intelligent LLM Routing API

108 lines 2.66 kB
/** * TypeScript type definitions for TokenRouter SDK */ export interface ClientOptions { apiKey?: string; baseUrl?: string; timeout?: number; maxRetries?: number; headers?: Record<string, string>; } export interface UsageDetails { cached_tokens?: number; audio_tokens?: number; reasoning_tokens?: number; accepted_prediction_tokens?: number; rejected_prediction_tokens?: number; } export interface Usage { prompt_tokens: number; completion_tokens: number; total_tokens: number; prompt_tokens_details?: UsageDetails; completion_tokens_details?: UsageDetails; } export interface ChatMessage { role: 'system' | 'user' | 'assistant' | 'function' | 'tool'; content?: any; name?: string; function_call?: FunctionCall; tool_calls?: ToolCall[]; } export interface FunctionCall { name: string; arguments: string; } export interface ToolCall { id: string; type: 'function'; function: FunctionCall; } export interface ChatCompletionChoice { index: number; message: ChatMessage; finish_reason?: string | null; logprobs?: any; } export interface ChatCompletion { id: string; object: string; created: number; model: string; choices: ChatCompletionChoice[]; usage?: Usage; system_fingerprint?: string; service_tier?: string; cost_usd?: number; latency_ms?: number; routed_model?: string; routed_provider?: string; prompt_type?: string; complexity?: number; } export interface ChatCompletionChunk { id: string; object: string; created: number; model: string; choices: Array<{ index: number; delta: Partial<ChatMessage>; finishReason?: string; }>; usage?: Usage; } export type RoutingMode = 'cost' | 'quality' | 'latency' | 'balanced'; export interface ChatCompletionRequest { messages: ChatMessage[]; model?: string; mode?: RoutingMode; model_preferences?: string[]; max_completion_tokens?: number | null; max_tokens?: number | null; response_format?: Record<string, any> | null; stream?: boolean | null; temperature?: number | null; tool_choice?: string | ToolChoice | null; tools?: Tool[] | null; user?: string | null; [key: string]: any; } export interface Tool { type: 'function'; function: { name: string; description?: string; parameters?: any; }; } export interface ToolChoice { type: 'function'; function: { name: string; }; } export interface ResponseFormat { type: 'text' | 'json_object'; } //# sourceMappingURL=types.d.ts.map