> ## Documentation Index
> Fetch the complete documentation index at: https://docs.illa.io/llms.txt
> Use this file to discover all available pages before exploring further.

# TypeScript Support

> Types you can import and how to use them effectively

## TypeScript support

The SDK is written in TypeScript and ships full type definitions. Most apps only need classes, but you can also import types for stronger guarantees.

## Publicly exported classes

```ts theme={null}
import {
  IllaSDK,
  Chat,
  Prompt,
  ContextManager,
  CoreApiProvider,
  InMemoryCache,
  AsyncToolChecker,
  ChatNotFound,
  UserContextMissing,
} from '@illalabs/sdk'
```

## Publicly exported types

```ts theme={null}
import type {
  // SDK configuration
  illaSDKConfig,
  SendMessageContext,

  // Context management
  ChatContextSnapshot,
  ContextManagerOptions,
  IContextManager,

  // Caching
  CacheEntryOptions,
  ICache,
} from '@illalabs/sdk'
```

Note: Additional types are available from `@illalabs/interfaces` package for tool execution, message history, and user context.

## Usage Examples

### Using the ILLA SDK with types

```ts theme={null}
import { IllaSDK } from '@illalabs/sdk'
import type { illaSDKConfig, SendMessageContext } from '@illalabs/sdk'

const config: illaSDKConfig = {
  apiKey: process.env.ILLA_API_KEY!,
}

const sdk = new IllaSDK(config)

// Type-safe message context
const context: SendMessageContext = {
  userContext: { address: '0x1234...' }
}

const result = await sdk.sendMessage('Hello', context)
```

### Customize context manager

```ts theme={null}
import type { ContextManagerOptions } from '@illalabs/sdk'

const options: ContextManagerOptions = {
  cacheKeyPrefix: 'illa:sdk:ctx',
  defaultToolsConfig: {
    autoRouter: { swapOrBridge: 'lifi' }
  }
}

const ctx = new ContextManager(new InMemoryCache(), options)
```

### TTL with CacheEntryOptions

```ts theme={null}
import type { CacheEntryOptions } from '@illalabs/sdk'

const options: CacheEntryOptions = { ttl: 60_000 }
await cache.set('key', value, options)
```

### Using interfaces from @illalabs/interfaces

```ts theme={null}
import type {
  MessageHistoryType,
  PendingToolCallType,
  IllaToolOutcomeJSON,
  UserContext,
} from '@illalabs/interfaces'

const userContext: UserContext = { address: '0x1234...' }
const messages: MessageHistoryType = await sdk.getMessages(chatId)
```

### Simulation and signing types

```ts theme={null}
import type {
  SimulationResult,
  AssetChange,
  GasEstimate,
  ActionMetadata,
  ContractInteraction,
  SimulationActionType,
  SignatureRequest,
  EIP712TypedData,
} from '@illalabs/interfaces'
```

### Supported constants and values

```ts theme={null}
import {
  SUPPORTED_ACTIONS,
  SUPPORTED_CHAINS,
  SUPPORTED_CHAIN_IDS,
  SUPPORTED_OPENAI_MODELS,
  SUPPORTED_OPENROUTER_MODELS,
  type SupportedAction,
  type SupportedChain,
  type SupportedChainId,
  type SupportedOpenAIModel,
  type SupportedOpenRouterModel,
} from '@illalabs/interfaces'
```
