Skip to content

OpenAI Chat Completions

POST /v1/chat/completions

OpenAI-compatible chat completions. All standard parameters are accepted (temperature, max_tokens, tools, top_p, stop, etc.).

See OpenAI's documentation for the full request and response specification.

Request

bash
curl https://hyper.charm.land/v1/chat/completions \
  -H "Authorization: Bearer sk-hyper-xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4-pro",
    "messages": [
      {"role": "system", "content": "You are helpful."},
      {"role": "user", "content": "Hello!"}
    ]
  }'
FieldTypeRequiredDescription
modelstringyesModel ID from /v1/models
messagesarrayyesArray of message objects
streambooleannoSet true for SSE streaming (default false)
temperaturenumberno0–2
max_tokensintegernoMax output tokens
toolsarraynoTool/function definitions

Response

json
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1718000000,
  "model": "deepseek-v4-pro",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hey there!"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 5,
    "total_tokens": 15,
    "cost": {
      "usd": 0.000012,
      "hypercredits": 12
    },
    "remaining": {
      "hypercredits": 88
    }
  }
}

Custom Usage Fields

Hyper extends the standard usage object with cost and balance information:

FieldDescription
usage.cost.usdCost of this request in USD
usage.cost.hypercreditsCost in Hypercredits
usage.remaining.hypercreditsTeam's remaining Hypercredit balance after this request

These fields are included in both regular and streaming responses. For streaming, they appear in the final chunk when include_usage is enabled via stream_options.

Streaming

Set "stream": true to receive server-sent events:

bash
curl https://hyper.charm.land/v1/chat/completions \
  -H "Authorization: Bearer sk-hyper-xxxxxxxxxxxxxxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4-pro",
    "messages": [{"role": "user", "content": "Hello!"}],
    "stream": true
  }'

Each chunk is a data: line containing a chat.completion.chunk object. The stream ends with data: [DONE].

Errors

All errors use the standard OpenAI error format:

json
{
  "error": {
    "message": "...",
    "type": "...",
    "code": null
  }
}
Statuserror.typeCause
400invalid_request_errorInvalid JSON, missing model or messages, context window exceeded
401authentication_errorMissing or invalid API key
402billing_errorInsufficient Hypercredits
403permission_errorForbidden
404invalid_request_errorModel not found
429rate_limit_errorRate limit exceeded
5xxserver_errorUpstream provider failure