API REFERENCE · CHAT COMPLETIONS

Chat completions

OpenAI-compatible endpoint for chat-style conversations. Use this for almost everything text-shaped: assistants, RAG, code generation, summarization, agents.

POSThttps://api.hoonify.ai/v1/chat/completions

Authentication

Send your API key as a bearer token. See the Subscriptions page for creating and rotating keys.

shell
Authorization: Bearer hoon_…

Request body

FieldTypeDescription
modelstring · requiredModel identifier — e.g. deepseek-v4-pro. See catalog.
messagesarray · requiredConversation turns. Each item is {role, content}. Roles: system, user, assistant, tool.
temperaturenumber · 0–2Sampling temperature. Default 0.7. Lower = more deterministic.
max_tokensintegerHard cap on completion tokens. Defaults to model max if omitted.
top_pnumber · 0–1Nucleus sampling. Default 1. Use this or temperature, not both.
top_kintegerHoonify extension. Sample from the top-k logits. Default 0 (off).
streambooleanIf true, returns Server-Sent Events instead of one JSON body.
toolsarrayFunction-calling. Same shape as the OpenAI tools array.

Example request

json
{
  "model": "deepseek-ai/DeepSeek-V4-Pro",
  "messages": [
    {"role": "system", "content": "You are a helpful AI assistant."},
    {"role": "user",   "content": "Summarize quantum tunneling in one paragraph."}
  ],
  "temperature": 0.7,
  "max_tokens": 1024,
  "top_p": 0.95,
  "stream": false
}

Response

Non-streaming responses return a single JSON body. Streaming responses are an SSE stream of chat.completion.chunk objects terminated by [DONE].

json
{
  "id": "chatcmpl-FRcX2Fe1k4vR",
  "object": "chat.completion",
  "created": 1745784012,
  "model": "deepseek-ai/DeepSeek-V4-Pro",
  "system_fingerprint": "hoonify-fp8-r12",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Quantum tunneling is the phenomenon where a particle…"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 28,
    "completion_tokens": 142,
    "total_tokens": 170
  }
}

Errors

Errors return the OpenAI-style error envelope: {"error": {"type": ..., "message": ...}}.

StatusTypeCause
400invalid_requestMalformed JSON, unsupported field, or invalid value.
401unauthorizedMissing, malformed, or revoked API key.
404model_not_foundModel ID does not exist or is not available to your org.
409no_capacityNo replica currently available. Retry with backoff.
429rate_limitedPer-key RPM exceeded. Back off and retry with jitter.
503unavailableTemporarily unable to serve the request. Retry with backoff.

Idempotency

For long completions, set X-Hoonify-Idempotency-Keyon retries. Hoonify deduplicates within a 5-minute window — you won't pay twice for a request that succeeded server-side but failed mid-flight back to your client.

Tool calling

Pass tools with JSON-Schema function definitions. The model returns atool_calls array on the assistant message; you execute the call and post the result back as a tool-role message in the next turn. Same shape as the OpenAI tools API — drop-in compatible.