Guides
Production checklist
A short list of habits that keep an AI HUB integration reliable and predictable in production.
Keys & caps
- Use one key per environment (dev, staging, production) so that one surface can be revoked without disrupting the others.
- Rotate by creating a new key, switching over, then revoking the old one. Revocation is immediate.
- Set a per-key monthly spend cap to bound blast radius. Past the cap a key returns
402.
Handle errors & retries
Retry 429 and transient 5xx responses with exponential backoff, honoring the Retry-After header. Do not retry 401 or 402: fix the key or top up first.
Python
import time
from openai import OpenAI, RateLimitError
def call_with_retry(client, **kwargs):
for attempt in range(5):
try:
return client.chat.completions.create(**kwargs)
except RateLimitError as e:
wait = int(e.response.headers.get("retry-after", 2 ** attempt))
time.sleep(wait)
raise RuntimeError("exhausted retries")See Errors and Rate limits for the full envelope.
Monitor spend
Poll GET /key to read remaining budget and usage, and keep the wallet funded so calls are not rejected at 402. The console usage page shows per-call cost.