Get Your API Key
Start by generating your API key from your workspace settings.1
Access Workspace Settings
- Log into your SundayPyjamas workspace
- Navigate to Settings → API tab
- Click “Generate API Key”
- Give your key a descriptive name (optional)
2
Save Your Key Securely
Make Your First Request
Choose your preferred method to make your first API call:- JavaScript
- Python
- cURL
Understanding the Response
The API returns a streaming text response. You’ll receive the AI’s response in real-time:Common Use Cases
Content Generation
Generate blog posts, emails, and marketing copy with custom prompts.
Chat Interface
Build conversational AI interfaces with streaming responses.
Email Writing
Create professional emails for various purposes and audiences.
Code Assistance
Get help with programming tasks and code generation.
Best Practices
Secure Your API Key
Handle Errors Gracefully
Optimize for Token Usage
Next Steps
Authentication Guide
Learn about API key management, security, and permissions.
Chat API Reference
Explore complete endpoint documentation with all parameters.
Code Examples
View ready-to-use implementations in multiple languages.
Rate Limits
Understand usage guidelines and optimization strategies.
Troubleshooting
"Invalid API key" Error
"Invalid API key" Error
- Check your API key format:
spj_ai_[64-characters] - Ensure the key is active and not deleted
- Verify the Authorization header:
Bearer spj_ai_...
"Token limit exceeded" Error
"Token limit exceeded" Error
- Check your workspace usage in settings
- Optimize prompts to use fewer tokens
- Consider upgrading your plan
Network/Connection Errors
Network/Connection Errors
- Verify the API URL is correct
- Check your internet connection
- Ensure HTTPS is used, not HTTP
Ready to build amazing AI-powered applications? Start with the Chat API documentation or explore our code examples to see what’s possible!

