Skip to main content
The @auriko/sdk package provides a typed TypeScript client for the Auriko 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

You can also use the RoutingOptions type with enum constants for IDE autocomplete:
All routing fields:
FieldTypeDescription
optimizeOptimizeStrategy: "cost", "cost-focus", "ttft", "ttft-focus", "tps", "tps-focus", "balanced"
weightsRoutingWeightsCustom scoring weights: cost, ttft, throughput. Overrides preset.
ttft_percentileMetricPercentileTTFT scoring percentile: "p50" (default) or "p95"
throughput_percentileMetricPercentileThroughput scoring percentile: "p50" (default) or "p95"
max_cost_per_1mnumberMax $ per 1M tokens (average of input + output)
max_ttft_msnumberMax TTFT in milliseconds
min_throughput_tpsnumberMin throughput in tokens/sec
providersstring[]Allowlist of providers
exclude_providersstring[]Blocklist of providers
preferstringPreferred provider (soft preference)
modeMode"pool" (default) or "fallback"
allow_fallbacksbooleanEnable fallback on failure
max_fallback_attemptsnumberMax fallback retries
data_policyDataPolicy"none", "no_training", "zdr"
only_byokbooleanOnly use BYOK providers
only_platformbooleanOnly use platform providers
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 the reasoning_effort parameter:
You can also pass provider-specific parameters through extensions:
See Extensions and Thinking for provider details and streaming thinking output.

Request metadata

Attach metadata to requests for tracking and analytics:
Valid metadata fields: 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

After consuming all chunks, access stream-level metadata:
Close a stream manually with stream.close().
Routing metadata, usage, and response headers are available only after consuming all chunks.
See Streaming Guide for full patterns including tool call streaming.

Tool calling

See Tool Calling Guide for multi-turn tool conversations.

Create responses

Send a request using the OpenAI Response API format:

Stream Response API events

See the TypeScript SDK Reference for all parameters and event types.

Read response headers

Every response and error includes a responseHeaders object with typed accessors:
PropertyHeaderType
requestIdx-request-idstring | undefined
rateLimitRemainingx-ratelimit-remaining-requestsnumber | undefined
rateLimitLimitx-ratelimit-limit-requestsnumber | undefined
rateLimitResetx-ratelimit-reset-requestsstring | undefined
creditsBalanceMicrodollarsx-credits-balance-microdollarsnumber | undefined
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

The Usage object on every response carries optional detail breakdowns:
FieldSub-fieldsType
prompt_tokens_detailscached_tokensnumber | undefined
completion_tokens_detailsreasoning_tokensnumber | undefined
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:
See Error Handling Guide for retry patterns.

Use identity and model discovery APIs

Query identity and model information:

Model listing choices

MethodReturnsUse when
list()All models with provider availability, pricing, data policyYou need the full model catalog
retrieve(modelId)Single model: provider availability, pricing, data policyYou have a model ID and need its details
listRegistry()Flat list: id, family, display_nameYou need a quick model ID lookup
listDirectory()Rich detail: provider entries, context windows, capabilities, pricing tiersYou need to compare providers or check capabilities
listProviders()Provider catalog: display name, description, data policyYou need to see available providers
See the TypeScript SDK Reference for the complete API.

SDK scope

The Auriko 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 @auriko/ai-sdk-provider instead.

Use TypeScript types

The SDK provides typed responses, errors, and routing configuration. Import types directly:

Node.js, Deno, and Browser

The SDK works in multiple environments:

Node.js

Deno

Browser (with bundler)

Never expose your API key in client-side code. Use a backend proxy instead.