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
