Quick Decision Matrix
Choose the SDK When…
Building Browser Applications
Perfect for web apps, SPAs, and browser-based tools
Want Rapid Development
Get started in minutes with minimal boilerplate code
Need Event-Driven Architecture
Built-in events for messages, images, and streaming
Building Conversational Interfaces
Automatic conversation history and turn management
SDK Advantages
✅ Minimal Setup: One import, one configuration object✅ Automatic Authentication: Secure token handling with refresh
✅ Built-in Events: React to messages, images, and errors
✅ Conversation Management: Automatic history and context
✅ Streaming Made Easy: AsyncIterable pattern for real-time responses
✅ Image Generation: Automatic detection and generation
✅ TypeScript Support: Full type safety and autocomplete
✅ Error Handling: Specific error types for different scenarios
SDK Example
Choose the REST API When…
Using Non-JavaScript Languages
Python, Java, C#, Go, PHP, Ruby, or any other language
Building Backend Services
Server-side applications, APIs, and microservices
Need Maximum Control
Custom request handling and response processing
Batch Processing
Processing large datasets or automated workflows
REST API Advantages
✅ Universal Language Support: Works with any programming language✅ Maximum Flexibility: Full control over requests and responses
✅ Server-Side Integration: Perfect for backend services
✅ Existing Infrastructure: Integrate with current HTTP clients
✅ Batch Operations: Process multiple requests efficiently
✅ Custom Authentication: Implement your own auth patterns
REST API Example
Use Case Scenarios
Perfect for SDK
🤖 Chatbot InterfacesPerfect for REST API
🤝 Chat Co-pilot with Response SelectionFeature Comparison
Authentication
SDK Approach:Streaming
SDK Approach:Error Handling
SDK Approach:Migration Paths
From REST API to SDK
If you’re currently using the REST API and want to migrate to the SDK:- Set up authentication server (see SDK Quickstart)
- Replace HTTP calls with SDK methods
- Add event listeners for reactive UI updates
- Enable automatic features like conversation history
From SDK to REST API
If you need to migrate from SDK to REST API:- Implement authentication header management
- Add streaming parsing for real-time responses
- Build conversation history tracking
- Handle errors with HTTP status codes
Decision Framework
Ask yourself these questions:-
What’s your primary language?
- JavaScript/TypeScript → SDK
- Other languages → REST API
-
What’s your environment?
- Browser application → SDK
- Server/backend → REST API
-
How complex is your use case?
- Simple chat/conversation → SDK
- Complex integrations → REST API
-
Do you need real-time features?
- Yes, with minimal code → SDK
- Yes, with full control → REST API
-
How quickly do you need to ship?
- ASAP → SDK
- Have time for custom implementation → REST API
Get Started
Ready to choose your path?Start with SDK
Perfect for JavaScript/TypeScript browser applications
Start with REST API
Ideal for any language or server-side applications
