Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.auriko.ai/llms.txt

Use this file to discover all available pages before exploring further.

TypeScript SDK Reference

See the TypeScript SDK Guide for usage examples and getting started.

Client

Initialize a client with configuration options:
import { Client } from "@auriko/sdk";

const client = new Client({
  apiKey: "ak_...",                   // or AURIKO_API_KEY env var
  baseUrl: "https://api.auriko.ai/v1",  // default
  timeout: 60_000,                       // ms, default 60s
  maxRetries: 2,                         // default 2 (0 disables)
});

Resources

ResourceMethods
client.chat.completionscreate(params)
client.responsescreate(params)
client.modelslist(), retrieve(modelId), listDirectory(), listRegistry(), listProviders()
client.meget()

Chat Completions

client.chat.completions.create(params)

Creates a chat completion. Supports single-model and multi-model routing.
// Non-streaming
const response = await client.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: "Hello!" }],
  max_tokens: 100,
});

// Streaming
const stream = await client.chat.completions.create({
  model: "gpt-4o",
  messages: [{ role: "user", content: "Hello!" }],
  stream: true,
});

Parameters

ParameterTypeRequiredDescription
messagesArray<Message>YesConversation messages (non-empty)
modelstringOne of model/gateway.modelsModel ID
streambooleanNoEnable streaming (default: false)
temperaturenumberNoSampling temperature (0–2)
max_tokensnumberNoMax tokens to generate
max_completion_tokensnumberNoMax completion tokens (alias for max_tokens)
reasoning_effort'low' | 'medium' | 'high' | 'xhigh' | 'max' | 'off'NoReasoning effort for supported models — translated to provider-native control (see guide)
top_pnumberNoNucleus sampling (0–1)
frequency_penaltynumberNoFrequency penalty (-2 to 2)
presence_penaltynumberNoPresence penalty (-2 to 2)
top_knumberNoTop-K sampling
min_pnumberNoMin-P sampling (0–1)
top_anumberNoTop-A sampling (0–1)
repetition_penaltynumberNoRepetition penalty
stopstring | string[]NoStop sequences
seednumberNoDeterministic sampling seed
nnumberNoNumber of completions to generate
toolsTool[]NoFunction calling tool definitions
tool_choicestring | objectNoTool selection: "auto", "none", "required", or function spec
parallel_tool_callsbooleanNoAllow parallel function calls
response_formatobjectNoOutput format (e.g., { type: "json_object" })
stream_optionsobjectNoStream options (e.g., { include_usage: true })
logprobsbooleanNoReturn log probabilities
top_logprobsnumberNoNumber of top logprobs per token (0–20)
logit_biasRecord<string, number>NoToken bias adjustments
userstringNoEnd-user identifier
gatewayGatewayOptions | Record<string, unknown>NoGateway directives: routing, metadata, models
extensionsExtensions | Record<string, unknown>NoProvider-specific extensions (provider passthrough)
extra_bodyRecord<string, unknown>NoAdditional body fields (merged last except stream; gateway-aware one-level-deep merge on gateway)

gateway.metadata fields

FieldTypeDescription
tagsstring[]Tags for categorizing requests (max 100 items, each ≤50 chars)
user_idstringYour application’s user identifier for per-user analytics (max 255 chars)
trace_idstringDistributed tracing identifier (max 255 chars)
custom_fieldsRecord<string, string>Arbitrary key-value pairs (max 10 keys, keys ≤50 chars, values ≤200 chars)
import { Client } from "@auriko/sdk";

const client = new Client();
const response = await client.chat.completions.create({
    model: "gpt-4o",
    messages: [{ role: "user", content: "Hello!" }],
    gateway: {
        metadata: {
            user_id: "user_123",
            trace_id: "req-abc",
            custom_fields: { env: "prod", team: "backend" },
        },
    },
});
Only the four fields above are accepted. Use custom_fields for arbitrary key-value pairs.

Response (non-streaming)

interface ChatCompletion {
  id: string;
  created: number;
  model: string;
  object: "chat.completion";
  system_fingerprint?: string;  // not all models include this
  choices: Choice[];
  usage?: Usage;
  routing_metadata?: RoutingMetadata;
  service_tier?: string | null;          // processing tier (OpenAI-routed models)
  responseHeaders: ResponseHeaders;  // SDK-added
}

interface ChoiceMessage {
  role: string;
  content: string | null;
  reasoning_content?: string;       // chain-of-thought text (plain string)
  reasoning?: ReasoningBlock[];     // structured reasoning blocks with signatures
  refusal?: string | null;          // model refusal content (OpenAI passthrough)
  tool_calls?: ToolCall[];
  annotations?: unknown[];               // URL citations and model annotations (OpenAI-routed models)
}

Response (streaming)

Returns a Stream that yields ChatCompletionChunk objects.
const stream = await client.chat.completions.create({ stream: true, ... });

