> ## Documentation Index
> Fetch the complete documentation index at: https://dev-docs.altrum.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# SDKs

> Point the OpenAI, Anthropic and Google SDKs at the AI Gateway by changing the base URL and the key.

<Info>This is in development. Details may change before it is available.</Info>

Keep the SDK you use. Set its base URL to the AI Gateway and its API key to your virtual key. Each example reads the key from the `ALTRUM_VIRTUAL_KEY` environment variable.

<Tabs>
  <Tab title="OpenAI">
    ```python theme={null}
    import os
    from openai import OpenAI

    client = OpenAI(base_url="https://api.altrum.ai/openai/v1", api_key=os.environ["ALTRUM_VIRTUAL_KEY"])

    reply = client.chat.completions.create(
        model="openai/gpt-4o-mini",
        messages=[{"role": "user", "content": "Summarise this ticket in one line."}],
    )
    print(reply.choices[0].message.content)
    ```

    ```typescript theme={null}
    import OpenAI from 'openai'

    const client = new OpenAI({ baseURL: 'https://api.altrum.ai/openai/v1', apiKey: process.env.ALTRUM_VIRTUAL_KEY })

    const reply = await client.chat.completions.create({
      model: 'openai/gpt-4o-mini',
      messages: [{ role: 'user', content: 'Summarise this ticket in one line.' }],
    })
    console.log(reply.choices[0].message.content)
    ```
  </Tab>

  <Tab title="Anthropic">
    ```python theme={null}
    import os
    from anthropic import Anthropic

    client = Anthropic(base_url="https://api.altrum.ai/anthropic", api_key=os.environ["ALTRUM_VIRTUAL_KEY"])

    reply = client.messages.create(
        model="anthropic/claude-sonnet-4-5",
        max_tokens=256,
        messages=[{"role": "user", "content": "Summarise this ticket in one line."}],
    )
    print(reply.content[0].text)
    ```
  </Tab>

  <Tab title="Google">
    ```python theme={null}
    import os
    from google import genai
    from google.genai import types

    client = genai.Client(
        api_key=os.environ["ALTRUM_VIRTUAL_KEY"],
        http_options=types.HttpOptions(base_url="https://api.altrum.ai/genai"),
    )

    reply = client.models.generate_content(
        model="gemini/gemini-2.5-flash",
        contents="Summarise this ticket in one line.",
    )
    print(reply.text)
    ```
  </Tab>
</Tabs>

Any of these clients can call any model your key allows: the provider prefix in the model name decides where the request goes. See [Endpoints](/ai-gateway/endpoints).

## Handle a refusal

When a guardrail blocks a request, a budget is spent or a rate limit is reached, the SDK raises its usual API error with a message from Altrum that says what stopped the request and what to do. Catch it as you catch provider errors.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.