API Reference
ParrotRouter provides an OpenAI-compatible API that works with existing SDKs and tools.
Base URL
https://api.parrotrouter.com/v1
Authentication
All API requests require authentication using a Bearer token in the Authorization header:
curl https://api.parrotrouter.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json"
Endpoints
POST
/v1/chat/completions
Create Chat Completion
Generate AI responses using chat models with conversation history
POST
/v1/completions
Create Completion
Generate text completions for prompts (legacy format)
GET
/v1/models
List Available Models
Get a list of all available models with details and pricing
GET
/v1/credits
Get Credits Balance
Check your current credit balance and usage
Response Format
All responses follow the OpenAI format for compatibility:
Successful Responsejson
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "gpt-4",
"choices": [{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 12,
"total_tokens": 21
}
}
Error Handling
Errors are returned with appropriate HTTP status codes:
Error Responsejson
{
"error": {
"message": "Invalid API key provided",
"type": "authentication_error",
"code": "invalid_api_key"
}
}