Chat Completions (OpenAI-Compatible LLMs)

How to access Hive's self-hosted large language models through the OpenAI-compatible Chat Completions API.

This is a shared reference for all LLMs served on the /api/v3/chat/completions streaming path. The access mechanics — endpoint, auth, streaming, response shape, billing, errors — are identical across models. The details that vary per model (model key, context window, pricing, capabilities) are listed under Available models.

What this API is

You can prompt a model with the standard OpenAI chat-completions format and receive a streamed text response. It acts as a provider for coding agent harnesses, or as a drop-in for the OpenAI SDK — point the client at Hive's base URL and use your Hive Secret Key.

  • OpenAI-compatible — same request/response shape as OpenAI's /chat/completions.
  • Streaming responses — token-by-token SSE output.

Streaming is required

LLMs on this path currently serve streaming only.


Quickstart

Coding Agents

Configure your agent harness to use Hive as a model provider. Specify Hive's base URL, the desired model name from Available Models, and your Hive API Key.

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "hive-ai": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "Hive",
      "options": {
        "baseURL": "https://api.thehive.ai/api/v3",
        "apiKey": "{YOUR_API_KEY}"
      },
      "models": {
        "zai-org/glm-5.3-flash": {
          "name": "GLM 5.3 Flash",
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          }
        }
      }
    }
  }
}

Point the OpenAI SDK at Hive's base URL and set stream=True. Swap in the model key you want from Available models.

Python (OpenAI SDK)

from openai import OpenAI

client = OpenAI(
    base_url="https://api.thehive.ai/api/v3/",
    api_key="<YOUR_SECRET_KEY>",
)
stream = client.chat.completions.create(
    model="zai-org/glm-5.3-flash",
    messages=[
        {"role": "user", 
         "content": "Explain TCP and UDP in two sentences."
        }
    ],
    stream=True,
    extra_headers={"Accept": "text/event-stream"},
)
for chunk in stream:
    if chunk.choices and chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
    if chunk.usage:
        print(f"\n\n[usage] {chunk.usage}")

cURL

curl https://api.thehive.ai/api/v3/chat/completions \
  -H "Authorization: Bearer <YOUR_SECRET_KEY>" \
  -H "Content-Type: application/json" \
  -H "Accept: text/event-stream" \
  -d '{
    "model": "zai-org/glm-5.3-flash",
    "messages": [{"role": "user", "content": "Hello!"}],
    "stream": true
  }'

Try our Playground UI if you'd like to start testing GLM-5.3-Flash right away!

NOTE! For our Virginia (VA1) customers, use URL: https://api-va1.thehive.ai/api/v3/chat/completions

Create your V3 API Key

  1. Click ‘Service API Keys’ in the sidebar.
  2. Click ‘Create API Key’ to create a new key scoped to your organization. This key can be used with any "Playground Available" model.
  3. Copy the Secret Key and use it as the Authorization: Bearer <SECRET_KEY> header (the OpenAI SDK's api_key).
⚠️

Keep your Secret Key safe — do not share it or embed it client-side.


Multi-turn conversations

There's no server-side conversation state — each call is stateless. To continue a conversation, resend the full message history on every request:

messages = [
    {"role": "user", "content": "What's a good name for a pet turtle?"},
    {"role": "assistant", "content": "How about Shelldon?"},
    {"role": "user", "content": "Give me three more."},
]

Parameters

FieldTypeDefinition
modelstringRequired. The model key (see Available models).
messagesarrayRequired. Conversation history. Each object has a role (user or assistant) and content (string).
streamboolRequired — must be true. Routes the request to the streaming path.
max_tokensintOutput token cap.
temperaturefloatRandomness. 0 = deterministic.
top_pfloatNucleus sampling cutoff.
top_kintLimits sampling to the top K tokens.

Response format (SSE)

The response is a stream of Server-Sent Events, each an OpenAI-style chat.completion.chunk. Content arrives incrementally in choices[0].delta.content:

data: {"id":"...","object":"chat.completion.chunk","model":"<MODEL_KEY>","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}

data: {"id":"...","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":" there"},"finish_reason":null}]}

The stream ends with a final usage chunk (empty choices, populated usage) followed by data: [DONE] :

data: {"id":"...","object":"chat.completion.chunk","choices":[],"usage":{"prompt_tokens":18,"completion_tokens":42,"total_tokens":60}}

data: [DONE]

Usage is always included - you don't need to request stream_options.include_usage yourself.


Tool calling

Some models support OpenAI-style tool/function calling. When supported, pass tools in the request and read tool-call deltas off choices[0].delta.tool_calls in the stream. Support is per-model — check the capability column in Available models.


Billing

Models are billed by token, reported in the final usage chunk. Billing supports the full OpenAI usage breakdown (input, output, cached read, cache write, reasoning, audio, accepted/rejected prediction tokens), but most text models charge only input tokens and output tokens (plus cached input read tokens where applicable). The exact SKUs billed per model are noted in Available models.


Rate limits & common errors

Default rate limit is 5 requests/second. Contact us to request a higher limit.

Too Many Requests (429)

{ "status_code": 429, "message": "Too Many Requests" }

Out of Balance (405) — a positive Organization Credit balance is required.

{
  "status_code": 405,
  "message": "Your Organization is currently paused. Please check your account balance, our terms and conditions, or contact [email protected] for more information."
}

Available models

ModelModel keyContext windowBilled tokensInput Modality
GLM-5.3-Flashzai-org/glm-5.3-flash1 million tokensInput, Output, Cached ReadText, Image, Video