Gemini-native ingress
Leave the google-genai SDK alone and point its base URL at /genai.
POST
https://iranrouter.com/genai/v1beta/models/{model}:generateContentPOST
https://iranrouter.com/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://iranrouter.com/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. embedContentand the other operations are not implemented and are refused in Google's own error shape (404).