Skip to main content

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 Interfaces
πŸ“± Real-time Applications
🎨 Creative Tools
πŸ”„ Interactive Experiences

Perfect for REST API

🀝 Chat Co-pilot with Response Selection
πŸ‘οΈ Video Categorization with Vision
πŸ’¬ Conversation Analysis & Profiling

Feature Comparison

Authentication

SDK Approach:
REST API Approach:

Streaming

SDK Approach:
REST API Approach:

Error Handling

SDK Approach:
REST API Approach:

Migration Paths

From REST API to SDK

If you’re currently using the REST API and want to migrate to the SDK:
  1. Set up authentication server (see SDK Quickstart)
  2. Replace HTTP calls with SDK methods
  3. Add event listeners for reactive UI updates
  4. Enable automatic features like conversation history

From SDK to REST API

If you need to migrate from SDK to REST API:
  1. Implement authentication header management
  2. Add streaming parsing for real-time responses
  3. Build conversation history tracking
  4. Handle errors with HTTP status codes

Decision Framework

Ask yourself these questions:
  1. What’s your primary language?
    • JavaScript/TypeScript β†’ SDK
    • Other languages β†’ REST API
  2. What’s your environment?
    • Browser application β†’ SDK
    • Server/backend β†’ REST API
  3. How complex is your use case?
    • Simple chat/conversation β†’ SDK
    • Complex integrations β†’ REST API
  4. Do you need real-time features?
    • Yes, with minimal code β†’ SDK
    • Yes, with full control β†’ REST API
  5. 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
Still unsure? Start with the SDK if you’re building a browser application with JavaScript/TypeScript. You can always switch to the REST API later if you need more control or different language support.