Configuration

Configuration

This page covers all configuration options for the Chaos SDK client.

ChaosConfig Interface

The ChaosConfig interface defines the configuration options for initializing the Chaos client:

types.ts
/**
 * Configuration for the Chaos client.
 */
export interface ChaosConfig {
  /** API key for authentication */
  apiKey: string;
  /** Base URL for the API (defaults to https://ai-staging.chaoslabs.co) */
  baseUrl?: string;
  /** Request timeout in milliseconds (defaults to 120000) */
  timeout?: number;
}

Configuration Options

apiKey (required)

Your Chaos API key for authentication. This is the only required configuration option.

baseUrl (optional)

The base URL for the API. Defaults to https://ai-staging.chaoslabs.co.

timeout (optional)

Request timeout in milliseconds. Defaults to 120000 (2 minutes). If a request exceeds this timeout, a ChaosTimeoutError will be thrown.

Basic Configuration

basic-config.ts
import Chaos from '@chaoslabs/ai-sdk';
 
// Minimal configuration (uses defaults)
const client = new Chaos({
  apiKey: process.env.CHAOS_API_KEY!,
});

Full Configuration

full-config.ts
import Chaos from '@chaoslabs/ai-sdk';
 
// Full configuration with all options
const client = new Chaos({
  apiKey: process.env.CHAOS_API_KEY!,
  baseUrl: 'https://ai-staging.chaoslabs.co',
  timeout: 180000, // 3 minutes
});

Model Constants

The SDK exports two model constants for use with the model parameter in requests:

models.ts
import { WALLET_MODEL, ASK_MODEL } from '@chaoslabs/ai-sdk';
 
// WALLET_MODEL = 'wallet'
// Use for DeFi operations like swap, supply, borrow, withdraw, etc.
// Requires wallet_id in metadata
 
// ASK_MODEL = 'ask'
// Use for research queries and informational requests
// Does not require wallet_id

Model Selection Guide

Use CaseModelExample
Swap tokensWALLET_MODEL"Swap 1 ETH for USDC"
Supply to protocolWALLET_MODEL"Supply 1000 USDC to Aave"
Borrow assetsWALLET_MODEL"Borrow 500 DAI from Compound"
Research TVLASK_MODEL"What is the TVL of Uniswap?"
Market analysisASK_MODEL"Compare lending rates across protocols"
Protocol infoASK_MODEL"How does Aave liquidation work?"

Environment Setup

We recommend storing your API key in environment variables:

Using dotenv

dotenv-setup.ts
import 'dotenv/config';
import Chaos from '@chaoslabs/ai-sdk';
 
const client = new Chaos({
  apiKey: process.env.CHAOS_API_KEY!,
});

Environment file

.env
# Chaos AI SDK
CHAOS_API_KEY=your-api-key-here

# Optional: Custom base URL
# CHAOS_BASE_URL=https://custom-api.example.com

Next Steps