Skip to main content
Keep the SDK you use. Change two things: its base URL, to the AI Gateway, and its API key, to your virtual key. Each SDK sends the key in its usual header, and Altrum reads it there. Every example reads the key from the ALTRUM_VIRTUAL_KEY environment variable.
Any of these clients can call any model your key allows: the provider prefix in the model name decides where the request goes. The Google SDK cannot list models through Altrum. See the API reference.

Send Altrum headers

To use a saved prompt, steer the cache or set your own request reference, send the request headers with the client or with one request:

Handle a refusal

When a guardrail, a budget or a rate limit stops a request, the SDK raises its usual API error, with the status and a message from Altrum saying what stopped it. Catch it as you catch any provider error. Handle errors shows which errors to retry and has code to copy, and Errors lists every code.