Source: https://ailoot.ai/docs/integrations/google-genai-python/
Canonical: https://ailoot.ai/docs/en/integrations/google-genai-python/
Language: en

[SDKs and frameworks](https://ailoot.ai/docs/en/integrations/#sdk) 

# Google GenAI SDK (Python)

[Markdown](https://ailoot.ai/docs/en/integrations/google-genai-python/index.md)

SDK · Gemini

| Format | Where to set it up |
| --- | --- |
| Gemini | genai.Client(api\_key=..., http\_options=types.HttpOptions(base\_url=...)) |

## [](https://ailoot.ai/docs/integrations/google-genai-python/#setup)Setup

Copy the configuration and replace `sk-...` with your key from the Ailoot Dashboard. Prefer storing the key in the environment variable `AILOOT_API_KEY`, if the application supports it.

Before starting, request GET /v1/models with your Ailoot key. Choose an exact model ID whose methods include POST /v1beta/models/{model}:generateContent, then use that ID in the configuration. For agents, also check tool support and the features required by your client version.

```python
import os
from google import genai
from google.genai import types
client = genai.Client(
    api_key=os.environ["AILOOT_API_KEY"],
    http_options=types.HttpOptions(base_url="https://api.ailoot.ai"))
r = client.models.generate_content(model="gemini-3.6-flash", contents="Hello")
print(r.text)
```

Example model: `gemini-3.6-flash, gemini-3.1-pro`. Choose any other model from the [catalog](https://ailoot.ai/models/en/) — check that it supports the format you need.

## [](https://ailoot.ai/docs/integrations/google-genai-python/#notes)Good to know

Use a URL without /v1beta: the SDK builds /v1beta/models/{model}:generateContent. The key is sent in the x-goog-api-key header, which Ailoot accepts. Only models supporting the Gemini format are available. The documentation for the JavaScript version (@google/genai) does not describe a custom endpoint, so it is not included here.

## [](https://ailoot.ai/docs/integrations/google-genai-python/#check)Test

- For the Gemini format, the URL is `https://api.ailoot.ai` without `/v1beta`.
- Ask a short question. If you get an error, check the code and Request ID, then consult [Errors and limits](https://ailoot.ai/docs/en/errors/).
- `404`: `https://api.ailoot.ai` → `/v1beta/models/{model}:generateContent`. Before starting, request GET /v1/models with your Ailoot key. Choose an exact model ID whose methods include POST /v1beta/models/{model}:generateContent, then use that ID in the configuration. For agents, also check tool support and the features required by your client version.
- 402 — insufficient balance for the reserve. Agents reserve more than chat: [why](https://ailoot.ai/docs/en/billing/reserve/).

Application documentation: [https://github.com/googleapis/python-genai#custom-base-url](https://github.com/googleapis/python-genai#custom-base-url)

Still have questions? Send your Request ID and a description — we'll help you troubleshoot.[Contact support](mailto:support@ailoot.ai)

## Ailoot · The company and its project portfolio





Ailoot combines established operating experience, a large client base, stable service and ongoing KPI control.





The company and its project portfolio: millions of customers; monthly sales in the billions.





Ailoot brings that operating experience to API access for AI features in customer products, agents, applications and automations.
