HAI Gateway Docs

Unified API (Preview)

Unified API Embeddings

Generate vector embeddings using the OpenAI-format request. During preview, only OpenAI-family embedding models are supported as passthrough.

POSTv1/embeddings
Preview · Gated Rollout

This 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

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-), 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 Embeddings API. For detailed parameter descriptions, refer to the OpenAI official documentation.

OpenAI-family Passthrough Only

During preview, the embedding channel supports only OpenAI and compatible-provider embedding models (e.g. text-embedding-3-small, text-embedding-3-large). Requests passing embedding models from other providers such as Google will return an unsupported-model error. Google embedContent and other cross-provider embedding conversions are planned for a future iteration.

cURL
Default
cURL:Default
curl https://api.hai.network/unified-preview/openai/v1/embeddings \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-pat-YourAccessToken" \
  -d '{
    "model": "text-embedding-3-small",
    "input": "The quick brown fox jumps over the lazy dog"
  }'
200
Default
200:Default
{
  "object": "list",
  "data": [
    {
      "object": "embedding",
      "index": 0,
      "embedding": [
        0.0023064255,
        -0.009327292,
        "..."
      ]
    }
  ],
  "model": "text-embedding-3-small",
  "usage": {
    "prompt_tokens": 9,
    "total_tokens": 9
  }
}