Chat Completions
OpenAI-compatible chat completions API. Drop-in replacement — just change the base URL.
Authentication
Use either header:
X-API-Key: sk-alphachat-xxxxx # or Authorization: Bearer sk-alphachat-xxxxx
POST /v1/chat/completions
Create a chat completion. Supports streaming via SSE.
Request Body
| Field | Type | Required | Description |
|---|---|---|---|
| model | string | yes | Model ID (e.g. "deepseek-v4-flash") |
| messages | array | yes | Array of {role, content} objects |
| stream | boolean | no | Enable SSE streaming (default: false) |
| temperature | float | no | Sampling temperature (0-2) |
| top_p | float | no | Nucleus sampling threshold |
| max_tokens | int | no | Maximum tokens to generate |
Example (curl)
curl -X POST https://api.alphachat.com/v1/chat/completions \
-H "Authorization: Bearer sk-alphachat-xxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-flash",
"messages": [{"role": "user", "content": "hello"}]
}'Response
{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"model": "deepseek-v4-flash",
"choices": [{
"index": 0,
"message": {"role": "assistant", "content": "Hello! How can I help?"},
"finish_reason": "stop"
}],
"usage": {
"prompt_tokens": 5,
"completion_tokens": 8,
"total_tokens": 13
}
}Streaming (SSE)
Set stream: true. Response is Server-Sent Events:
data: {"id":"chatcmpl-abc","choices":[{"delta":{"role":"assistant"},"index":0}]}
data: {"id":"chatcmpl-abc","choices":[{"delta":{"content":"Hello"},"index":0}]}
data: {"id":"chatcmpl-abc","choices":[{"delta":{"content":"!"},"index":0,"finish_reason":"stop"}]}
data: [DONE]GET /v1/models
List available models.
{
"object": "list",
"data": [
{"id": "deepseek-v4-flash", "object": "model", "owned_by": "alphachat"},
{"id": "mixtral-8x7b", "object": "model", "owned_by": "alphachat"}
]
}Error Codes
| Code | Description |
|---|---|
| 401 | Invalid or missing API key |
| 402 | Insufficient balance — top up credits |
| 404 | Model not found or disabled |
| 422 | Invalid request body |
| 429 | Rate limit exceeded (60 req/min default) |
| 503 | No providers available for this model |