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.