Gemini-native ingress
Leave the google-genai SDK alone and point its base URL at /genai.
POST
https://anyrouter.ir/genai/v1beta/models/{model}:generateContentPOST
https://anyrouter.ir/genai/v1beta/models/{model}:streamGenerateContentLeave the google-genai SDK as it is and point its base URL at /genai. The model and the streaming choice ride in the path, exactly as Google defines them.
from google import genai client = genai.Client( api_key="ir-...", http_options={"base_url": "https://anyrouter.ir/genai"}, ) resp = client.models.generate_content( model="google/gemini-2.5-pro", contents="سلام", )
What is translated
contents/systemInstruction/generationConfigand tools both ways, plususageMetadataon the response.- Images as
inline_data(base64) orfile_data.file_uri. - Authenticate with x-goog-api-key or Authorization — either works, and the value is your ir- key.
Options with no honest equivalent on our primary surface are dropped rather than guessed at:
topK, safetySettings, responseSchema, cachedContent and the thinking budget. If you need them, call the model through chat/completions instead. models.list() works and returns the same catalogue as GET /v1/models, in Google's shape; countTokens is free and returns the same estimate the wallet hold is computed from. embedContent and the other operations are not implemented and are refused in Google's own error shape (404).