API Reference
Complete API documentation for the Coren AI Platform. All endpoints use JSON for request and response bodies, and require authentication via API key or Bearer token.
Base URL
All API requests should be made to:
https://api.coren.ai/v1
Endpoints
Authentication
The Coren API uses API keys to authenticate requests. You can view and manage your API keys in the Dashboard. Include your API key in the Authorization header of all requests.
API Key Authentication
curl https://api.coren.ai/v1/chat/completions \-H "Authorization: Bearer sk_live_your_api_key_here" \-H "Content-Type: application/json" \-d '{"model": "coren-large", "messages": [...]}'
Request Headers
| Header | Required | Description |
|---|---|---|
| Authorization | Yes | Bearer token with your API key |
| Content-Type | Yes | application/json for all requests |
| X-Request-ID | No | Custom request ID for tracing |
| X-Tenant-ID | No | Tenant ID for multi-tenant environments |
Security Best Practices
- Never expose your API key in client-side code or public repositories
- Use environment variables to store API keys
- Rotate keys periodically and revoke compromised keys immediately
- Use separate keys for development and production environments
Chat Completions
Create chat completions using various LLM providers. The API automatically routes requests to the optimal provider based on your configuration.
Embeddings
Generate vector embeddings for text inputs. Embeddings can be used for semantic search, clustering, and similarity comparisons.
Models
List and manage models available in your organization. Includes both provider models and custom fine-tuned models.
Fine-tuning
Create and manage fine-tuning jobs to customize models for your specific use case.
RAG (Retrieval-Augmented Generation)
Manage knowledge bases and perform retrieval-augmented generation queries.
Agents
Create and manage AI agents with custom tools, memory, and workflows.
Error Codes
The API uses standard HTTP response codes to indicate success or failure of requests. Error responses include a JSON body with details about the error.
Error Response Format
{"error": {"code": "invalid_api_key","message": "The API key provided is invalid.","type": "authentication_error","param": null,"request_id": "req_abc123"}}
HTTP Status Codes
| Code | Status | Description |
|---|---|---|
| 200 | OK | Request succeeded |
| 201 | Created | Resource created successfully |
| 400 | Bad Request | Invalid request body or parameters |
| 401 | Unauthorized | Invalid or missing API key |
| 403 | Forbidden | Insufficient permissions for this action |
| 404 | Not Found | Resource does not exist |
| 429 | Too Many Requests | Rate limit exceeded |
| 500 | Internal Server Error | Server error, retry later |
| 503 | Service Unavailable | Service temporarily unavailable |
Error Types
| Type | Description |
|---|---|
| authentication_error | Invalid API key or authentication failure |
| invalid_request_error | Request body validation failed |
| rate_limit_error | Too many requests in a short period |
| quota_exceeded_error | Monthly usage quota exceeded |
| model_error | Error from the underlying model provider |
| server_error | Internal server error |
Rate Limiting
When you receive a 429 error, check the Retry-After header for the number of seconds to wait before retrying. Implement exponential backoff for production applications.