SDKs & Client Libraries
Official SDKs
JavaScript/TypeScript SDK
npm install @twig-ai/sdk
# or
yarn add @twig-ai/sdkimport { TwigAI } from '@twig-ai/sdk';
const twig = new TwigAI({
apiKey: process.env.TWIG_API_KEY
});
// Chat completion
const response = await twig.chat.create({
prompt: 'What is your refund policy?',
agentId: 'agent-123'
});
console.log(response.text);
console.log(response.sources);Python SDK (Coming Soon)
SDK Features
Chat Completion
Agent Management
Data Source Management
Analytics
Error Handling
Try-Catch Pattern
Error Types
Advanced Usage
Retry with Backoff
Custom Configuration
Webhook Helpers
Community SDKs
Ruby (Community)
Go (Community)
Best Practices
1. API Key Management
2. Error Handling
3. Performance
4. Testing
Examples
Next.js API Route
Express.js Server
React Component
Contributing
Next Steps
Last updated

