Unified API (Preview)
Unified API Chat Completions
Call OpenAI, Anthropic, Google, and other providers through a single OpenAI-format endpoint. The gateway detects each model's native schema and performs the conversion transparently.
v1/chat/completionsThis endpoint is currently in gated rollout and is available to a limited set of tenants only. If your request returns a permission error, your account has not been added to the allowlist yet. For production, please use the stable native endpoints (/openai, /anthropic, /google). API behavior may change in future releases during the preview without prior notice.
Authorizations
Use the following format for authentication: Bearer sk-pat-YourAccessToken
The key value is your HAI Gateway Personal Access Token (starting with sk-pat-), identical to the OpenAI Relay channel. No separate API key from any upstream provider is required.
Base URL
Body Parameters
The request body format is fully compatible with the official OpenAI Chat Completions API. For detailed parameter descriptions, refer to the OpenAI official documentation.
Set model to any configured model ID (retrieve the full list via List Models). The gateway automatically detects its native schema:
- OpenAI / compatible providers: passthrough, no format conversion
- Anthropic (
claude-*): converted to Anthropic Messages format upstream; response stream is translated back to OpenAI chunks - Google (
gemini-*): converted to GooglegenerateContentupstream; response stream is translated back to OpenAI chunks
Streaming Request Notes
Consistent with the native OpenAI endpoint, this endpoint always returns usage in streaming responses:
- If the request body does not contain
stream_options,{"include_usage": true}is added automatically - If
stream_optionsalready exists,include_usageis forced totrue
Preview-period Feature Limitations
When calling Anthropic / Google models through the unified endpoint, the following features are unavailable or behave differently. If you need these capabilities, use the native endpoints for the respective providers:
- Basic tool calling: the format is mappable, but parallel calls and
tool_choicesemantics differ - Structured output: implementations diverge too much across providers; not supported
- Extended thinking / reasoning: Anthropic thinking blocks and OpenAI reasoning are provider-specific; not supported
- Prompt caching: Anthropic's explicit
cache_controlhas no OpenAI counterpart; not supported
curl https://api.hai.network/unified-preview/openai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-pat-YourAccessToken" \
-d '{
"model": "gpt-5.4-2026-03-05",
"messages": [
{
"role": "developer",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello!"
}
]
}'{
"id": "chatcmpl-9XYZ...",
"object": "chat.completion",
"created": 1741132800,
"model": "claude-opus-4-6",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! How can I help you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 10,
"total_tokens": 22
}
}