Gemini
Verified : Automated tests passed for: Configuration files: The configuration files on this page were checked against their schema. End-to-end run: Every step ran in a fresh test environment and the results were checked.Route agentgateway LLM traffic to Google Gemini models.
Configure Google Gemini as an LLM provider in agentgateway.
Configuration
You can add the model in the UI or in your configuration file.
To add the model in the UI, follow these steps. The steps create the same model as the Config file tab.
Set your API key in the
GEMINI_API_KEYenvironment variable. The UI checks that the variable exists when you save the model.export GEMINI_API_KEY='<your-api-key>'Create a configuration file with an empty
llmsection, and start agentgateway in the same terminal. Without anllmsection, the UI does not show the LLM > Models page.cat > config.yaml <<'EOF' # yaml-language-server: $schema=https://agentgateway.dev/schema/config llm: models: [] EOF agentgateway -f config.yamlOpen LLM > Models, such as http://localhost:15000/ui/llm/models, and click Add model.
From the Provider dropdown, select Gemini.
Keep the default
gemini/*in the Incoming model match field.For the Provider API key, select Env var, and enter
GEMINI_API_KEY.For Outgoing model, keep Strip gemini/. This option removes the
gemini/prefix before the request is forwarded. To send every request to one model instead, select Explicit, and enter the model name. This option setsparams.model.

Click Save model.
Whether the UI can save depends on your storage mode. For more information, see Save changes from the UI.
Reasoning effort
Set reasoning_effort in OpenAI-compatible Chat Completions requests to a Gemini model to configure Gemini thinking. For Gemini 2.5 and older models, reasoning_effort maps to thinkingConfig.thinkingBudget. For Gemini 3 and Gemini 4 models, reasoning_effort maps to thinkingConfig.thinkingLevel.
| Model family | reasoning_effort behavior |
|---|---|
| Gemini 2.5 and older | minimal, low, medium, high, xhigh, and max use thinkingBudget values. none omits thinkingConfig. |
| Gemini 3 | minimal, low, medium, high, xhigh, and max use thinkingLevel. none omits thinkingConfig. |
| Gemini 4 | minimal and low use thinkingLevel: "low". medium uses thinkingLevel: "medium". high, xhigh, and max use thinkingLevel: "high". none omits thinkingConfig. |
For Gemma 4 models, none, minimal, and low use thinkingLevel: "minimal", and medium, high, xhigh, and max use thinkingLevel: "high".
Use Decisions and SystemOne
Gemini decision models, such as gemini-decision-1, can answer OpenAI Decisions (/v1/decisions) and TypeSafe SystemOne (/v1/systemone) requests. Agentgateway converts both formats to the Gemini Decisions API (/v1beta/decisions) and converts the answers back to the client’s format. The conversion is best effort.
With the llm configuration, both paths are mapped automatically. Add a model entry for the decision model.
# yaml-language-server: $schema=https://agentgateway.dev/schema/config
llm:
models:
- name: gemini-decision-1
provider: gemini
params:
apiKey: "$GEMINI_API_KEY"Send a Decisions request.
curl "localhost:4000/v1/decisions" -H content-type:application/json -d '{
"model": "gemini-decision-1",
"input": [{"role": "user", "content": [{"type": "input_text", "text": "The package was left in the rain and the box is soaked through."}]}],
"questions": [{"type": "predicate", "name": "visible_damage", "instructions": "Does the customer report visible damage to the package?"}]
}' | jqExample output:
{
"model": "gemini-decision-1",
"answers": [
{"type": "predicate", "name": "visible_damage", "probability": 0.64}
],
"usage": {"input_tokens": 156, "output_tokens": 0, "total_tokens": 156, ...}
}For the supported request content, see Decisions.
Use structured outputs
For OpenAI-compatible Chat Completions requests, setresponse_format.type to json_schema to request structured JSON from a Gemini model. Agentgateway sends the schema to Gemini as responseJsonSchema. Standard JSON Schema keywords, such as $defs, $ref, anyOf, and additionalProperties, pass through unchanged. Tool definitions are handled differently. For schemas in tools[].function.parameters, agentgateway inlines $defs and $ref, removes fields that Gemini does not support, such as additionalProperties, and keeps a propertyOrdering field that you set.curl "localhost:4000/v1/chat/completions" -H content-type:application/json -d '{
"model": "gemini/gemini-2.5-flash",
"messages": [
{
"role": "user",
"content": "Return one calendar event for tomorrow."
}
],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "calendar_event",
"strict": true,
"schema": {
"$defs": {
"CalendarEvent": {
"type": "object",
"additionalProperties": false,
"properties": {
"name": { "type": "string" },
"date": { "type": "string" }
},
"required": ["name", "date"]
}
},
"type": "object",
"additionalProperties": false,
"properties": {
"event": { "$ref": "#/$defs/CalendarEvent" }
},
"required": ["event"]
}
}
}
}' | jqExample output, in which content is a JSON string that matches the schema:
{
"model": "gemini-2.5-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "{\"event\":{\"name\":\"Team sync\",\"date\":\"2026-11-25\"}}"
},
"finish_reason": "stop"
}
],
...
}Send images and files in Responses requests
For Gemini, agentgateway converts an OpenAI Responses request to Chat Completions. Gemini has no Chat Completions file part, so the conversion sends both images and files as image_url parts.
- An
input_imagepart must setimage_url. - An
input_filepart must carry the file as a base64 data URL, such asdata:application/pdf;base64,<base64>, infile_dataorfile_url. Thefilenameis not sent.
The conversion rejects a file that sets only file_id, a file_data value that is not a data URL, and a remote URL in file_url. It also rejects an image or file in a system, developer, or assistant message.