Chat Completions
POST /v1/chat/completions
OpenAI's Chat Completions format, for tools that do not speak Responses yet. TokHive converts the request to Responses and converts the result back into a chat.completion object, or a stream of chat.completion.chunk events. Supply, verification and billing are those of Responses. For new code, prefer Responses: it supports more of the model's features.
Example
- cURL
- Python
- TypeScript
curl https://api.tokhive.ai/v1/chat/completions \
-H "Authorization: Bearer $HIVE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6-sol",
"messages": [{"role": "user", "content": "Reply with exactly OK."}]
}'
import os
from openai import OpenAI
client = OpenAI(base_url="https://api.tokhive.ai/v1", api_key=os.environ["HIVE_API_KEY"])
completion = client.chat.completions.create(
model="gpt-6-sol",
messages=[{"role": "user", "content": "Reply with exactly OK."}],
)
print(completion.choices[0].message.content)
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.tokhive.ai/v1", apiKey: process.env.HIVE_API_KEY });
const completion = await client.chat.completions.create({
model: "gpt-6-sol",
messages: [{ role: "user", content: "Reply with exactly OK." }],
});
console.log(completion.choices[0].message.content);
model and a non-empty messages are required. Only OpenAI models are accepted; a Claude model returns 400 wrong_protocol. "stream": true returns chunks as server-sent events, and otherwise a single JSON object is returned.
Supported fields
| Chat field | Behavior |
|---|---|
system, developer, user, assistant messages | Supported. Text and inline user images are converted. system is sent as developer. |
tools, tool_choice | Function tools are supported; other tool types are refused. |
tool_calls and tool messages | Converted to function calls and their outputs. Keep each call together with its result when continuing. |
functions, function_call, function messages | The legacy function format is converted too. |
response_format | json_object and json_schema are supported. |
reasoning_effort | Sets the reasoning effort. The reasoning summary comes back in the extension field reasoning_content. |
parallel_tool_calls, service_tier | Passed through. |
stream | Supported. |
Images must be inline base64 data URLs (PNG, JPEG, GIF or WebP). Remote image URLs are refused, because TokHive does not fetch them.
Ignored fields
temperature, top_p, max_tokens, max_completion_tokens, stop, n, logprobs, user, presence_penalty, frequency_penalty, metadata and similar fields are silently dropped: the subscription upstream does not accept them. Don't rely on them to shape the output, and in particular don't rely on max_tokens to limit its length.
Conversations
A Chat request carries no conversation identity, and TokHive keeps no history between calls. Send the full conversation every time.