API Reference
Complete API documentation for CPAI endpoints.
Base URL
Section titled “Base URL”http://localhost:8080/v1
All API requests require authentication via the Authorization header with a Bearer token.
Authentication
Section titled “Authentication”Include your API key in the Authorization header:
Authorization: Bearer cpai-xxxxxChat Completions
Section titled “Chat Completions”OpenAI-compatible chat completions endpoint.
POST /chat/completions
Section titled “POST /chat/completions”Request body:
{ "model": "kimi-k2.5", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "Hello!"} ], "temperature": 0.7, "max_tokens": 1024, "stream": false}Response:
{ "id": "chatcmpl-xxx", "object": "chat.completion", "created": 1234567890, "model": "kimi-k2.5", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Hello! How can I help you today?" }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 10, "completion_tokens": 20, "total_tokens": 30 }}Streaming
Section titled “Streaming”Set stream: true for Server-Sent Events (SSE) streaming responses.
curl http://localhost:8080/v1/chat/completions \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "kimi-k2.5", "messages": [{"role": "user", "content": "Hello!"}], "stream": true }'Models
Section titled “Models”Available models:
kimi-k2.5- Kimi K2.5 (default)deepseek-coder- DeepSeek Codercodellama- CodeLlama
Error Codes
Section titled “Error Codes”| Code | Description |
|---|---|
| 400 | Bad Request - Invalid request body |
| 401 | Unauthorized - Invalid or missing API key |
| 403 | Forbidden - IP not whitelisted |
| 429 | Too Many Requests - Concurrency limit exceeded |
| 503 | Service Unavailable - No GPU nodes available |
Health Check
Section titled “Health Check”Public health endpoint (no authentication required):
GET /health