SDK Overview

The @chaoslabs/ai-sdk is a TypeScript SDK for interacting with the Chaos AI API. It provides a simple, type-safe interface for building DeFi AI applications.

Features

FeatureDescription
Type-safeFull TypeScript support with comprehensive type definitions
Two modesWALLET_MODEL for DeFi operations, ASK_MODEL for research
Rich responsesTables, charts, transactions, and interactive elements
Zod schemasBuilt-in validation for block parsing
Error handlingChaosError and ChaosTimeoutError classes
Helper functionsextractText(), extractBlocks(), hasRisks()

Installation

terminal
npm install @chaoslabs/ai-sdk

Quick Example

example.ts
import { Chaos, WALLET_MODEL, extractText } from '@chaoslabs/ai-sdk';
 
const chaos = new Chaos({ apiKey: process.env.CHAOS_API_KEY! });
 
const response = await chaos.chat.responses.create({
  model: WALLET_MODEL,
  input: [{ type: 'message', role: 'user', content: "What's in my portfolio?" }],
  metadata: { user_id: 'user-1', session_id: 'session-1', wallet_id: '0x...' },
});
 
console.log(extractText(response));

Next Steps