generateContent API by default. You can switch those requests back to
Gemini’s OpenAI-compatible API when you need compatibility behavior that the
native adapter does not implement yet.
Configure AI Studio
Use theGEMINI_* prefix for Gemini API keys from AI Studio:
config.yaml:
Native versus OpenAI-compatible mode
Gemini native mode is enabled by default:openai_compatible to route chat and
Responses API requests through the upstream OpenAI-compatible
/chat/completions endpoint:
GEMINI_BASE_URL configures the Gemini base. GoModel keeps separate internal
bases for native Gemini and the OpenAI-compatible API:
- native chat/models default:
https://generativelanguage.googleapis.com/v1beta - OpenAI-compatible default:
https://generativelanguage.googleapis.com/v1beta/openai
GEMINI_BASE_URL ends in /openai, GoModel uses that value for the
OpenAI-compatible client and derives the native base by stripping /openai.
Gemini embeddings, files, and batches still use the OpenAI-compatible surface.
USE_GOOGLE_GEMINI_NATIVE_API is still supported as a legacy global toggle
when per-provider GEMINI_API_MODE is unset. Prefer GEMINI_API_MODE for
new deployments.Image URL behavior
Gemini models support image input, but the two GoModel routing modes handle OpenAI-styleimage_url values differently.
In native mode, GoModel converts OpenAI-compatible messages to Gemini
generateContent requests. That adapter currently supports inline image data
only:
https://example.com/image.png are rejected in
native mode. Google’s native Gemini API supports inline image data and Files
API references; for URL-hosted images, Google’s examples fetch the URL first
and send the bytes to generateContent.
Set GEMINI_API_MODE=openai_compatible when you need GoModel to pass the
OpenAI-compatible image_url request shape through to Google’s
OpenAI-compatible endpoint instead. Google documents image input for that
endpoint using the OpenAI image_url field.
Current support
Integrated:- chat completions and streaming
- Responses API and streaming
- model listing through AI Studio
/models - usage metadata normalization for native responses
- tool calls and function-call results
- inline image data via
data:URLs in native mode
- fetching remote
image_urlvalues - uploading remote images through the Gemini Files API before a chat request