Tool routing configuration is modeled by ToolAutorouterRequest from @illalabs/interfaces.
Start with SDK defaults unless you need deterministic routing behavior.
Most integrations should not define the full autorouter config initially.
Using the ILLA SDK
Set default routing via contextManagerOptions.defaultToolsConfig.
import { IllaSDK } from '@illalabs/sdk'
const sdk = new IllaSDK(
{ apiKey: process.env.ILLA_API_KEY! },
{
contextManagerOptions: {
defaultToolsConfig: {
autoRouter: {
swapOrBridge: 'lifi',
defi: { lending: 'aave' },
},
},
},
},
)
Per-chat configuration with a custom ContextManager
import { IllaSDK, InMemoryCache } from '@illalabs/sdk'
const cache = new InMemoryCache()
const contextManager = IllaSDK.createNewContextManager(cache, {
defaultToolsConfig: {
autoRouter: {
swapOrBridge: 'lifi',
},
},
})
const sdk = new IllaSDK(
{ apiKey: process.env.ILLA_API_KEY! },
{ contextManager },
)
const chat = sdk.createChat({
userContext: { address: '0x1234...' },
})
Read current configuration
const snapshot = await sdk.getChat(chatId).getContext()
console.log(snapshot.toolsConfig)
Update configuration on an existing chat
const chat = sdk.getChat(chatId)
const snapshot = await chat.getContext()
await chat.setContext({
...snapshot,
toolsConfig: {
autoRouter: {
swapOrBridge: 'lifi',
defi: { lending: 'aave' },
},
},
})
Notes
- Configuration is persisted in the chat context.
ContextManager deep-clones stored config to avoid accidental mutation.