API Documentation
Complete guide to integrating AptRouter's prompt optimization API. Save up to 25% on token usage while maintaining quality and semantic meaning.
Quickstart
Get started with the AptRouter API in just a few steps.
1Create an Account
Sign up at aptrouter.ai/signup to get started.
2Purchase Credits
Add credits to your account. £0.10 per 1M tokens (£1 = 10M tokens). Minimum purchase £5.
3Generate an API Key
Go to the API Keys page and create a new key. Save it securely - it won't be shown again.
4Start Optimizing
Use your API key to send prompts and receive optimized versions.
Authentication
All protected endpoints require an API key. Get your API key from your dashboard.
API Key Format
Authentication Methods
Option 1: X-API-Key Header (Recommended)
Option 2: Authorization Bearer Token
Security Notes:
- ⚠️ Never expose your API key in client-side code
- ✅ Store keys in environment variables
- 🔄 Rotate keys regularly
- 🚫 Don't commit keys to version control
API Reference
/v1/optimizeOptimize a prompt to reduce token usage while maintaining semantic meaning and quality.
Request Body
Response (200 OK)
Error Responses
Examples
| 1 | |
Error Codes
Common error responses and how to handle them.
Bad Request
Invalid request format or missing required fields. Check your request body.
Unauthorized
Missing or invalid API key. Ensure your X-API-Key header is set correctly.
Insufficient Credits
Your account has run out of credits. Add more credits to continue.
Rate Limit Exceeded
Too many requests. Current limit: 100 requests per minute.
Internal Server Error
Something went wrong on our end. Please try again or contact support.
Error Response Format
Support
Need help with your integration? We're here to assist.
Email Support
support@aptrouter.aiGet help with technical questions, billing issues, or general inquiries.
Community Discord
Join our Discord serverConnect with other developers, share tips, and get quick answers from the community.
Best Practices
- Implement retry logic with exponential backoff for failed requests
- Cache optimized prompts to reduce API calls and costs
- Monitor your credit balance regularly
- Store API keys in environment variables, never in code
- Review the Activity page for usage insights