Skip to content

Runtime: add a native Google Gemini provider (provider: gemini) #537

Description

@initializ-mk

Summary

forge's runtime supports three model providers today — anthropic, openai, and bedrock. Add Google Gemini as a first-class native provider (provider: gemini), covering both Vertex AI and the Gemini Developer API.

Model this on the native AWS Bedrock Converse provider (#205), not on the openai path.

Why native (not the OpenAI-compat shim)

Gemini's native API is a distinct wire format — generateContent / streamGenerateContent with contents[].parts[], roles user/model, systemInstruction, tools:[{functionDeclarations}], and generationConfig — not chat-completions and not Responses. Google does expose an OpenAI-compatible chat/completions endpoint, but routing through it drops Gemini-native features (Google Search grounding, thinking config, safety settings). So this should be a native provider that speaks generateContent, exactly as bedrock speaks Converse.

Scope

  • Provider impl — forge-core/llm/providers/gemini.go implementing the provider interface (streaming via streamGenerateContent), translating forge's message/tool model to/from Gemini's contents/parts (roles user/model), systemInstruction, functionDeclarations, and generationConfig. Mirror bedrock.go / bedrock_eventstream.go.
  • Factory + client — register gemini in forge-core/llm/providers/factory.go; wire in forge-core/llm/client.go.
  • Config + validation — provider: gemini in forge-core/types/config.go; in forge-core/validate/forge_config.go require the Vertex fields (project + location/region) when in Vertex mode, or an API key for the Developer API — analogous to bedrock requiring aws_region.
  • Auth — Vertex AI via Google ADC / service account (the google-auth chain); Gemini Developer API via API key. Support a base_url override for routing (the ANTHROPIC_BASE_URL analog).
  • forge init — offer Google Gemini as a first-class provider in the TUI and non-interactively (--model-provider gemini + the Vertex project/region or API key), with a default Gemini model list.
  • Tests — mirror bedrock_test.go / responses_test.go (wire-format translation, streaming, tool calls, validation).

Acceptance

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions