Skip to main content

Overview

This guide provides comprehensive Python examples for integrating with the SundayPyjamas AI Suite API, including synchronous and asynchronous implementations, batch processing, and CLI tools.
Examples include both sync and async implementations with comprehensive error handling and production-ready patterns.

Installation

Install required packages:

Basic Setup

Environment Variables

Create a .env file:

Configuration

Simple Chat Request

Synchronous Implementation

Streaming Response Handler

Async Implementation

Async Client with aiohttp

Batch Processing

Process Multiple Requests

Content Generation Tools

Advanced Content Generator

Error Handling and Retry Logic

Robust Error Handling

CLI Tool Example

Command-Line Interface

Usage Examples

Testing

Unit Tests

Beyond Chat: Other APIs

See the full Agents API reference.
See the full RAG API reference.
See the full Image API reference.

Next Steps

JavaScript Examples

Explore comprehensive JavaScript/TypeScript implementations

cURL Examples

Command-line examples for testing and automation

Rate Limits

Learn about optimization and usage tracking

Error Handling

Master robust error handling patterns
All Python examples include comprehensive error handling, retry logic, and are production-ready. The async examples provide better performance for high-throughput applications.