for await (const chunk of stream) {
  chunk.choices[0]?.delta?.content;                  // incremental content
  chunk.choices[0]?.delta?.reasoning_content;        // incremental reasoning text (if enabled)
  chunk.choices[0]?.delta?.reasoning_signature;      // signature for current thinking block
  chunk.choices[0]?.delta?.reasoning_redacted_data;  // encrypted redacted thinking data
}

stream.usage;            // available after iteration
stream.routing_metadata; // available after iteration
stream.responseHeaders;  // available immediately
stream.isClosed;         // boolean
stream.close();          // manual cleanup

Responses

client.responses.create(params)

Creates a response using the OpenAI Response API format. Supports single-model and multi-model routing.
// Non-streaming
const response = await client.responses.create({
  model: "gpt-4o",
  input: "Hello!",
});

// Streaming
const stream = await client.responses.create({
  model: "gpt-4o",
  input: "Hello!",
  stream: true,
});

Parameters

ParameterTypeRequiredDescription
inputstring | ResponseInputItemParam[]YesText string or structured input items
modelstringYes*Model ID (*or use gateway.models for multi-model routing)
streambooleanNoEnable streaming (default: false)
instructionsstringNoSystem instructions for the model
toolsResponseToolParam[]NoTool definitions
tool_choicestring | Record<string, unknown>NoTool selection: "auto", "none", "required", or function spec
parallel_tool_callsbooleanNoAllow parallel function calls
max_output_tokensnumberNoMax tokens to generate
temperaturenumberNoSampling temperature (0–2)
top_pnumberNoNucleus sampling (0–1)
top_knumberNoTop-K sampling
top_logprobsnumberNoNumber of top logprobs per token (0–20)
reasoningResponseReasoningParamNoReasoning config: effort, summary, generate_summary
textRecord<string, unknown>NoText format config (e.g., { format: { type: "json_schema", ... } })
userstringNoEnd-user identifier
metadataRecord<string, string>NoArbitrary key-value metadata
includestring[]NoAdditional data to include in the response
truncationstringNoTruncation strategy for long inputs
prompt_cache_keystringNoKey for prompt caching
safety_identifierstringNoSafety policy identifier
gatewayGatewayOptions | Record<string, unknown>NoGateway namespace for routing, multi-model, and metadata options
extensionsExtensions | Record<string, unknown>NoProvider-specific extensions
extra_bodyRecord<string, unknown>NoAdditional body fields (merged last)

Response (non-streaming)

interface ResponseObject {
  id: string;
  object: "response";
  created_at: number;
  model: string;
  status: "completed" | "failed" | "incomplete" | "in_progress";
  output: ResponseOutputItem[];
  output_text: string;
  parallel_tool_calls: boolean;
  tool_choice: unknown;
  tools: unknown[];
  usage?: ResponseUsage | null;
  error?: ResponseError | null;
  incomplete_details?: Record<string, string> | null;
  metadata?: Record<string, string> | null;
  routing_metadata?: RoutingMetadata | null;
  responseHeaders: ResponseHeaders;
}

Response (streaming)

Returns a ResponseStream that yields Response API events.
const stream = await client.responses.create({
  model: "gpt-4o",
  input: "Hello!",
  stream: true,
});

for await (const event of stream) {
  if (event.type === "response.output_text.delta") {
    process.stdout.write(event.delta);
  }
}

// After iteration, the terminal event's response is available:
const final = stream.completedResponse;  // ResponseObject from the terminal event
final?.usage;                            // token usage
final?.routing_metadata;                 // routing details

stream.responseHeaders;                  // available immediately (before iteration)
stream.close();                          // manual cleanup
routing_metadata on completedResponse is available for both streaming and non-streaming responses. For streaming, it’s populated after iteration completes.

Models

Query the model catalog:
const models = await client.models.list();                // GET /v1/models
const model = await client.models.retrieve("gpt-4o");     // GET /v1/models/{model_id}
const directory = await client.models.listDirectory();    // GET /v1/directory/models
const registry = await client.models.listRegistry();      // GET /v1/registry/models
const providers = await client.models.listProviders();    // GET /v1/registry/providers

Identity

Get current API key identity:
const identity = await client.me.get();  // GET /v1/me
// Returns: { object, user_id, workspace_id, tier, rate_limit_rpm }

Error Classes

All errors extend AurikoAPIError. Dispatch is driven by the type field of the canonical error envelope (see Errors for the full envelope and retry policy).
Error ClassHTTPtype
BadRequestError400 / 413 / 422invalid_request_error
AuthenticationError401authentication_error
PermissionDeniedError403permission_error
NotFoundError404not_found_error
ConflictError409invalid_request_error
RateLimitError429rate_limit_error
InternalServerError500api_error
APIStatusError502 / 503 / 504api_error
APIConnectionError(network failure before response)

AurikoAPIError Fields

FieldTypeDescription
messagestringHuman-readable error description (inherited from Error)
statusCodenumberHTTP status code
codestringMachine-readable error code (see Error Codes)
typestringCanonical error type (one of six values)
paramstring | nullParameter that caused the error, when attributable
requestIdstringValue of x-request-id on the failing response
docUrlstring | undefinedLink to the error’s docs page
retryAfterSecondsnumber | undefinedRetry-After header value (429 / 503 only)
providerstring | undefinedUpstream provider that produced this error, when attributable
import { Client, RateLimitError, AuthenticationError } from "@auriko/sdk";

