Gemini compatibility
Gemini model IDs are encoded in the request path. GM supports
generateContent and SSE streamGenerateContent.
Python
Section titled “Python”import osfrom google import genaifrom google.genai import types
client = genai.Client( api_key=os.environ["GM_API_KEY"], http_options=types.HttpOptions(base_url="https://api.saygm.com"),)
response = client.models.generate_content( model="gemini-2.5-pro", contents="Say gm.",)print(response.text)curl "https://api.saygm.com/v1beta/models/gemini-2.5-pro:generateContent" \ -H "Authorization: Bearer $GM_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "contents": [{"role": "user", "parts": [{"text": "Say gm."}]}] }'For streaming, use :streamGenerateContent?alt=sse. GM requires alt=sse and
does not support Gemini’s legacy JSON-array streaming format.
Usage and cost
Section titled “Usage and cost”Every successful response carries settled cost inside usageMetadata,
alongside the normal token counts, using Gemini’s camelCase convention:
{ "usageMetadata": { "promptTokenCount": 12, "candidatesTokenCount": 9, "totalTokenCount": 21, "cost": 0.000140000, "costNanoUsd": 140000 }}cost is USD, rendered as a JSON number with exactly nine fractional digits —
the amount actually settled against the account’s prepaid balance, not an
estimate from /v1/models rates. costNanoUsd is the same amount as an
integer in nano-USD (1 nUSD = 10⁻⁹ USD), matching GET /v1/credits. Error
responses carry neither field. See
per-request cost for how to use the
figure.