Prerequisites: Secure Token Endpoint
Authentication Setup Required
Before using the SDK, you must set up a secure token provider endpoint on your backend server. This keeps your API key safe and enables proper user authentication.Click here for complete setup instructions →
Install the SDK
Install the SDK in your frontend application:Your First Chat
Create a simple chat application with just a few lines of code:Progressive Examples
Step 1: Basic Chat with Event Handling
Step 2: Streaming Responses
Get responses as they’re generated for a more interactive experience:Step 3: Conversational Turns
Enable natural conversation flow with automatic response splitting:Step 4: Image Generation
Generate images automatically when the AI suggests them:Step 5: Vision Analysis
Analyze images with the vision capabilities:Key SDK Features
Secure Authentication
Token-based auth keeps your API key safe on the backend
Event-Driven
Listen for message, image, and error events for reactive UIs
Auto-Context
Automatic conversation history management with configurable size
Real-time Streaming
Stream responses as they’re generated with AsyncIterable pattern
Image Generation
Automatic image generation when AI responses include image prompts
Type Safety
Full TypeScript support with intelligent autocomplete
Configuration Options
Configure the client with extensive options:Error Handling
Handle different scenarios with specific error types:What’s Next?
Now that you’ve got the basics, explore more advanced features:Chat & Conversations
Learn about conversation management and history handling
Image Generation
Dive deeper into image creation and automatic generation
Streaming & Events
Master real-time streaming and event handling patterns
Tool Calling
Connect AI to external APIs and services
Need Help?
Choose Your Path
Compare SDK vs REST API approaches
REST API Alternative
Prefer direct HTTP integration? Try our REST API
