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

FieldTypeRequiredDescription
modelstringyesModel ID (e.g. "deepseek-v4-flash")
messagesarrayyesArray of {role, content} objects
streambooleannoEnable SSE streaming (default: false)
temperaturefloatnoSampling temperature (0-2)
top_pfloatnoNucleus sampling threshold
max_tokensintnoMaximum 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

CodeDescription
401Invalid or missing API key
402Insufficient balance — top up credits
404Model not found or disabled
422Invalid request body
429Rate limit exceeded (60 req/min default)
503No providers available for this model