HAI Gateway Docs

OpenAI

OpenAI Chat Completions

Creates a model response for the given chat conversation.

POSTv1/chat/completions

Authorizations

Authorizationstringheaderrequired

Use the following format for authentication: Bearer sk-pat-YourAccessToken

The key value is your HAI Gateway Personal Access Token (starting with sk-pat-). No separate API key from OpenAI 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.

Streaming Request Notes

The Chat Completions API does not include usage in streaming responses by default. For billing convenience, this system will always include usage in streaming responses:

  • If the request body does not contain stream_options, {"include_usage": true} will be added automatically
  • If stream_options already exists, include_usage will be forced to true
cURL
cURL:Default
curl https://api.hai.network/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!"
      }
    ]
  }'