Skip to content

agentix.providers.gemini

gemini

Google Gemini model adapter (google-genai SDK).

Translates agentix types to Gemini's generate_content shape — contents with user/model roles and typed parts (text / function_call / function_response). Install with pip install "agentix[gemini]".

Everything is built as plain dict (the SDK accepts dict contents / config / function declarations), so no google.genai.types import is needed and the translation is unit-testable with a bare fake client.

Note: Gemini function calls carry no call id — tool results are matched back by name. Parallel calls to the same tool in one turn can't be disambiguated; that's a Gemini-protocol limitation, not an agentix one.

GeminiModel

GeminiModel(
    *,
    model: str = DEFAULT_MODEL,
    api_key: str | None = None,
    client: Any = None,
    **extra: Any,
)

A :class:~agentix.model.ModelFn backed by Gemini generate_content.

extra is merged into the request config (e.g. temperature, max_output_tokens, response_mime_type / response_schema for JSON). For tests, inject client= — any object exposing client.aio.models.generate_content(...).

with_response_format

with_response_format(schema: dict[str, Any]) -> GeminiModel

Return a copy that enforces JSON output against schema via Gemini's response_mime_type / response_schema (used by response_model).