# Google Gemini-compatible API (/en/docs/api/compatible/google)



## Base URL [#base-url]

<ApiBaseDomain prefix="/google" />

## Get started [#get-started]

<QuickstartTabs snippets="{&#x22;curl&#x22;:&#x22;curl https://api-origin.invalid/google/v1beta/models/gemini-2.5-flash:generateContent \\\n  -H \&#x22;x-goog-api-key: $PRAXIS_API_KEY\&#x22; \\\n  -H \&#x22;Content-Type: application/json\&#x22; \\\n  -d '{\&#x22;contents\&#x22;:[{\&#x22;role\&#x22;:\&#x22;user\&#x22;,\&#x22;parts\&#x22;:[{\&#x22;text\&#x22;:\&#x22;你好\&#x22;}]}]}'&#x22;,&#x22;python&#x22;:&#x22;import os\n\nfrom google import genai\nfrom google.genai import types\n\nclient = genai.Client(\n    api_key=os.environ[\&#x22;PRAXIS_API_KEY\&#x22;],\n    http_options=types.HttpOptions(base_url=\&#x22;https://api-origin.invalid/google\&#x22;),\n)\n\nresp = client.models.generate_content(\n    model=\&#x22;gemini-2.5-flash\&#x22;,\n    contents=\&#x22;你好\&#x22;,\n)\nprint(resp.text)&#x22;,&#x22;typescript&#x22;:&#x22;import { GoogleGenAI } from \&#x22;@google/genai\&#x22;;\n\nconst ai = new GoogleGenAI({\n  apiKey: process.env.PRAXIS_API_KEY,\n  httpOptions: { baseUrl: \&#x22;https://api-origin.invalid/google\&#x22; },\n});\n\nconst resp = await ai.models.generateContent({\n  model: \&#x22;gemini-2.5-flash\&#x22;,\n  contents: \&#x22;你好\&#x22;,\n});\nconsole.log(resp.text);&#x22;}" />

## Available models [#available-models]

* The model name in the path is a platform model name (such as `gemini-2.5-flash`); see [list models](/en/docs/api/compatible/google/listModels). Only models that declare Google protocol support can be called here; other models return 404.
* For image output, include `IMAGE` in `generationConfig.responseModalities`; the request is served by the platform's image models.
* Forcing a tool (`toolConfig` mode `ANY`) on a thinking model is passed through to the model just like the native Gemini API: the model decides, and a rejection comes back as a Google-formatted 400 error.

## Endpoints [#endpoints]

| Method | Path                                                                                                   | Description               | Support     |
| ------ | ------------------------------------------------------------------------------------------------------ | ------------------------- | ----------- |
| POST   | [`/v1beta/models/{modelsId}:generateContent`](/docs/api/compatible/google/generateContent)             | Generate content          | ● Supported |
| POST   | [`/v1beta/models/{modelsId}:streamGenerateContent`](/docs/api/compatible/google/streamGenerateContent) | Stream generated content  | ● Supported |
| POST   | [`/v1beta/models/{modelsId}:countTokens`](/docs/api/compatible/google/countTokens)                     | Count tokens              | ◐ Partial   |
| POST   | [`/v1beta/models/{modelsId}:embedContent`](/docs/api/compatible/google/embedContent)                   | Generate an embedding     | ● Supported |
| POST   | [`/v1beta/models/{modelsId}:batchEmbedContents`](/docs/api/compatible/google/batchEmbedContents)       | Generate batch embeddings | ● Supported |
| GET    | [`/v1beta/models`](/docs/api/compatible/google/listModels)                                             | List models               | ● Supported |
| GET    | [`/v1beta/models/{modelsId}`](/docs/api/compatible/google/getModel)                                    | Get a model               | ● Supported |

## Differences from Gemini API [#differences-from-gemini-api]

* <a href="/docs/api/compatible/google/generateContent">Generate content</a>：Forced tool use in toolConfig (functionCallingConfig mode ANY, including allowedFunctionNames) is forwarded unchanged on thinking models too — the same as the native Gemini API, so whether it is accepted is up to the upstream model; if the upstream answers 400, the error keeps the Google format and carries the upstream code and status.
* <a href="/docs/api/compatible/google/countTokens">Count tokens</a>：Returns a model-family-calibrated estimate, including Chinese text and tool definitions, with the response header x-praxis-token-count: estimated. Do not use it as an exact usage or billing count.
* <a href="/docs/api/compatible/google/embedContent">Generate an embedding</a>：Only text parts are accepted; images and other multimodal parts are rejected. taskType, title and retrieval settings such as autoTruncate / documentOcr / audioTrackExtraction have no equivalent on the platform: a request that carries them gets 400 (INVALID\_ARGUMENT) instead of being silently ignored, because different taskType values produce vectors that behave differently and dropping one would quietly change retrieval quality. outputDimensionality maps to the dimension of the returned vector.
* <a href="/docs/api/compatible/google/batchEmbedContents">Generate batch embeddings</a>：Each entry in requests follows the same rules as embedContent (text parts only, same rejections); every entry in a batch must use the same outputDimensionality. The current official JS and Python SDKs actually call this batch endpoint for embedContent.
* <a href="/docs/api/compatible/google/listModels">List models</a>：Embedding models are listed with embedContent as their only supported method. While the model catalog is temporarily unavailable, generateContent keeps working: requests that explicitly ask for image output (responseModalities includes IMAGE) still go to the image route, and older image requests that do not say so are handled as text chat for that window — every response during the fallback carries the X-Praxis-Route-Degraded: model-catalog-unavailable header so you can tell.

For authoritative parameter definitions, see the [official Gemini API documentation](https://ai.google.dev/api).

Errors follow the Gemini API format, see [errors](/docs/api/errors); quotas and response headers are covered in [rate limits](/docs/api/rate-limits).