try {
  await client.chat.completions.create({ ... });
} catch (e) {
  if (e instanceof RateLimitError) {
    console.log(`retry after ${e.retryAfterSeconds}s (requestId=${e.requestId})`);
  } else if (e instanceof AuthenticationError) {
    console.log(`${e.message} (requestId=${e.requestId})`);
  }
}
Unknown error responses fall through to the base AurikoAPIError class. Always keep a catch-all for forward compatibility.
mapErrorFromCode(code, message, responseHeaders, opts?) constructs a typed AurikoAPIError subclass from an error code string (e.g., "rate_limit_error"RateLimitError):
import { mapErrorFromCode, RateLimitError } from "@auriko/sdk";

const err = mapErrorFromCode("rate_limit_error", "Too many requests", responseHeaders);
if (err instanceof RateLimitError) {
  console.log(err.retryAfterSeconds);
}

Response Headers

Available on ChatCompletion.responseHeaders, Stream.responseHeaders, and ResponseObject.responseHeaders:
response.responseHeaders.requestId;                  // X-Request-ID
response.responseHeaders.rateLimitRemaining;          // X-RateLimit-Remaining-Requests
response.responseHeaders.rateLimitLimit;              // X-RateLimit-Limit-Requests
response.responseHeaders.rateLimitReset;              // X-RateLimit-Reset-Requests
response.responseHeaders.creditsBalanceMicrodollars;  // X-Credits-Balance-Microdollars
response.responseHeaders.get("x-custom-header");      // any header by name
response.responseHeaders.getAll("x-multi-header");    // string[] for multi-value headers

Constants

Runtime enum objects for routing configuration:
import { Optimize, Mode, DataPolicy } from "@auriko/sdk";

// Optimize strategy
Optimize.COST        // "cost"
Optimize.COST_FOCUS  // "cost-focus"
Optimize.TTFT        // "ttft"
Optimize.TTFT_FOCUS  // "ttft-focus"
Optimize.TPS         // "tps"
Optimize.TPS_FOCUS   // "tps-focus"
Optimize.BALANCED    // "balanced"

// Routing mode
Mode.POOL           // "pool"
Mode.FALLBACK       // "fallback"

// Data policy
DataPolicy.NONE         // "none"
DataPolicy.NO_TRAINING  // "no_training"
DataPolicy.ZDR          // "zdr"

Types

All types use snake_case field names matching the wire format:

Client & Stream

import { Client, Stream, ResponseStream } from "@auriko/sdk";

Chat Response Types

import type {
  ChatCompletion, ChatCompletionChunk, Choice, ChoiceMessage,
  ReasoningBlock, StreamChoice, Delta, ToolCall, ToolCallFunction,
  ToolCallDelta, ToolCallDeltaFunction,
} from "@auriko/sdk";

Response Types

Common types for the Response API. The SDK exports all event types in the ResponseStreamEvent union — import individual event types (e.g., ResponseTextDeltaEvent, ResponseFunctionCallArgumentsDoneEvent) as needed.
import type {
  ResponseObject, ResponseObjectBase, ResponseUsage, ResponseError,
  ResponseOutputItem, ResponseMessageOutputItem,
  ResponseFunctionCallOutputItem, ResponseReasoningOutputItem,
  ResponseOutputContentPart, ResponseReasoningSummary,
  ResponseStreamEvent, ResponseCreateParams,
  ResponseInputItemParam, ResponseToolParam, ResponseReasoningParam,
} from "@auriko/sdk";

Common Types

import type { Usage, PromptTokensDetails, CompletionTokensDetails, ApiKeyIdentity } from "@auriko/sdk";

Routing Types

import type { GatewayOptions, RoutingOptions, RoutingMetadata, CostInfo, StructuredWarning, StructuredWarningType } from "@auriko/sdk";

Extensions

import type { Extensions } from "@auriko/sdk";
FieldTypeDescription
anthropicRecord<string, unknown>Anthropic-specific parameters
openaiRecord<string, unknown>OpenAI-specific parameters
googleRecord<string, unknown>Google-specific parameters
deepseekRecord<string, unknown>DeepSeek-specific parameters
[key]Record<string, unknown>Arbitrary provider passthrough

Model Discovery Types

import type { DirectoryResponse, ModelsListResponse, ProviderList } from "@auriko/sdk";

Request Types

import type { ChatCompletionCreateParams, ClientOptions } from "@auriko/sdk";

Runtime Constants

import { Optimize, Mode, DataPolicy, ResponseHeaders } from "@auriko/sdk";

Error Classes

import {
  AurikoAPIError, APIConnectionError, APIStatusError,
  AuthenticationError, BadRequestError, ConflictError,
  InternalServerError, NotFoundError, PermissionDeniedError,
  RateLimitError, mapErrorFromCode,
} from "@auriko/sdk";