HAI Gateway Docs

Best Practices

Security and efficiency recommendations

Token Security

Your Access Token is a master key — never put it in frontend code, commit it to Git, or write it to logs. Use environment variables and secret management systems, and rotate tokens regularly.

Server-Side Forwarding

Store your token on your own server and have it call the Relay API, preventing the token from being exposed in the browser.

Least Privilege

Create separate tokens for different applications with monthly limits. This makes it easy to isolate and contain issues.

Pre-Check & Quotas

For large context calls, use the Token Count endpoint to estimate costs before sending the request.

Quick Start

Use the available-relay-rules endpoint to get available model + endpoint combinations, then select the corresponding provider Base URL and send requests in the official format.