@arbytra/sdk package provides a typed TypeScript client for the Arbytra API.
Full SDK Reference
Complete API reference with all types, parameters, and examples
Installation
Get started
Configure
API Key
Base URL
Timeout
Retries
Create chat completions
Basic request
Send a chat completion request:With routing options
RoutingOptions type with enum constants for IDE autocomplete:
See Advanced Routing for detailed strategy guides.
Multi-model routing
Route a request across multiple models. The router picks the best option based on your routing strategy:model and gateway.models are mutually exclusive. Specify exactly one. Passing both raises BadRequestError.Reasoning effort
Enable extended reasoning for complex tasks using thereasoning_effort parameter:
extensions:
Request metadata
Attach metadata to requests for tracking and analytics:user_id, tags (list), trace_id, and custom_fields (object for arbitrary key-value pairs). See the TypeScript SDK Reference for field constraints.
Stream responses
stream.close().
Routing metadata, usage, and response headers are available only after consuming all chunks.
Tool calling
Create responses
Send a request using the OpenAI Response API format:Stream Response API events
Read response headers
Every response and error includes aresponseHeaders object with typed accessors:
Error objects also carry
responseHeaders. Use e.responseHeaders.requestId when filing support tickets to correlate with server logs.
See the TypeScript SDK Reference for the complete ResponseHeaders API.
Read token usage
TheUsage object on every response carries optional detail breakdowns:
Availability depends on the provider.
completion_tokens_details.reasoning_tokens is present for OpenAI o-series, DeepSeek, xAI, and Google Gemini. It’s undefined for providers that don’t report reasoning token counts (Anthropic, Moonshot, Fireworks).
See Check reasoning token availability for the full breakdown.
Handle errors
Catch typed exceptions:Use identity and model discovery APIs
Query identity and model information:Model listing choices
See the TypeScript SDK Reference for the complete API.
SDK scope
The Arbytra SDK covers: inference (chat completions and the Response API, both with routing), identity, and model discovery. For full platform operations, use the REST API directly. If you use the Vercel AI SDK, see@arbytra/ai-sdk-provider instead.