SweetRouterAPI

Guides

Going to production

A short checklist so your launch goes smoothly.

Keys

  • Use separate keys for development, staging and production.
  • Keep keys in environment variables on your server, never in client code.
  • If a key leaks, revoke it in the console and create a new one.

Retries and timeouts

The OpenAI SDK retries 429 and server errors for you and waits for Retry-After. Set a retry count and a timeout:

python
client = OpenAI(
    base_url="https://api.sweetrouter.com/v1",
    api_key=os.environ["SWEETROUTER_API_KEY"],
    max_retries=3,   # retries 429 and 5xx with backoff, honours Retry-After
    timeout=60,      # seconds
)

Rate limits

Spread traffic evenly and handle 429 by waiting and retrying. Expecting a lot of traffic? Tell us your peak requests per second before launch and we'll raise your limits. See Limits.

Balance

Requests fail with 402 insufficient_balance when your balance runs out. Check it on the Billing page and top up ahead of busy periods. For invoicing or larger volumes, contact us.

Tracing calls

Each response includes sweetrouter.job_id and an x-request-id header. Log both, and include them when you contact us. You can also send the user field with your own end-user id to match calls to users in your logs.

Launch checklist

  • Production key stored as a server environment variable.
  • Retries and a timeout set in your client.
  • History trimming in place for long chats.
  • Errors shown to users in a friendly way.
  • Enough balance for your expected traffic.