Installation
Install the Tracia SDK using your preferred package manager:
Requirements
- Node.js 18+ (uses native
fetch)
- Works in modern browsers with native
fetch support
Configuration
Initialize the Tracia client with your API key:
import { Tracia } from 'tracia';
const tracia = new Tracia({
apiKey: process.env.TRACIA_API_KEY
});
Configuration Options
| Option | Type | Required | Description |
|---|
apiKey | string | Yes | Your Tracia API key (starts with tr_) |
onSpanError | (error: Error, spanId: string) => void | No | Callback for background span submission failures |
Environment Variables
We recommend storing your API key in environment variables:
TRACIA_API_KEY=tr_your_api_key_here
Never commit API keys to version control. Use environment variables or a secrets manager.
TypeScript Support
The SDK is written in TypeScript and exports all types:
import {
Tracia,
TraciaOptions,
TraciaSession,
RunOptions,
RunResult,
TokenUsage,
Prompt,
PromptListItem,
PromptMessage,
MessageRole,
CreatePromptOptions,
UpdatePromptOptions,
TraciaError,
TraciaErrorCode,
// runLocal types
LocalPromptMessage,
RunLocalInput,
RunLocalResult,
LocalStream,
LLMProvider,
// Span types
Span,
SpanListItem,
SpanStatus,
ListSpansOptions,
ListSpansResult,
// Tool types
ToolDefinition,
ToolCall,
ToolChoice,
} from 'tracia';
Next Steps