> For the complete documentation index, see [llms.txt](https://weavescope.gitbook.io/beam_weaver/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://weavescope.gitbook.io/beam_weaver/partners/google.md).

# Google

BeamWeaver includes a Gemini Developer API provider under `BeamWeaver.Google`.

## Implemented

* `BeamWeaver.Google.ChatModel` implements `BeamWeaver.Core.ChatModel`.
* Public model identifiers use the `google:` provider prefix, for example `google:gemini-3.5-flash`.
* Bare `gemini-*` identifiers are intentionally rejected so Gemini Developer API and future Vertex AI adapters do not share an ambiguous namespace.
* Requests go through `BeamWeaver.Transport`, so fake and replay transports can exercise provider behavior without live credentials.
* Namespace constructors load defaults from `config :beam_weaver, :google`; put any OS environment reads in your `config/runtime.exs`. Custom routing can use configured `:base_url`, explicit `:base_url`, or `:endpoint`.
* BeamWeaver messages become Gemini `contents` plus top-level `systemInstruction`.
* Custom tools become Gemini function declarations. Google built-ins such as Google Search, Google Maps, URL context, code execution, File Search, MCP servers, and model-specific computer use are pass-through provider request values.
* Gemini function parameter schemas are provider-sanitized: local `$ref` entries are dereferenced, unsupported JSON Schema annotation/object keywords such as `$defs`, `title`, `default`, and `additionalProperties` are removed, and nested property schemas are cleaned recursively.
* `google:gemini-3.5-flash` is checked in with Google's published text-only output profile: text, image, video, audio, and PDF input are supported; text output, thinking, structured output, function calling, code execution, File Search, Google Maps grounding, Search grounding, URL context, caching, batch, flex, and priority inference are supported; image generation, audio generation, Live API, and computer use are not advertised.
* Responses include normalized usage, reasoning/thinking token metadata, safety ratings, grounding metadata, model version, request IDs, and raw provider metadata.
* Streaming supports text deltas, typed stream envelopes, and reconstructed final assistant messages.
* Checked-in model profiles cover current recommended Gemini chat models. Deprecated or near-shutdown models such as Gemini 2.0 Flash, Gemini 2.5 Flash, Gemini 2.5 Pro, and Gemini 3 Flash Preview are rejected with a `:deprecated_model` error and replacement metadata; explicit `google:gemini-*` identifiers still use the family fallback for uncataloged current model IDs.

## Usage

```elixir
{:ok, model} =
  BeamWeaver.Models.init_chat_model("google:gemini-3.5-flash",
    thinking_budget: 512,
    include_thoughts: true
  )

BeamWeaver.Core.ChatModel.invoke(model, [
  BeamWeaver.Core.Message.user("Summarize the tradeoffs in one paragraph.")
])
```

Provider tools are request values:

```elixir
tools = [
  BeamWeaver.Google.Tools.google_search(),
  BeamWeaver.Google.Tools.google_maps(),
  BeamWeaver.Google.Tools.code_execution(),
  BeamWeaver.Google.Tools.file_search(["fileSearchStores/my_store"]),
  my_local_tool
]

BeamWeaver.Core.ChatModel.invoke(model, messages, tools: tools, tool_choice: :auto)
```

Structured output maps to Gemini generation config:

```elixir
BeamWeaver.Core.ChatModel.invoke(model, messages,
  response_format: %{
    schema: %{
      type: :object,
      properties: %{answer: %{type: :string}},
      required: [:answer]
    }
  }
)
```

When a structured-output request does not set `:max_output_tokens`, BeamWeaver uses the model profile's output limit for Gemini. For example, `google:gemini-3.5-flash` defaults structured-output calls to `65_536` `maxOutputTokens`, while an explicit `max_output_tokens:` value still wins.

Token counting uses Gemini's count-tokens endpoint:

```elixir
BeamWeaver.Google.ChatModel.count_tokens(model, [
  BeamWeaver.Core.Message.user("Count this.")
])
```

## Remaining Google Work

* Live-cassette expansion against the Gemini Developer API.
* Vertex AI. That should be a separate explicit adapter/prefix rather than an alias of `google:*`.
* Dedicated image, audio, and video generation model modules beyond chat response modality options.
* Exact Python class identity and serialization compatibility. BeamWeaver keeps native Elixir modules, structs, and tagged errors.

## Related Guides

* [Models](/beam_weaver/core-components/models.md)
* [Tools](/beam_weaver/core-components/tools.md#server-side-provider-tools)
* [Messages](/beam_weaver/core-components/messages.md#standard-content-blocks)
* [Structured Output](/beam_weaver/core-components/structured_output.md)
* [Tracing](/beam_weaver/operations/tracing.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://weavescope.gitbook.io/beam_weaver/partners/google.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
