Overview
This guide covers setting up your development environment for integrating with the SundayPyjamas AI Suite API, including local testing, documentation preview, and development best practices.
This documentation can be run locally for contributions and updates.
API Development Setup
Environment Configuration
Get Your API Key
Generate an API key from your SundayPyjamas workspace:
Navigate to Settings → API tab
Click “Generate API Key”
Save the key securely
Set Environment Variables
Create a .env file in your project: # API Configuration
SUNDAYPYJAMAS_API_KEY = spj_ai_your_api_key_here
SUNDAYPYJAMAS_API_URL = https://suite.sundaypyjamas.com/api/v1
# Development Settings
NODE_ENV = development
PORT = 3000
Install Dependencies
Choose your preferred language and install required packages: JavaScript/Node.js
Python
Go
# Basic setup (Node.js 18+)
npm init -y
npm install dotenv
# For advanced features
npm install node-fetch @types/node
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install packages
pip install requests python-dotenv aiohttp
# Initialize Go module
go mod init your-project
# No additional packages needed for basic HTTP requests
Local Documentation Development
If you want to contribute to this documentation or run it locally:
Prerequisites
Node.js version 19 or higher
Git for version control
Install Documentation CLI
Clone and Preview
# Clone the documentation repository
git clone < repository-ur l >
cd ai-suite-platform-docs
# Start local preview
mint dev
A local preview will be available at http://localhost:3000.
Custom Ports
# Use a different port
mint dev --port 3333
# Automatic port selection if 3000 is in use
# Port 3000 is already in use. Trying 3001 instead.
Testing Your Integration
Basic Connection Test
test-connection.js
test_connection.py
test-connection.sh
// test-connection.js
require ( 'dotenv' ). config ();
async function testConnection () {
const response = await fetch ( ` ${ process . env . SUNDAYPYJAMAS_API_URL } /chat` , {
method: 'POST' ,
headers: {
'Authorization' : `Bearer ${ process . env . SUNDAYPYJAMAS_API_KEY } ` ,
'Content-Type' : 'application/json'
},
body: JSON . stringify ({
messages: [{ role: 'user' , content: 'Hello! This is a test.' }]
})
});
if ( response . ok ) {
console . log ( '✅ API connection successful' );
const result = await response . text ();
console . log ( 'Response:' , result );
} else {
console . error ( '❌ API connection failed:' , response . status );
const error = await response . text ();
console . error ( 'Error:' , error );
}
}
testConnection ();
Integration Testing
Create a comprehensive test suite:
// tests/api-integration.test.js
const assert = require ( 'assert' );
require ( 'dotenv' ). config ();
describe ( 'SundayPyjamas AI API Integration' , () => {
const apiUrl = process . env . SUNDAYPYJAMAS_API_URL ;
const apiKey = process . env . SUNDAYPYJAMAS_API_KEY ;
it ( 'should handle basic chat request' , async () => {
const response = await fetch ( ` ${ apiUrl } /chat` , {
method: 'POST' ,
headers: {
'Authorization' : `Bearer ${ apiKey } ` ,
'Content-Type' : 'application/json'
},
body: JSON . stringify ({
messages: [{ role: 'user' , content: 'Hello' }]
})
});
assert . strictEqual ( response . status , 200 );
const result = await response . text ();
assert ( result . length > 0 );
});
it ( 'should handle system messages' , async () => {
const response = await fetch ( ` ${ apiUrl } /chat` , {
method: 'POST' ,
headers: {
'Authorization' : `Bearer ${ apiKey } ` ,
'Content-Type' : 'application/json'
},
body: JSON . stringify ({
messages: [
{ role: 'system' , content: 'You are a helpful assistant.' },
{ role: 'user' , content: 'What is 2+2?' }
]
})
});
assert . strictEqual ( response . status , 200 );
});
it ( 'should return error for invalid API key' , async () => {
const response = await fetch ( ` ${ apiUrl } /chat` , {
method: 'POST' ,
headers: {
'Authorization' : 'Bearer invalid_key' ,
'Content-Type' : 'application/json'
},
body: JSON . stringify ({
messages: [{ role: 'user' , content: 'Hello' }]
})
});
assert . strictEqual ( response . status , 401 );
});
});
Recommended Extensions
VS Code Extensions
MDX extension for documentation
Prettier for code formatting
REST Client for API testing
dotenv for environment variables
API Testing Tools
Postman for interactive testing
Insomnia for REST API testing
HTTPie for command-line testing
Thunder Client for VS Code
Environment Validation
Create a validation script to check your setup:
// scripts/validate-env.js
require ( 'dotenv' ). config ();
const requiredEnvVars = [
'SUNDAYPYJAMAS_API_KEY' ,
'SUNDAYPYJAMAS_API_URL'
];
console . log ( '🔍 Validating environment configuration... \n ' );
let hasErrors = false ;
requiredEnvVars . forEach ( envVar => {
const value = process . env [ envVar ];
if ( ! value ) {
console . error ( `❌ Missing required environment variable: ${ envVar } ` );
hasErrors = true ;
} else {
console . log ( `✅ ${ envVar } : ${ value . substring ( 0 , 20 ) } ...` );
}
});
// Validate API key format
const apiKey = process . env . SUNDAYPYJAMAS_API_KEY ;
if ( apiKey && ! apiKey . startsWith ( 'spj_ai_' )) {
console . error ( '❌ Invalid API key format. Should start with "spj_ai_"' );
hasErrors = true ;
}
// Validate URL format
const apiUrl = process . env . SUNDAYPYJAMAS_API_URL ;
if ( apiUrl && ! apiUrl . startsWith ( 'https://' )) {
console . warn ( '⚠️ API URL should use HTTPS for security' );
}
if ( hasErrors ) {
console . error ( ' \n ❌ Environment validation failed. Please fix the issues above.' );
process . exit ( 1 );
} else {
console . log ( ' \n ✅ Environment validation passed!' );
}
Link Validation
# Validate all links in documentation
mint broken-links
# Check specific files
mint broken-links --files quickstart.mdx,authentication.mdx
Building for Production
# Build documentation
mint build
# Deploy to production (requires setup)
mint deploy
Troubleshooting
Common solutions:
Verify API key format (spj_ai_[64-characters])
Check environment variable loading
Ensure HTTPS is used for API URL
Verify workspace permissions
# Debug API key
echo "API Key: ${ SUNDAYPYJAMAS_API_KEY : 0 : 20 }..."
echo "API URL: $SUNDAYPYJAMAS_API_URL "
Documentation Build Errors
Common solutions:
Update documentation CLI: npm update -g mint
Clear cache: rm -rf ~/.mintlify && mint dev
Check MDX syntax in files
Validate JSON configuration
# Reinstall CLI if needed
npm remove -g mint
npm i -g mint
Environment Variable Issues
Common solutions:
Check .env file location (project root)
Verify no extra spaces in variable assignments
Ensure proper dotenv loading in code
Check for conflicting environment variables
// Debug environment loading
console . log ( 'Current working directory:' , process . cwd ());
console . log ( 'Environment variables loaded:' , !! process . env . SUNDAYPYJAMAS_API_KEY );
Next Steps
Join our developer community for support, updates, and to share your implementations with other developers.