Skip to main content

Overview

This guide provides comprehensive cURL examples for testing and automating interactions with the SundayPyjamas AI Suite API. Perfect for command-line testing, shell scripting, and CI/CD pipelines.
All examples include proper error handling, output formatting, and can be easily adapted for automation scripts.

Basic Setup

Environment Variables

Set up your environment variables for easier testing:

Verify Setup

Test your environment variables:

Basic Chat Request

Simple Single Message

With Specific Model

Multi-turn Conversation

With System Message

Content Generation Examples

Blog Post Generation

Email Generation

Marketing Copy

Streaming Response Handling

Basic Streaming

Save Streaming Response

Error Testing and Debugging

Test Invalid API Key

Expected response:

Test Missing Messages

Expected response:

Test Invalid Message Format

Debug Request with Verbose Output

Advanced Examples

Batch Processing with Shell Script

Create a file called batch_process.sh:
Make it executable and run:

Content Generation Pipeline

Create content_pipeline.sh:

Response Analysis Script

Create analyze_response.sh:
Usage:

Testing and Debugging

Check API Connectivity

Debug Headers and Request

Performance Testing

Load Testing Script

JSON Processing with jq

Extract Specific Data

Format Error Responses

Best Practices

1. Always Handle Errors

2. Use Proper JSON Escaping

3. Set Timeouts

4. Create Reusable Functions

CI/CD Integration

GitHub Actions Example

Docker Integration

Beyond Chat: Other APIs

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

Next Steps

JavaScript Examples

Learn JavaScript/TypeScript implementations with React components

Python Examples

Explore comprehensive Python implementations with async support

Rate Limits

Understand usage guidelines and optimization strategies

Authentication

Review API key management and security best practices
All cURL examples can be easily adapted for automation, testing, and integration into CI/CD pipelines. The shell scripts provide a foundation for building more complex workflows.