diff --git a/.github/workflows/google-contributor-stale.yml b/.github/workflows/google-contributor-stale.yml new file mode 100644 index 000000000..ebff9cfcd --- /dev/null +++ b/.github/workflows/google-contributor-stale.yml @@ -0,0 +1,29 @@ +# This workflow closes PRs that have had no activity for 14 days. +name: Close inactive google-contributor PRs + +on: + schedule: + - cron: "30 2 * * *" + workflow_dispatch: {} + +jobs: + stale: + runs-on: ubuntu-latest + permissions: + pull-requests: write + issues: write + + steps: + - uses: actions/stale@v10 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + any-of-labels: "google-contributor" + days-before-pr-stale: 14 + days-before-pr-close: 0 + operations-per-run: 100 + stale-pr-label: "status:stale" + exempt-pr-labels: "override-stale" + close-pr-message: > + This google-contributor PR has been inactive for 14 days. + days-before-issue-stale: -1 + days-before-issue-close: -1 diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 5fdcb436f..97426337d 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -3,8 +3,9 @@ name: Mark and close stale issues on: schedule: - # Scheduled to run at 1:30 UTC everyday - - cron: '30 1 * * *' + # Scheduled to run at 1:30 UTC everyday + - cron: '30 1 * * *' + workflow_dispatch: {} jobs: stale: @@ -14,11 +15,12 @@ jobs: issues: write steps: - - uses: actions/stale@v5 + - uses: actions/stale@v10 with: repo-token: ${{ secrets.GITHUB_TOKEN }} days-before-issue-stale: 7 days-before-issue-close: 2 + operations-per-run: 100 stale-issue-label: "status:stale" close-issue-reason: not_planned any-of-labels: "status:awaiting user response" diff --git a/CHANGELOG.md b/CHANGELOG.md index acc50b0dd..a982e3364 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,131 @@ # Changelog +## [2.9.0](https://github.com/googleapis/python-genai/compare/v2.9.0-rc1...v2.9.0) (2026-06-19) + +### Major updates + +* **The interactions implementation has been completely replaced**. The public api surface is unchanged. ([d830f16](https://github.com/googleapis/python-genai/commit/d830f165d223ac5f42ab3fa74d2c3d868b0054d8)) + +### Features + +* Add audioOffset to VoiceActivity ([fb785e4](https://github.com/googleapis/python-genai/commit/fb785e402a3aa958b45bf6300f0be972b2f92bf9)) +* Add gemini-3-flash-preview (gemini-3.1, gemini-3.5, gemini-4 are already mapped) to the local tokenizer map. ([749f8a1](https://github.com/googleapis/python-genai/commit/749f8a1b1b5ef06b4b0fc604bc5482f003ef0e1a)), closes [#1972](https://github.com/googleapis/python-genai/issues/1972) +* Add interimInputTranscription to LiveServerContent ([fb785e4](https://github.com/googleapis/python-genai/commit/fb785e402a3aa958b45bf6300f0be972b2f92bf9)) +* Add LanguageAuto, LanguageHints, and adaptationPhrases to AudioTranscriptionConfig ([fb785e4](https://github.com/googleapis/python-genai/commit/fb785e402a3aa958b45bf6300f0be972b2f92bf9)) +* Broaden publisher model path check to support all publishers ([5d282e6](https://github.com/googleapis/python-genai/commit/5d282e662de39d7fb68d258e6ca20446dba16576)) +* Add ServiceTier to UsageMetadata ([45b4963](https://github.com/googleapis/python-genai/commit/45b4963f4cdc8dc01cffe85260c629e50595fbf9)) +* Expose Computer Use API fields ([420b5a7](https://github.com/googleapis/python-genai/commit/420b5a774852501f04c716f74b6c58f466bb71df)) +* Gemma 4 local tokenizer support ([ca97c58](https://github.com/googleapis/python-genai/commit/ca97c5805666f6386d0148848132c07ce81e2c72)) +* **interaction-api:** Add presence_penalty, frequency_penalty, and cached_content to models.proto ([05f16fe](https://github.com/googleapis/python-genai/commit/05f16fea01d4c8bdc4d6ac9c2b7bbed11ada3aee)) +* **interaction-api:** Rename usage to total_usage in StreamMetadata. ([7c331c6](https://github.com/googleapis/python-genai/commit/7c331c6c40825cbbbd7cfc354357c171bdf395f5)) + +### Bug Fixes + +* Add fallback for `aiohttp.readline` without `max_line_length` for backward compatibility because we still want to keep aiohttp as optional dependency ([e99ab99](https://github.com/googleapis/python-genai/commit/e99ab99d63625b2f383a08f5fb91812c096f1c2b)), closes [#2487](https://github.com/googleapis/python-genai/issues/2487) +* Fix header ([f8f9749](https://github.com/googleapis/python-genai/commit/f8f97496965795469888b93f3c70d6ea08296a83)) +* Keep live music API keys out of websocket urls ([#2564](https://github.com/googleapis/python-genai/issues/2564)) ([c754ebf](https://github.com/googleapis/python-genai/commit/c754ebf3973fde9894b24c2425cee67eb2d03b64)) +* Make `transformers` an optional dependency for local tokenizers, also add other dependencies to local-tokenizer-extras. ([528926b](https://github.com/googleapis/python-genai/commit/528926b5a94fb6590846e739e643895016d2c0d0)) +* Use .model_copy() instead of deprecated .copy() ([216369f](https://github.com/googleapis/python-genai/commit/216369f519712285db0902f0b248be3c4faf664c)) + + + + +## [2.9.0-rc1](https://github.com/googleapis/python-genai/compare/v2.9.0-rc0...v2.9.0-rc1) (2026-06-17) + + +### Features + +* Add audioOffset to VoiceActivity ([fb785e4](https://github.com/googleapis/python-genai/commit/fb785e402a3aa958b45bf6300f0be972b2f92bf9)) +* Add gemini-3-flash-preview (gemini-3.1, gemini-3.5, gemini-4 are already mapped) to the local tokenizer map. ([749f8a1](https://github.com/googleapis/python-genai/commit/749f8a1b1b5ef06b4b0fc604bc5482f003ef0e1a)), closes [#1972](https://github.com/googleapis/python-genai/issues/1972) +* Add interimInputTranscription to LiveServerContent ([fb785e4](https://github.com/googleapis/python-genai/commit/fb785e402a3aa958b45bf6300f0be972b2f92bf9)) +* Add LanguageAuto, LanguageHints, and adaptationPhrases to AudioTranscriptionConfig ([fb785e4](https://github.com/googleapis/python-genai/commit/fb785e402a3aa958b45bf6300f0be972b2f92bf9)) +* Broaden publisher model path check to support all publishers ([5d282e6](https://github.com/googleapis/python-genai/commit/5d282e662de39d7fb68d258e6ca20446dba16576)) + + +### Miscellaneous Chores + +* Release 2.9.0-rc1 ([b95f2a8](https://github.com/googleapis/python-genai/commit/b95f2a87213da7b5305d9fb0ea801ca657fb109d)) + +## [2.9.0-rc0](https://github.com/googleapis/python-genai/compare/v2.8.0...v2.9.0-rc0) (2026-06-16) + +### Major updates + +* **The interactions implementation has been completely replaced**. The public api surface should be unchanged. ([d830f16](https://github.com/googleapis/python-genai/commit/d830f165d223ac5f42ab3fa74d2c3d868b0054d8)) + +### Features + +* Add ServiceTier to UsageMetadata ([45b4963](https://github.com/googleapis/python-genai/commit/45b4963f4cdc8dc01cffe85260c629e50595fbf9)) +* Expose Computer Use API fields ([420b5a7](https://github.com/googleapis/python-genai/commit/420b5a774852501f04c716f74b6c58f466bb71df)) +* Gemma 4 local tokenizer support ([ca97c58](https://github.com/googleapis/python-genai/commit/ca97c5805666f6386d0148848132c07ce81e2c72)) +* **interaction-api:** Add presence_penalty, frequency_penalty, and cached_content to models.proto ([05f16fe](https://github.com/googleapis/python-genai/commit/05f16fea01d4c8bdc4d6ac9c2b7bbed11ada3aee)) +* **interaction-api:** Rename usage to total_usage in StreamMetadata. ([7c331c6](https://github.com/googleapis/python-genai/commit/7c331c6c40825cbbbd7cfc354357c171bdf395f5)) + + +### Bug Fixes + +* Add fallback for `aiohttp.readline` without `max_line_length` for backward compatibility because we still want to keep aiohttp as optional dependency ([e99ab99](https://github.com/googleapis/python-genai/commit/e99ab99d63625b2f383a08f5fb91812c096f1c2b)), closes [#2487](https://github.com/googleapis/python-genai/issues/2487) +* Fix header ([f8f9749](https://github.com/googleapis/python-genai/commit/f8f97496965795469888b93f3c70d6ea08296a83)) +* Keep live music API keys out of websocket urls ([#2564](https://github.com/googleapis/python-genai/issues/2564)) ([c754ebf](https://github.com/googleapis/python-genai/commit/c754ebf3973fde9894b24c2425cee67eb2d03b64)) +* Make `transformers` an optional dependency for local tokenizers, also add other dependencies to local-tokenizer-extras. ([528926b](https://github.com/googleapis/python-genai/commit/528926b5a94fb6590846e739e643895016d2c0d0)) +* Use .model_copy() instead of deprecated .copy() ([216369f](https://github.com/googleapis/python-genai/commit/216369f519712285db0902f0b248be3c4faf664c)) + + +### Documentation + +* Announce Automatic Function Calling (AFC) upcoming breaking change warning ([4697258](https://github.com/googleapis/python-genai/commit/4697258417902a5d0074a2247db34bfdf40e5468)) +* Clarify Live API START/END_SENSITIVITY_HIGH/LOW defaults are different in Gemini Live and Gemini Enterprise Agent Platform Live API ([a0ec6ab](https://github.com/googleapis/python-genai/commit/a0ec6abc8f54f9cfc110e9b1dd3271971961f193)), closes [#2555](https://github.com/googleapis/python-genai/issues/2555) +* Regenerate docs for 2.8.0 ([93e7ab1](https://github.com/googleapis/python-genai/commit/93e7ab1e8851dd68e59368d49bc2e3695dfd5148)) + + +## [2.8.0](https://github.com/googleapis/python-genai/compare/v2.7.0...v2.8.0) (2026-06-03) + + +### Features + +* Add Agent Platform MCP support to async generate_content ([e3be9af](https://github.com/googleapis/python-genai/commit/e3be9af3c21c9f8f625aecd890a5ee1f9993fb3d)) +* Add transcription language code. ([53ea3f6](https://github.com/googleapis/python-genai/commit/53ea3f689bf02ecbdbecf8a2a4aff77c48016eb9)) +* Add TranslationConfig for live translation. ([4775314](https://github.com/googleapis/python-genai/commit/47753147a30c10138f1a4e46c1c8e8069ae8e86d)) +* Support ReinforcementTuning in GenAI SDK including ValidateReward API method. ([e0854a6](https://github.com/googleapis/python-genai/commit/e0854a6d1f487435507d2cffd82ad133de8b931d)) + + +### Bug Fixes + +* Include all fields of a single tool ([7b1d498](https://github.com/googleapis/python-genai/commit/7b1d4982f4a61def33db8873feb1334416d4a0e4)) + + +### Documentation + +* A comment for field `enable_widget` in message `GoogleMaps` is changed ([74d81dd](https://github.com/googleapis/python-genai/commit/74d81dd2e3cfe9eb9350751cfbcb597fcd60a479)) +* A comment for field `google_maps_widget_context_token` in message `GroundingMetadata` is changed ([74d81dd](https://github.com/googleapis/python-genai/commit/74d81dd2e3cfe9eb9350751cfbcb597fcd60a479)) +* Remove `codegen_instructions.md` for simpler maintenance, Gemini API Skills should be the single source of truth ([bfa2a49](https://github.com/googleapis/python-genai/commit/bfa2a495e5c7e5acd232c46d3f84913f3a50522a)) +* Update README.md for model/SDK Changes and direct to Gemini API Skills ([47c1a13](https://github.com/googleapis/python-genai/commit/47c1a13e8475b3a2553e699f9ff0823d8757fa92)) +* Update the docs for 2.7 ([bbef98e](https://github.com/googleapis/python-genai/commit/bbef98e64ebf6e12a5ab1aba02302a28ca1faf4f)) + +## [2.7.0](https://github.com/googleapis/python-genai/compare/v2.6.0...v2.7.0) (2026-05-27) + + +### Features + +* Additional computer_use field support for vertex. ([b4828fa](https://github.com/googleapis/python-genai/commit/b4828fa5b085d2dbb47a0adc9c10e4b35d60ad64)) +* **interaction-api:** Allow "text/csv" as a supported document mime type for Interaction API. ([543137b](https://github.com/googleapis/python-genai/commit/543137b78d392c7d81a287f3916e215f13845a72)) +* **interaction-api:** Enable BigQuery tool in Deep Research config. ([5dc17e5](https://github.com/googleapis/python-genai/commit/5dc17e53eec9f3bfbdb39a6a4c8f92a45868167e)) +* Support Reinforcement Tuning in GenAI SDK ([0ead888](https://github.com/googleapis/python-genai/commit/0ead8888695f379ecf35cfc68d69e4b7e8e20403)) + +## [2.6.0](https://github.com/googleapis/python-genai/compare/v2.5.0...v2.6.0) (2026-05-21) + + +### Features + +* Add `enable_prompt_injection_detection` for Computer Use feature for the Gemini API. ([b1f632d](https://github.com/googleapis/python-genai/commit/b1f632d5d617a8e24fd4cb87556a4eb180b6d29b)) +* Add budget_exceeded status ([15443c0](https://github.com/googleapis/python-genai/commit/15443c0211446c41a9ab2705dd2282d324581eb7)) +* Add gemini-3.5-flash ([15443c0](https://github.com/googleapis/python-genai/commit/15443c0211446c41a9ab2705dd2282d324581eb7)) +* Add new fields ([2910346](https://github.com/googleapis/python-genai/commit/291034641aa9cb153f501de0f39db6382186f1c6)) + + +### Documentation + +* Replace `vertexai` with `enterprise` in Client instantiation ([c1c6df7](https://github.com/googleapis/python-genai/commit/c1c6df74e888fd25061ad4364b05977a857b90a3)) + ## [2.5.0](https://github.com/googleapis/python-genai/compare/v2.4.0...v2.5.0) (2026-05-20) diff --git a/README.md b/README.md index 2510fc7a5..c1cdbe5a8 100644 --- a/README.md +++ b/README.md @@ -6,20 +6,31 @@ -------- **Documentation:** https://googleapis.github.io/python-genai/ - ----- Google Gen AI Python SDK provides an interface for developers to integrate -Google's generative models into their Python applications. It supports the -[Gemini Developer API](https://ai.google.dev/gemini-api/docs) and +Google's generative models into their Python applications. It supports +the [Gemini Developer API](https://ai.google.dev/gemini-api/docs) and [Gemini Enterprise Agent Platform](https://docs.cloud.google.com/gemini-enterprise-agent-platform) APIs. -## Code Generation +> [!WARNING] +> **Upcoming Breaking Change to Automatic Function Calling (AFC):** +> We will introduce a breaking change to the Automatic Function Calling (AFC) +> feature in the next major version. Specifically, users will not be able to +> invoke AFC from direct calls to `Models.generate_content` or its stream and +> async variants. Instead, users should invoke AFC from `chats` modules. + +## Agent Skills + +Large Language Models (LLMs) and generative AI coding assistants are often trained on static datasets. As a result, they may be unaware of recent updates and suggest outdated or legacy libraries. + +To ensure your AI coding helper (such as Antigravity, Claude Code, Cursor, or other IDE extensions) generates up-to-date code using the correct SDK syntax and best practices, we recommend equipping your assistant with **Gemini API Skills**. Loading these skills injects the correct patterns and guidelines directly into your AI assistant's context. -Generative models are often unaware of recent API and SDK updates and may suggest outdated or legacy code. +Depending on your target platform, use the corresponding Agent Skill repository: -We recommend using our Code Generation instructions [`codegen_instructions.md`](https://raw.githubusercontent.com/googleapis/python-genai/refs/heads/main/codegen_instructions.md) when generating Google Gen AI SDK code to guide your model towards using the more recent SDK features. Copy and paste the instructions into your development environment to provide the model with the necessary context. +* **Gemini Developer API**: Use the [google-gemini/gemini-skills](https://github.com/google-gemini/gemini-skills) repository. +* **Gemini Enterprise Agent Platform (formerly Vertex AI)**: Use the [google/skills](https://github.com/google/skills/tree/main/skills/cloud/gemini-api) repository. ## Installation @@ -43,7 +54,7 @@ from google.genai import types ## Create a client Please run one of the following code blocks to create a client for -different services ([Gemini Developer API](https://ai.google.dev/gemini-api/docs) or [Vertex AI](https://cloud.google.com/vertex-ai/generative-ai/docs/learn/overview)). +different services ([Gemini Developer API](https://ai.google.dev/gemini-api/docs) or [Agent Platform](https://docs.cloud.google.com/gemini-enterprise-agent-platform)). ```python from google import genai @@ -55,9 +66,9 @@ client = genai.Client(api_key='GEMINI_API_KEY') ```python from google import genai -# Only run this block for Vertex AI API +# Only run this block for Agent Platform client = genai.Client( - enterprise=True, project='your-project-id', location='us-central1' + enterprise=True, project='your-project-id', location='global' ) ``` @@ -114,13 +125,13 @@ precedence. export GEMINI_API_KEY='your-api-key' ``` -**Gemini API on Vertex AI:** Set `GOOGLE_GENAI_USE_VERTEXAI`, +**Gemini API on Agent Platform:** Set `GOOGLE_GENAI_USE_ENTERPRISE`, `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION`, as shown below: ```bash -export GOOGLE_GENAI_USE_VERTEXAI=true +export GOOGLE_GENAI_USE_ENTERPRISE=true export GOOGLE_CLOUD_PROJECT='your-project-id' -export GOOGLE_CLOUD_LOCATION='us-central1' +export GOOGLE_CLOUD_LOCATION='global' ``` ```python @@ -156,7 +167,7 @@ To explicitly close the async client: from google.genai import Client aclient = Client( - enterprise=True, project='my-project-id', location='us-central1' + enterprise=True, project='my-project-id', location='global' ).aio response_1 = await aclient.models.generate_content( model=MODEL_ID, @@ -222,7 +233,7 @@ from google.genai import types client = genai.Client( enterprise=True, project='your-project-id', - location='us-central1', + location='global', http_options=types.HttpOptions(api_version='v1') ) ``` @@ -305,7 +316,6 @@ will not include api version, project, or location. Expected request url will be: https://test-api-gateway-proxy.com/publishers/google/models/gemini-3-pro-preview - ## Types Parameter types can be specified as either dictionaries(`TypedDict`) or @@ -323,7 +333,7 @@ See the 'Create a client' section above to initialize a client. ```python response = client.models.generate_content( - model='gemini-2.5-flash', contents='Why is the sky blue?' + model='gemini-3.5-flash', contents='Why is the sky blue?' ) print(response.text) ``` @@ -334,7 +344,7 @@ print(response.text) from google.genai import types response = client.models.generate_content( - model='gemini-2.5-flash-image', + model='gemini-3.1-flash-image', contents='A cartoon infographic for flying sneakers', config=types.GenerateContentConfig( response_modalities=["IMAGE"], @@ -363,7 +373,7 @@ python code. ```python file = client.files.upload(file='a11.txt') response = client.models.generate_content( - model='gemini-2.5-flash', + model='gemini-3.5-flash', contents=['Could you summarize this file?', file] ) print(response.text) @@ -596,7 +606,7 @@ we use GenerateContentConfig to specify the desired behavior from the model. from google.genai import types response = client.models.generate_content( - model='gemini-2.5-flash', + model='gemini-3.5-flash', contents='high', config=types.GenerateContentConfig( system_instruction='I say high, you say low', @@ -645,7 +655,7 @@ print(async_pager[0]) from google.genai import types response = client.models.generate_content( - model='gemini-2.5-flash', + model='gemini-3.5-flash', contents='Say something bad.', config=types.GenerateContentConfig( safety_settings=[ @@ -679,7 +689,7 @@ def get_current_weather(location: str) -> str: response = client.models.generate_content( - model='gemini-2.5-flash', + model='gemini-3.5-flash', contents='What is the weather like in Boston?', config=types.GenerateContentConfig(tools=[get_current_weather]), ) @@ -697,7 +707,7 @@ as follows: from google.genai import types response = client.models.generate_content( - model='gemini-2.5-flash', + model='gemini-3.5-flash', contents='What is the weather like in Boston?', config=types.GenerateContentConfig( tools=[get_current_weather], @@ -744,7 +754,7 @@ function = types.FunctionDeclaration( tool = types.Tool(function_declarations=[function]) response = client.models.generate_content( - model='gemini-2.5-flash', + model='gemini-3.5-flash', contents='What is the weather like in Boston?', config=types.GenerateContentConfig(tools=[tool]), ) @@ -788,7 +798,7 @@ function_response_content = types.Content( ) response = client.models.generate_content( - model='gemini-2.5-flash', + model='gemini-3.5-flash', contents=[ user_prompt_content, function_call_content, @@ -823,7 +833,7 @@ def get_current_weather(location: str) -> str: return "sunny" response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="What is the weather like in Boston?", config=types.GenerateContentConfig( tools=[get_current_weather], @@ -853,7 +863,7 @@ def get_current_weather(location: str) -> str: return "sunny" response = client.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents="What is the weather like in Boston?", config=types.GenerateContentConfig( tools=[get_current_weather], @@ -900,10 +910,9 @@ async def run(): # Send request to the model with MCP function declarations response = await client.aio.models.generate_content( - model="gemini-2.5-flash", + model="gemini-3.5-flash", contents=prompt, config=genai.types.GenerateContentConfig( - temperature=0, tools=[session], # uses the session, will automatically call the tool using automatic function calling ), ) @@ -945,7 +954,7 @@ user_profile = { } response = client.models.generate_content( - model='gemini-2.5-flash', + model='gemini-3.5-flash', contents='Give me a random user profile.', config={ 'response_mime_type': 'application/json', @@ -975,7 +984,7 @@ class CountryInfo(BaseModel): response = client.models.generate_content( - model='gemini-2.5-flash', + model='gemini-3.5-flash', contents='Give me information for the United States.', config=types.GenerateContentConfig( response_mime_type='application/json', @@ -989,7 +998,7 @@ print(response.text) from google.genai import types response = client.models.generate_content( - model='gemini-2.5-flash', + model='gemini-3.5-flash', contents='Give me information for the United States.', config=types.GenerateContentConfig( response_mime_type='application/json', @@ -1028,7 +1037,7 @@ to you, rather than being returned as one chunk. ```python for chunk in client.models.generate_content_stream( - model='gemini-2.5-flash', contents='Tell me a story in 300 words.' + model='gemini-3.5-flash', contents='Tell me a story in 300 words.' ): print(chunk.text, end='') ``` @@ -1042,7 +1051,7 @@ you can use the `from_uri` class method to create a `Part` object. from google.genai import types for chunk in client.models.generate_content_stream( - model='gemini-2.5-flash', + model='gemini-3.5-flash', contents=[ 'What is this image about?', types.Part.from_uri( @@ -1066,7 +1075,7 @@ with open(YOUR_IMAGE_PATH, 'rb') as f: image_bytes = f.read() for chunk in client.models.generate_content_stream( - model='gemini-2.5-flash', + model='gemini-3.5-flash', contents=[ 'What is this image about?', types.Part.from_bytes(data=image_bytes, mime_type=YOUR_IMAGE_MIME_TYPE), @@ -1085,7 +1094,7 @@ of `client.models.generate_content` ```python response = await client.aio.models.generate_content( - model='gemini-2.5-flash', contents='Tell me a story in 300 words.' + model='gemini-3.5-flash', contents='Tell me a story in 300 words.' ) print(response.text) @@ -1095,7 +1104,7 @@ print(response.text) ```python async for chunk in await client.aio.models.generate_content_stream( - model='gemini-2.5-flash', contents='Tell me a story in 300 words.' + model='gemini-3.5-flash', contents='Tell me a story in 300 words.' ): print(chunk.text, end='') ``` @@ -1104,7 +1113,7 @@ async for chunk in await client.aio.models.generate_content_stream( ```python response = client.models.count_tokens( - model='gemini-2.5-flash', + model='gemini-3.5-flash', contents='why is the sky blue?', ) print(response) @@ -1116,7 +1125,7 @@ Compute tokens is only supported in Vertex AI. ```python response = client.models.compute_tokens( - model='gemini-2.5-flash', + model='gemini-3.5-flash', contents='why is the sky blue?', ) print(response) @@ -1126,7 +1135,7 @@ print(response) ```python response = await client.aio.models.count_tokens( - model='gemini-2.5-flash', + model='gemini-3.5-flash', contents='why is the sky blue?', ) print(response) @@ -1137,7 +1146,7 @@ print(response) ```python from google.genai import local_tokenizer -tokenizer = local_tokenizer.LocalTokenizer(model_name='gemini-2.5-flash') +tokenizer = local_tokenizer.LocalTokenizer(model_name='gemini-3.5-flash') result = tokenizer.count_tokens("What is your name?") ``` @@ -1146,7 +1155,7 @@ result = tokenizer.count_tokens("What is your name?") ```python from google.genai import local_tokenizer -tokenizer = local_tokenizer.LocalTokenizer(model_name='gemini-2.5-flash') +tokenizer = local_tokenizer.LocalTokenizer(model_name='gemini-3.5-flash') result = tokenizer.compute_tokens("What is your name?") ``` @@ -1251,8 +1260,6 @@ response3.generated_images[0].image.show() ### Veo -Support for generating videos is considered public preview - #### Generate Videos (Text to Video) ```python @@ -1355,7 +1362,7 @@ that it can reflect on its previous responses (i.e., engage in an ongoing ### Send Message (Synchronous Non-Streaming) ```python -chat = client.chats.create(model='gemini-2.5-flash') +chat = client.chats.create(model='gemini-3.5-flash') response = chat.send_message('tell me a story') print(response.text) response = chat.send_message('summarize the story you told me in 1 sentence') @@ -1365,7 +1372,7 @@ print(response.text) ### Send Message (Synchronous Streaming) ```python -chat = client.chats.create(model='gemini-2.5-flash') +chat = client.chats.create(model='gemini-3.5-flash') for chunk in chat.send_message_stream('tell me a story'): print(chunk.text) ``` @@ -1373,7 +1380,7 @@ for chunk in chat.send_message_stream('tell me a story'): ### Send Message (Asynchronous Non-Streaming) ```python -chat = client.aio.chats.create(model='gemini-2.5-flash') +chat = client.aio.chats.create(model='gemini-3.5-flash') response = await chat.send_message('tell me a story') print(response.text) ``` @@ -1381,7 +1388,7 @@ print(response.text) ### Send Message (Asynchronous Streaming) ```python -chat = client.aio.chats.create(model='gemini-2.5-flash') +chat = client.aio.chats.create(model='gemini-3.5-flash') async for chunk in await chat.send_message_stream('tell me a story'): print(chunk.text) ``` @@ -1440,7 +1447,7 @@ else: file_uris = [file1.uri, file2.uri] cached_content = client.caches.create( - model='gemini-2.5-flash', + model='gemini-3.5-flash', config=types.CreateCachedContentConfig( contents=[ types.Content( @@ -1475,7 +1482,7 @@ cached_content = client.caches.get(name=cached_content.name) from google.genai import types response = client.models.generate_content( - model='gemini-2.5-flash', + model='gemini-3.5-flash', contents='Summarize the pdfs', config=types.GenerateContentConfig( cached_content=cached_content.name, @@ -1484,9 +1491,7 @@ response = client.models.generate_content( print(response.text) ``` -## Interactions (Preview) - -> **Warning:** The Interactions API is in **Beta**. This is a preview of an experimental feature. Features and schemas are subject to **breaking changes**. +## Interactions The Interactions API is a unified interface for interacting with Gemini models and agents. It simplifies state management, tool orchestration, and long-running tasks. @@ -1496,7 +1501,7 @@ See the [documentation site](https://ai.google.dev/gemini-api/docs/interactions) ```python interaction = client.interactions.create( - model='gemini-2.5-flash', + model='gemini-3.5-flash', input='Tell me a short joke about programming.' ) print(interaction.outputs[-1].text) @@ -1510,14 +1515,14 @@ The Interactions API supports server-side state management. You can continue a c ```python # 1. First turn interaction1 = client.interactions.create( - model='gemini-2.5-flash', + model='gemini-3.5-flash', input='Hi, my name is Amir.' ) print(f"Model: {interaction1.outputs[-1].text}") # 2. Second turn (passing previous_interaction_id) interaction2 = client.interactions.create( - model='gemini-2.5-flash', + model='gemini-3.5-flash', input='What is my name?', previous_interaction_id=interaction1.id ) @@ -1567,7 +1572,7 @@ import base64 # base64_image = ... interaction = client.interactions.create( - model='gemini-2.5-flash', + model='gemini-3.5-flash', input=[ {'type': 'text', 'text': 'Describe the image.'}, {'type': 'image', 'data': base64_image, 'mime_type': 'image/png'} @@ -1602,7 +1607,7 @@ weather_tool = { # 2. Send the request with tools interaction = client.interactions.create( - model='gemini-2.5-flash', + model='gemini-3.5-flash', input='What is the weather in Mountain View, CA?', tools=[weather_tool] ) @@ -1617,7 +1622,7 @@ for output in interaction.outputs: # Send result back to the model interaction = client.interactions.create( - model='gemini-2.5-flash', + model='gemini-3.5-flash', previous_interaction_id=interaction.id, input=[{ 'type': 'function_result', @@ -1637,7 +1642,7 @@ You can also use Google's built-in tools, such as **Google Search** or **Code Ex ```python interaction = client.interactions.create( - model='gemini-2.5-flash', + model='gemini-3.5-flash', input='Who won the last Super Bowl?', tools=[{'type': 'google_search'}] ) @@ -1653,7 +1658,7 @@ if text_output: ```python interaction = client.interactions.create( - model='gemini-2.5-flash', + model='gemini-3.5-flash', input='Calculate the 50th Fibonacci number.', tools=[{'type': 'code_execution'}] ) @@ -1696,7 +1701,7 @@ section above to initialize a client. ```python from google.genai import types -model = 'gemini-2.5-flash' +model = 'gemini-3.5-flash' training_dataset = types.TuningDataset( # or gcs_uri=my_vertex_multimodal_dataset gcs_uri='gs://your-gcs-bucket/your-tuning-data.jsonl', @@ -1850,7 +1855,7 @@ Vertex AI: ```python # Specify model and source file only, destination and job display name will be auto-populated job = client.batches.create( - model='gemini-2.5-flash', + model='gemini-3.5-flash', src='bq://my-project.my-dataset.my-table', # or "gs://path/to/input/data" ) @@ -1862,7 +1867,7 @@ Gemini Developer API: ```python # Create a batch job with inlined requests batch_job = client.batches.create( - model="gemini-2.5-flash", + model="gemini-3.5-flash", src=[{ "contents": [{ "parts": [{ @@ -1897,7 +1902,7 @@ file = client.files.upload( # Create a batch job with file name batch_job = client.batches.create( - model="gemini-2.5-flash", + model="gemini-3.5-flash", src="files/test-json", ) ``` diff --git a/codegen_instructions.md b/codegen_instructions.md deleted file mode 100644 index 9f9c1d6d3..000000000 --- a/codegen_instructions.md +++ /dev/null @@ -1,677 +0,0 @@ -# Gemini API Coding Guidelines (Python) - -You are a Gemini API coding expert. Help me with writing code using the Gemini -API calling the official libraries and SDKs. - -Please follow the following guidelines when generating code. - -**Official Documentation:** [ai.google.dev/gemini-api/docs](https://ai.google.dev/gemini-api/docs) - -## Golden Rule: Use the Correct and Current SDK - -Always use the **Google GenAI SDK** (`google-genai`), which is the unified -standard library for all Gemini API requests (AI Studio/Gemini Developer API -and Vertex AI) as of 2025. Do not use legacy libraries and SDKs. - -- **Library Name:** Google GenAI SDK -- **Python Package:** `google-genai` -- **Legacy Library**: (`google-generativeai`) is deprecated. - -**Installation:** - -- **Incorrect:** `pip install google-generativeai` -- **Incorrect:** `pip install google-ai-generativelanguage` -- **Correct:** `pip install google-genai` - -**APIs and Usage:** - -- **Incorrect:** `import google.generativeai as genai`-> **Correct:** `from - google import genai` -- **Incorrect:** `from google.ai import generativelanguage_v1` -> - **Correct:** `from google import genai` -- **Incorrect:** `from google.generativeai` -> **Correct:** `from google - import genai` -- **Incorrect:** `from google.generativeai import types` -> **Correct:** `from - google.genai import types` -- **Incorrect:** `import google.generativeai as genai` -> **Correct:** `from - google import genai` -- **Incorrect:** `genai.configure(api_key=...)` -> **Correct:** `client = - genai.Client(api_key='...')` -- **Incorrect:** `model = genai.GenerativeModel(...)` -- **Incorrect:** `model.generate_content(...)` -> **Correct:** - `client.models.generate_content(...)` -- **Incorrect:** `response = model.generate_content(..., stream=True)` -> - **Correct:** `client.models.generate_content_stream(...)` -- **Incorrect:** `genai.GenerationConfig(...)` -> **Correct:** - `types.GenerateContentConfig(...)` -- **Incorrect:** `safety_settings={...}` -> **Correct:** Use `safety_settings` - inside a `GenerateContentConfig` object. -- **Incorrect:** `from google.api_core.exceptions import GoogleAPIError` -> - **Correct:** `from google.genai.errors import APIError` -- **Incorrect:** `types.ResponseModality.TEXT` - -## Initialization and API Key - -The `google-genai` library requires creating a client object for all API calls. - -- Always use `client = genai.Client()` to create a client object. -- Set `GEMINI_API_KEY` (or `GOOGLE_API_KEY`) environment variable, which will be picked up - automatically. - -```python - -from google import genai - -# Best practice: implicitly use env variable - -client = genai.Client() - -# Alternative: explicit key (avoid hardcoding in production) - -# client = genai.Client(api_key='YOUR_API_KEY') - -``` - -## Customizing API Endpoint (Base URL) - -For advanced use cases, such as using a proxy or a private Vertex AI endpoint, you can customize the base URL for API requests. This is done by passing an `HttpOptions` object to the client constructor. - -```python -from google import genai -from google.genai import types - -# Configure the custom base URL -http_opts = types.HttpOptions( - base_url="https://my.custom.proxy/or/endpoint" -) - -client = genai.Client(http_options=http_opts) -response = client.models.generate_content( - model='gemini-2.5-flash', - contents='why is the sky blue?', -) - -print(response.text) -``` - - -## Models - -- By default, use the following models when using `google-genai`: - - **General Text & Multimodal Tasks:** `gemini-3-flash-preview` - - **Coding and Complex Reasoning Tasks:** `gemini-3-pro-preview` - - **Low Latency & High Volume Tasks:** `gemini-2.5-flash-lite` - - **Fast Image Generation and Editing:** `gemini-2.5-flash-image` (aka Nano Banana) - - **High-Quality Image Generation and Editing:** `gemini-3-pro-image-preview` (aka Nano Banana Pro) - - **High-Fidelity Video Generation:** `veo-3.0-generate-001` or `veo-3.1-generate-preview` - - **Fast Video Generation:** `veo-3.0-fast-generate-001` or `veo-3.1-fast-generate-preview` - - **Advanced Video Editing Tasks:** `veo-3.1-generate-preview` - -- It is also acceptable to use following models if explicitly requested by the - user: - - **Gemini 2.0 Series**: `gemini-2.0-flash`, `gemini-2.0-flash-lite` - - **Gemini 2.5 Series**: `gemini-2.5-flash`, `gemini-2.5-pro` - -- Do not use the following deprecated models (or their variants like - `gemini-1.5-flash-latest`): - - **Prohibited:** `gemini-1.5-flash` - - **Prohibited:** `gemini-1.5-pro` - - **Prohibited:** `gemini-pro` - -## Basic Inference (Text Generation) - -Here's how to generate a response from a text prompt. -Calls are stateless using the `client.models` accessor. - -```python -from google import genai - -client = genai.Client() - -response = client.models.generate_content( - model='gemini-3-flash-preview', - contents='Why is the sky blue?', -) - -print(response.text) # output is often markdown -``` - -## Multimodal Inputs - -Pass images directly as PIL objects, bytes, or file URIs. - -### Using PIL Images - -```python -from google import genai -from PIL import Image - -client = genai.Client() -image = Image.open('image.jpg') - -response = client.models.generate_content( - model='gemini-3-flash-preview', - contents=[image, 'Describe this image in detail.'], -) - -print(response.text) -``` - -### Using Bytes (Best for Web/API Backends) - -You can also use `Part.from_bytes` type to pass a variety of data types (images, -audio, video, pdf). - -```python -from google import genai -from google.genai import types - -client = genai.Client() - -with open('audio_sample.mp3', 'rb') as f: - audio_bytes = f.read() - -response = client.models.generate_content( - model='gemini-3-flash-preview', - contents=[ - types.Part.from_bytes( - data=audio_bytes, - mime_type='audio/mp3', - ), - 'Transcribe this audio.' - ] -) -print(response.text) -``` - -### File API (For Large Files) - -For video files or long audio, upload to the File API first. - -```python -# Upload -my_file = client.files.upload(file='video.mp4') - -# Generate -response = client.models.generate_content( - model='gemini-3-flash-preview', - contents=[my_file, 'What happens in this video?'] -) -print(response.text) - -# You can delete files after use like this: -client.files.delete(name=my_file.name) -``` - -## Advanced Capabilities - -### Thinking (Reasoning) - -Gemini 2.5 and 3 series models support explicit "thinking" for complex logic. - -#### Gemini 3 - -Thinking is on by default for `gemini-3-pro-preview` and `gemini-3-flash-preview`. -It can be adjusted by using the `thinking_level` parameter. - -- **`MINIMAL`:** (Gemini 3 Flash Only) Constrains the model to use as few tokens as possible for thinking and is best used for low-complexity tasks that wouldn't benefit from extensive reasoning. -- **`LOW`**: Constrains the model to use fewer tokens for thinking and is suitable for simpler tasks where extensive reasoning is not required. -- **`MEDIUM`**: (Gemini 3 Flash only) Offers a balanced approach suitable for tasks of moderate complexity that benefit from reasoning but don't require deep, multi-step planning. -- **`HIGH`**: (Default) Maximizes reasoning depth. The model may take significantly longer to reach a first token, but the output will be more thoroughly vetted. - -```python -from google import genai -from google.genai import types - -client = genai.Client() - -response = client.models.generate_content( - model='gemini-3-pro-preview', - contents='What is AI?', - config=types.GenerateContentConfig( - thinking_config=types.ThinkingConfig( - thinking_level=types.ThinkingLevel.HIGH - ) - ) -) - -# Access thoughts if returned -for part in response.candidates[0].content.parts: - if part.thought: - print(f"Thought: {part.text}") - else: - print(f"Response: {part.text}") -``` - -#### Gemini 2.5 - -Thinking is on by default for -`gemini-2.5-pro` and `gemini-2.5-flash`. -It can be adjusted by using `thinking_budget` setting. -Setting it to zero turns thinking off, and will reduce latency. - -```python -from google import genai -from google.genai import types - -client = genai.Client() - -response = client.models.generate_content( - model='gemini-2.5-pro', - contents='What is AI?', - config=types.GenerateContentConfig( - thinking_config=types.ThinkingConfig( - thinking_budget=0 - ) - ) -) - -# Access thoughts if returned -for part in response.candidates[0].content.parts: - if part.thought: - print(f"Thought: {part.text}") - else: - print(f"Response: {part.text}") -``` - -IMPORTANT NOTES: - -- Minimum thinking budget for `gemini-2.5-pro` is `128` and thinking can not - be turned off for that model. -- No models (apart from Gemini 2.5/3 series) support thinking or thinking - budgets APIs. Do not try to adjust thinking budgets for other models (such as - `gemini-2.0-flash` or `gemini-2.0-pro`), otherwise it will cause syntax - errors. - -### System Instructions - -Use system instructions to guide model's behavior. - -```python -from google import genai -from google.genai import types - -client = genai.Client() - -response = client.models.generate_content( - model='gemini-3-flash-preview', - contents='Explain quantum physics.', - config=types.GenerateContentConfig( - system_instruction='You are a pirate', - ) -) -print(response.text) -``` - -### Hyperparameters - -You can also set `temperature` or `max_output_tokens` within -`types.GenerateContentConfig` -**Avoid** setting `max_output_tokens`, `topP`, `topK` unless explicitly -requested by the user. - -### Safety configurations - -Avoid setting safety configurations unless explicitly requested by the user. If -explicitly asked for by the user, here is a sample API: - -```python -from google import genai -from google.genai import types -from PIL import Image - -client = genai.Client() - -img = Image.open('/path/to/img') -response = client.models.generate_content( - model='gemini-2.0-flash', - contents=['Do these look store-bought or homemade?', img], - config=types.GenerateContentConfig( - safety_settings=[ - types.SafetySetting( - category=types.HarmCategory.HARM_CATEGORY_HATE_SPEECH, - threshold=types.HarmBlockThreshold.BLOCK_LOW_AND_ABOVE, - ), - ] - ) -) - -print(response.text) -``` - -### Streaming - -Use `generate_content_stream` to reduce time-to-first-token. - -```python -from google import genai - -client = genai.Client() - -response = client.models.generate_content_stream( - model='gemini-3-flash-preview', - contents='Write a long story about a space pirate.' -) - -for chunk in response: - print(chunk.text, end='') -``` - -### Chat - -For multi-turn conversations, use the `chats` service to maintain conversation -history. - -```python -from google import genai - -client = genai.Client() -chat = client.chats.create(model='gemini-3-flash-preview') - -response1 = chat.send_message('I have a cat named Whiskers.') -print(response1.text) - -response2 = chat.send_message('What is the name of my pet?') -print(response2.text) - -# To access specific elements in chat history -for message in chat.get_history(): - print(f'role - {message.role}', end=': ') - print(message.parts[0].text) -``` - -### Structured Outputs (Pydantic) - -Enforce a specific JSON schema using standard Python type hints or Pydantic models. - -```python -from google import genai -from google.genai import types -from pydantic import BaseModel - -class Recipe(BaseModel): - name: str - description: str - ingredients: list[str] - steps: list[str] - -client = genai.Client() - -response = client.models.generate_content( - model='gemini-3-flash-preview', - contents='Provide a classic recipe for chocolate chip cookies.', - config=types.GenerateContentConfig( - response_mime_type='application/json', - response_json_schema=Recipe, - ), -) - -# response.text is guaranteed to be valid JSON matching the schema -print(response.text) - -# Access the response as a Pydantic object -recipe = Recipe.model_validate_json(response.text) -``` - -### Function Calling - -You can provide the model with tools (functions) it can use to bring in external -information to answer a question or act on a request outside the model. - -```python -from google import genai -from google.genai import types - -# Define a function that the model can call (to access external information) -def get_current_weather(city: str) -> str: - """Returns the current weather in a given city. For this example, it's hardcoded.""" - if 'boston' in city.lower(): - return 'The weather in Boston is 15°C and sunny.' - else: - return f'Weather data for {city} is not available.' - -client = genai.Client() - -response = client.models.generate_content( - model='gemini-3-flash-preview', - contents='What is the weather in Boston?', - config=types.GenerateContentConfig( - tools=[get_current_weather] # Make the function available to the model as a tool - - ), -) - -# The model may respond with a request to call the function -if response.function_calls: - print('Function calls requested by the model:') - for function_call in response.function_calls: - print(f'- Function: {function_call.name}') - print(f'- Args: {dict(function_call.args)}') -else: - print('The model responded directly:') - print(response.text) -``` - -### Grounding (Google Search) - -Connect the model to real-time web data. - -```python -from google import genai -from google.genai import types - -client = genai.Client() - -response = client.models.generate_content( - model='gemini-3-flash-preview', - contents='What was the score of the latest Olympique Lyonais game?', - config=types.GenerateContentConfig( - tools=[ - types.Tool(google_search=types.GoogleSearch()) - ] - ), -) - -print(response.text) -# Search details -print(f'Search Query: {response.candidates[0].grounding_metadata.web_search_queries}') -# Inspect grounding metadata -print(response.candidates[0].grounding_metadata.search_entry_point.rendered_content) -# Urls used for grounding -print(f"Search Pages: {', '.join([site.web.title for site in response.candidates[0].grounding_metadata.grounding_chunks])}") -``` - -The output `response.text` will likely not be in JSON format, do not attempt to -parse it as JSON. - -## Media Generation - -### Generate Images - -Here's how to generate images using the Nano Banana models. Start with the -Gemini 2.5 Flash Image (Nano Banana) model as it should cover most use-cases. - -```python -from google import genai -from google.genai import types -from PIL import Image - -prompt = "Create a picture of a nano banana dish in a fancy restaurant with a Gemini theme" - -client = genai.Client() - -response = client.models.generate_content( - model="gemini-2.5-flash-image", - contents=prompt, -) - -for part in response.parts: - if part.text is not None: - print(part.text) - elif part.inline_data is not None: - image = part.as_image() - image.save("generated_image.png") -``` - -Upgrade to the Gemini 3 Pro image (Nano Banana Pro) model if the user requests -high-resolution images or needs real-time information using the Google Search tool. - -```python -from google import genai -from google.genai import types -from PIL import Image - -prompt = "Visualize the current weather forecast for the next 5 days in San Francisco as a clean, modern weather chart. Add a visual on what I should wear each day" -aspect_ratio = "16:9" # "1:1","2:3","3:2","3:4","4:3","4:5","5:4","9:16","16:9","21:9" -resolution = "1K" # "1K", "2K", "4K" - -client = genai.Client() - -response = client.models.generate_content( - model="gemini-3-pro-image-preview", - contents=prompt, - config=types.GenerateContentConfig( - image_config=types.ImageConfig( - aspect_ratio=aspect_ratio, - image_size=resolution - ), - # Optional - tools=[ - types.Tool(google_search=types.GoogleSearch()) - ] - ) -) - -for part in response.parts: - if part.text is not None: - print(part.text) - elif image:= part.as_image(): - image.save("weather.png") -``` - -### Edit images - -Editing images is better done using the Gemini native image generation model, -and it is recommended to use chat mode. Configs are not supported in this model -(except modality). - -```python -from google import genai -from PIL import Image -from io import BytesIO - -client = genai.Client() - -prompt = """ -Create a picture of my cat eating a nano-banana in a fancy restaurant under the gemini constellation -""" -image = Image.open('/path/to/image.png') - -# Create the chat -chat = client.chats.create(model='gemini-2.5-flash-image') -# Send the image and ask for it to be edited -response = chat.send_message([prompt, image]) - -# Get the text and the image generated -for i, part in enumerate(response.candidates[0].content.parts): - if part.text is not None: - print(part.text) - elif part.inline_data is not None: - image = part.as_image() - image.save(f'generated_image_{i}.png') # Multiple images can be generated - -# Continue iterating -chat.send_message('Can you make it a bananas foster?') -``` - -### Video Generation (Veo) - -Use the Veo models for video generation. Usage of Veo can be costly, -so after generating code for it, give user a heads up to check pricing for Veo. -Start with the fast model since the result quality is usually sufficient, and -swap to the larger model if needed. - -```python -import time -from google import genai -from google.genai import types -from PIL import Image - -client = genai.Client() - -image = Image.open('path/to/image.png') # Optional - -# Video generation is an async operation -operation = client.models.generate_videos( - model='veo-3.0-fast-generate-001', - prompt='Panning wide shot of a calico kitten sleeping in the sunshine', - image=image, - config=types.GenerateVideosConfig( - person_generation='dont_allow', # 'dont_allow' or 'allow_adult' - aspect_ratio='16:9', # '16:9' or '9:16' - number_of_videos=1, # supported value is 1-4, use 1 by default - duration_seconds=8, # supported value is 5-8 - ), -) - -# Poll for completion -while not operation.done: - time.sleep(20) - operation = client.operations.get(operation) - -for n, generated_video in enumerate(operation.response.generated_videos): - client.files.download(file=generated_video.video) # just file=, no need for path= as it doesn't save yet - generated_video.video.save(f'video{n}.mp4') # saves the video -``` - -## Content and Part Hierarchy - -While the simpler API call is often sufficient, you may run into scenarios where -you need to work directly with the underlying `Content` and `Part` objects for -more explicit control. These are the fundamental building blocks of the -`generate_content` API. - -For instance, the following simple API call: - -```python -from google import genai - -client = genai.Client() - -response = client.models.generate_content( - model='gemini-3-flash-preview', - contents='How does AI work?' -) -print(response.text) -``` - -is effectively a shorthand for this more explicit structure: - -```python -from google import genai -from google.genai import types - -client = genai.Client() - -response = client.models.generate_content( - model='gemini-3-flash-preview', - contents=[ - types.Content(role='user', parts=[types.Part.from_text(text='How does AI work?')]), - ] -) -print(response.text) -``` - -## Other APIs - -The list of APIs and capabilities above are not comprehensive. If users ask you -to generate code for a capability not provided above, refer them to -ai.google.dev/gemini-api/docs. - -## Useful Links - -- Documentation: ai.google.dev/gemini-api/docs -- API Keys and Authentication: ai.google.dev/gemini-api/docs/api-key -- Models: ai.google.dev/models -- API Pricing: ai.google.dev/pricing -- Rate Limits: ai.google.dev/gemini-api/docs/rate-limits diff --git a/docs/genai.html b/docs/genai.html index 97bbf522d..0a15c20c8 100644 --- a/docs/genai.html +++ b/docs/genai.html @@ -306,6 +306,11 @@
Union[Interaction, AsyncStream[Union[InteractionCreatedEvent, InteractionCompletedEvent, InteractionStatusUpdate, ErrorEvent, StepStart, StepDelta, StepStop]]]
Union[Interaction, Stream[Union[InteractionCreatedEvent, InteractionCompletedEvent, InteractionStatusUpdate, ErrorEvent, StepStart, StepDelta, StepStop]]]
# Case 2: If LiveEphemeralParameters is set, lock all fields in
@@ -3877,7 +3887,7 @@ Submodules# example, changing `output_audio_transcription` in the Live API
# connection will be ignored by the API.
-auth_token = client.tokens.create(
+auth_token = client.auth_tokens.create(
config=types.CreateAuthTokenConfig(
uses=10,
live_constrained_parameters=types.LiveEphemeralParameters(
@@ -3894,7 +3904,7 @@ Submodules# empty, lock LiveConnectConfig with set fields (e.g.
# system_instruction in this example) when using the token in Live API
# sessions.
-auth_token = client.tokens.create(
+auth_token = client.auth_tokens.create(
config=types.CreateAuthTokenConfig(
uses=10,
live_constrained_parameters=types.LiveEphemeralParameters(
@@ -3911,7 +3921,7 @@ Submodules# set, lock LiveConnectConfig with set and additional fields (e.g.
# system_instruction, temperature in this example) when using the token
# in Live API sessions.
-auth_token = client.tokens.create(
+auth_token = client.auth_tokens.create(
config=types.CreateAuthTokenConfig(
uses=10,
live_constrained_parameters=types.LiveEphemeralParameters(
@@ -3989,6 +3999,38 @@ Submodules
+-
+async validate_reward(*, parent, sample_response, example, single_reward_config=None, composite_reward_config=None, config=None)¶
+Validates a reinforcement tuning reward configuration.
+Allows users to validate a reinforcement tuning reward configuration
+against a sample response and example before creating a reinforcement
+tuning job, so that they can iterate on the reward configuration without
+having to create a tuning job each time.
+
+- Return type:
+-
+
+- Parameters:
+
+parent – The resource name of the Location to validate the reward in, e.g.
+projects/{project}/locations/{location}.
+sample_response – The sample response for validating the reward
+configuration.
+example – The example to validate the reward configuration.
+single_reward_config – Single reward function configuration for
+reinforcement tuning. Mutually exclusive with composite_reward_config.
+composite_reward_config – Composite reward function configuration for
+reinforcement tuning. Mutually exclusive with single_reward_config.
+config – Optional parameters for the request.
+
+
+- Returns:
+A ValidateRewardResponse with the computed reward(s).
+
+
+
+
@@ -4048,6 +4090,38 @@ Submodules
+-
+validate_reward(*, parent, sample_response, example, single_reward_config=None, composite_reward_config=None, config=None)¶
+Validates a reinforcement tuning reward configuration.
+Allows users to validate a reinforcement tuning reward configuration
+against a sample response and example before creating a reinforcement
+tuning job, so that they can iterate on the reward configuration without
+having to create a tuning job each time.
+
+- Return type:
+-
+
+- Parameters:
+
+parent – The resource name of the Location to validate the reward in, e.g.
+projects/{project}/locations/{location}.
+sample_response – The sample response for validating the reward
+configuration.
+example – The example to validate the reward configuration.
+single_reward_config – Single reward function configuration for
+reinforcement tuning. Mutually exclusive with composite_reward_config.
+composite_reward_config – Composite reward function configuration for
+reinforcement tuning. Mutually exclusive with single_reward_config.
+config – Optional parameters for the request.
+
+
+- Returns:
+A ValidateRewardResponse with the computed reward(s).
+
+
+
+
@@ -7805,7 +7879,7 @@ Submodules }
],
"default": null,
- "description": "Optional. The IANA standard MIME type of the response. The model will generate output that conforms to this MIME type. Supported values include 'text/plain' (default) and 'application/json'. The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined. This is a preview feature.",
+ "description": "Optional. The IANA standard MIME type of the response. The model will generate output that conforms to this MIME type. Supported values include 'text/plain' (default) and 'application/json'. The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined.",
"title": "Responsemimetype"
},
"responseModalities": {
@@ -9388,7 +9462,7 @@ Submodules }
],
"default": null,
- "description": "The name of the BigQuery table created, in `predictions_<timestamp>` format, into which the prediction output is written.",
+ "description": "The name of the BigQuery table created, in `predictions_TIMESTAMP` format, into which the prediction output is written.",
"title": "Bigqueryoutputtable"
}
},
@@ -9717,7 +9791,7 @@ Submodules },
"CodeExecutionResult": {
"additionalProperties": false,
- "description": "Result of executing the `ExecutableCode`.\n\nGenerated only when the `CodeExecution` tool is used.",
+ "description": "Result of executing the ExecutableCode.\n\nGenerated only when the `CodeExecution` tool is used.",
"properties": {
"outcome": {
"anyOf": [
@@ -9754,7 +9828,7 @@ Submodules }
],
"default": null,
- "description": "The identifier of the `ExecutableCode` part this result is for. Only populated if the corresponding `ExecutableCode` has an id.",
+ "description": "Optional. The identifier of the `ExecutableCode` part this result is for. Only populated if the corresponding `ExecutableCode` has an id. This field is not supported in Vertex AI.",
"title": "Id"
}
},
@@ -9930,7 +10004,7 @@ Submodules },
"ExecutableCode": {
"additionalProperties": false,
- "description": "Model-generated code executed server-side, results returned to the model.\n\nOnly generated when using the `CodeExecution` tool, in which the code will\nbe automatically executed, and a corresponding `CodeExecutionResult` will\nalso be generated.",
+ "description": "Code generated by the model that is meant to be executed, and the result returned to the model.\n\nGenerated when using the `CodeExecution` tool, in which the code will be\nautomatically executed, and a corresponding CodeExecutionResult will also be\ngenerated.",
"properties": {
"code": {
"anyOf": [
@@ -9967,7 +10041,7 @@ Submodules }
],
"default": null,
- "description": "Unique identifier of the `ExecutableCode` part. The server returns the `CodeExecutionResult` with the matching `id`.",
+ "description": "Optional. Unique identifier of the `ExecutableCode` part. The server returns the `CodeExecutionResult` with the matching `id`. This field is not supported in Vertex AI.",
"title": "Id"
}
},
@@ -10047,7 +10121,7 @@ Submodules },
"FunctionCall": {
"additionalProperties": false,
- "description": "A function call.",
+ "description": "A predicted FunctionCall returned from the model that contains a string representing the FunctionDeclaration.name and a structured JSON object containing the parameters and their values.",
"properties": {
"id": {
"anyOf": [
@@ -10059,7 +10133,7 @@ Submodules }
],
"default": null,
- "description": "The unique id of the function call. If populated, the client to execute the\n `function_call` and return the response with the matching `id`.",
+ "description": "Optional. The unique id of the function call. If populated, the client to execute the `function_call` and return the response with the matching `id`.",
"title": "Id"
},
"args": {
@@ -10073,7 +10147,7 @@ Submodules }
],
"default": null,
- "description": "Optional. The function parameters and values in JSON object format. See [FunctionDeclaration.parameters] for parameter details.",
+ "description": "Optional. The function parameters and values in JSON object format. See FunctionDeclaration.parameters for parameter details.",
"title": "Args"
},
"name": {
@@ -10086,7 +10160,7 @@ Submodules }
],
"default": null,
- "description": "Optional. The name of the function to call. Matches [FunctionDeclaration.name].",
+ "description": "Optional. The name of the function to call. Matches FunctionDeclaration.name.",
"title": "Name"
},
"partialArgs": {
@@ -10124,7 +10198,7 @@ Submodules },
"FunctionResponse": {
"additionalProperties": false,
- "description": "A function response.",
+ "description": "The result output from a FunctionCall that contains a string representing the FunctionDeclaration.name and a structured JSON object containing any output from the function is used as context to the model.\n\nThis should contain the result of a `FunctionCall` made based on model\nprediction.",
"properties": {
"willContinue": {
"anyOf": [
@@ -10136,7 +10210,7 @@ Submodules }
],
"default": null,
- "description": "Signals that function call continues, and more responses will be returned, turning the function call into a generator. Is only applicable to NON_BLOCKING function calls (see FunctionDeclaration.behavior for details), ignored otherwise. If false, the default, future responses will not be considered. Is only applicable to NON_BLOCKING function calls, is ignored otherwise. If set to false, future responses will not be considered. It is allowed to return empty `response` with `will_continue=False` to signal that the function call is finished.",
+ "description": "Optional. Signals that function call continues, and more responses will be returned, turning the function call into a generator. Is only applicable to NON_BLOCKING function calls, is ignored otherwise. If set to false, future responses will not be considered. It is allowed to return empty `response` with `will_continue=False` to signal that the function call is finished. This may still trigger the model generation. To avoid triggering the generation and finish the function call, additionally set `scheduling` to `SILENT`. This field is not supported in Vertex AI.",
"title": "Willcontinue"
},
"scheduling": {
@@ -10149,7 +10223,7 @@ Submodules }
],
"default": null,
- "description": "Specifies how the response should be scheduled in the conversation. Only applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults to WHEN_IDLE."
+ "description": "Optional. Specifies how the response should be scheduled in the conversation. Only applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults to WHEN_IDLE."
},
"parts": {
"anyOf": [
@@ -10164,7 +10238,7 @@ Submodules }
],
"default": null,
- "description": "List of parts that constitute a function response. Each part may\n have a different IANA MIME type.",
+ "description": "Optional. Ordered `Parts` that constitute a function response. Parts may have different IANA MIME types.",
"title": "Parts"
},
"id": {
@@ -10190,7 +10264,7 @@ Submodules }
],
"default": null,
- "description": "Required. The name of the function to call. Matches [FunctionDeclaration.name] and [FunctionCall.name].",
+ "description": "Required. The name of the function to call. Matches FunctionDeclaration.name and FunctionCall.name.",
"title": "Name"
},
"response": {
@@ -10213,7 +10287,7 @@ Submodules },
"FunctionResponseBlob": {
"additionalProperties": false,
- "description": "Raw media bytes for function response.\n\nText should not be sent as raw bytes, use the FunctionResponse.response\nfield.",
+ "description": "Raw media bytes for function response.\n\nText should not be sent as raw bytes, use the 'text' field.",
"properties": {
"mimeType": {
"anyOf": [
@@ -10239,7 +10313,7 @@ Submodules }
],
"default": null,
- "description": "Required. Inline media bytes.",
+ "description": "Required. Raw bytes.",
"title": "Data"
},
"displayName": {
@@ -10252,7 +10326,7 @@ Submodules }
],
"default": null,
- "description": "Optional. Display name of the blob.\n Used to provide a label or filename to distinguish blobs.",
+ "description": "Optional. Display name of the blob. Used to provide a label or filename to distinguish blobs. This field is only returned in PromptMessage for prompt management. It is currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled. This field is not supported in Gemini API.",
"title": "Displayname"
}
},
@@ -10261,7 +10335,7 @@ Submodules },
"FunctionResponseFileData": {
"additionalProperties": false,
- "description": "URI based data for function response.",
+ "description": "URI based data for function response.\n\nThis data type is not supported in Gemini API.",
"properties": {
"fileUri": {
"anyOf": [
@@ -10299,7 +10373,7 @@ Submodules }
],
"default": null,
- "description": "Optional. Display name of the file.\n Used to provide a label or filename to distinguish files.",
+ "description": "Optional. Display name of the file data. Used to provide a label or filename to distinguish file datas. This field is only returned in PromptMessage for prompt management. It is currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled.",
"title": "Displayname"
}
},
@@ -10308,7 +10382,7 @@ Submodules },
"FunctionResponsePart": {
"additionalProperties": false,
- "description": "A datatype containing media that is part of a `FunctionResponse` message.\n\nA `FunctionResponsePart` consists of data which has an associated datatype. A\n`FunctionResponsePart` can only contain one of the accepted types in\n`FunctionResponsePart.data`.\n\nA `FunctionResponsePart` must have a fixed IANA MIME type identifying the\ntype and subtype of the media if the `inline_data` field is filled with raw\nbytes.",
+ "description": "A datatype containing media that is part of a `FunctionResponse` message.\n\nA `FunctionResponsePart` consists of data which has an associated datatype. A\n`FunctionResponsePart` can only contain one of the accepted types in\n`FunctionResponsePart.data`. A `FunctionResponsePart` must have a fixed IANA\nMIME type identifying the type and subtype of the media if the `inline_data`\nfield is filled with raw bytes.",
"properties": {
"inlineData": {
"anyOf": [
@@ -10320,7 +10394,7 @@ Submodules }
],
"default": null,
- "description": "Optional. Inline media bytes."
+ "description": "Inline media bytes."
},
"fileData": {
"anyOf": [
@@ -10332,14 +10406,14 @@ Submodules }
],
"default": null,
- "description": "Optional. URI based data."
+ "description": "URI based data. This field is not supported in Gemini API."
}
},
"title": "FunctionResponsePart",
"type": "object"
},
"FunctionResponseScheduling": {
- "description": "Specifies how the response should be scheduled in the conversation.",
+ "description": "Specifies how the response should be scheduled in the conversation.\n\nOnly applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults\nto WHEN_IDLE.",
"enum": [
"SCHEDULING_UNSPECIFIED",
"SILENT",
@@ -11367,7 +11441,7 @@ Submodules }
],
"default": null,
- "description": "Optional. Page number of the retrieved context. This field is not supported in Vertex AI.",
+ "description": "Optional. Page number of the retrieved context, if applicable. This field is not supported in Vertex AI.",
"title": "Pagenumber"
},
"mediaId": {
@@ -11380,7 +11454,7 @@ Submodules }
],
"default": null,
- "description": "Optional. Media ID. This field is not supported in Vertex AI.",
+ "description": "Optional. The media blob resource name for multimodal file search results. Format: fileSearchStores/{file_search_store_id}/media/{blob_id}. This field is not supported in Vertex AI.",
"title": "Mediaid"
}
},
@@ -12550,6 +12624,32 @@ Submodules "default": null,
"description": "The content of the chunk.",
"title": "Text"
+ },
+ "chunkId": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "The ID of the chunk.",
+ "title": "Chunkid"
+ },
+ "fileId": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "The ID of the file that the chunk belongs to.",
+ "title": "Fileid"
}
},
"title": "RagChunk",
@@ -13745,7 +13845,7 @@ Submodules },
"CodeExecutionResult": {
"additionalProperties": false,
- "description": "Result of executing the `ExecutableCode`.\n\nGenerated only when the `CodeExecution` tool is used.",
+ "description": "Result of executing the ExecutableCode.\n\nGenerated only when the `CodeExecution` tool is used.",
"properties": {
"outcome": {
"anyOf": [
@@ -13782,7 +13882,7 @@ Submodules }
],
"default": null,
- "description": "The identifier of the `ExecutableCode` part this result is for. Only populated if the corresponding `ExecutableCode` has an id.",
+ "description": "Optional. The identifier of the `ExecutableCode` part this result is for. Only populated if the corresponding `ExecutableCode` has an id. This field is not supported in Vertex AI.",
"title": "Id"
}
},
@@ -13898,7 +13998,7 @@ Submodules },
"ExecutableCode": {
"additionalProperties": false,
- "description": "Model-generated code executed server-side, results returned to the model.\n\nOnly generated when using the `CodeExecution` tool, in which the code will\nbe automatically executed, and a corresponding `CodeExecutionResult` will\nalso be generated.",
+ "description": "Code generated by the model that is meant to be executed, and the result returned to the model.\n\nGenerated when using the `CodeExecution` tool, in which the code will be\nautomatically executed, and a corresponding CodeExecutionResult will also be\ngenerated.",
"properties": {
"code": {
"anyOf": [
@@ -13935,7 +14035,7 @@ Submodules }
],
"default": null,
- "description": "Unique identifier of the `ExecutableCode` part. The server returns the `CodeExecutionResult` with the matching `id`.",
+ "description": "Optional. Unique identifier of the `ExecutableCode` part. The server returns the `CodeExecutionResult` with the matching `id`. This field is not supported in Vertex AI.",
"title": "Id"
}
},
@@ -14015,7 +14115,7 @@ Submodules },
"FunctionCall": {
"additionalProperties": false,
- "description": "A function call.",
+ "description": "A predicted FunctionCall returned from the model that contains a string representing the FunctionDeclaration.name and a structured JSON object containing the parameters and their values.",
"properties": {
"id": {
"anyOf": [
@@ -14027,7 +14127,7 @@ Submodules }
],
"default": null,
- "description": "The unique id of the function call. If populated, the client to execute the\n `function_call` and return the response with the matching `id`.",
+ "description": "Optional. The unique id of the function call. If populated, the client to execute the `function_call` and return the response with the matching `id`.",
"title": "Id"
},
"args": {
@@ -14041,7 +14141,7 @@ Submodules }
],
"default": null,
- "description": "Optional. The function parameters and values in JSON object format. See [FunctionDeclaration.parameters] for parameter details.",
+ "description": "Optional. The function parameters and values in JSON object format. See FunctionDeclaration.parameters for parameter details.",
"title": "Args"
},
"name": {
@@ -14054,7 +14154,7 @@ Submodules }
],
"default": null,
- "description": "Optional. The name of the function to call. Matches [FunctionDeclaration.name].",
+ "description": "Optional. The name of the function to call. Matches FunctionDeclaration.name.",
"title": "Name"
},
"partialArgs": {
@@ -14092,7 +14192,7 @@ Submodules },
"FunctionResponse": {
"additionalProperties": false,
- "description": "A function response.",
+ "description": "The result output from a FunctionCall that contains a string representing the FunctionDeclaration.name and a structured JSON object containing any output from the function is used as context to the model.\n\nThis should contain the result of a `FunctionCall` made based on model\nprediction.",
"properties": {
"willContinue": {
"anyOf": [
@@ -14104,7 +14204,7 @@ Submodules }
],
"default": null,
- "description": "Signals that function call continues, and more responses will be returned, turning the function call into a generator. Is only applicable to NON_BLOCKING function calls (see FunctionDeclaration.behavior for details), ignored otherwise. If false, the default, future responses will not be considered. Is only applicable to NON_BLOCKING function calls, is ignored otherwise. If set to false, future responses will not be considered. It is allowed to return empty `response` with `will_continue=False` to signal that the function call is finished.",
+ "description": "Optional. Signals that function call continues, and more responses will be returned, turning the function call into a generator. Is only applicable to NON_BLOCKING function calls, is ignored otherwise. If set to false, future responses will not be considered. It is allowed to return empty `response` with `will_continue=False` to signal that the function call is finished. This may still trigger the model generation. To avoid triggering the generation and finish the function call, additionally set `scheduling` to `SILENT`. This field is not supported in Vertex AI.",
"title": "Willcontinue"
},
"scheduling": {
@@ -14117,7 +14217,7 @@ Submodules }
],
"default": null,
- "description": "Specifies how the response should be scheduled in the conversation. Only applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults to WHEN_IDLE."
+ "description": "Optional. Specifies how the response should be scheduled in the conversation. Only applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults to WHEN_IDLE."
},
"parts": {
"anyOf": [
@@ -14132,7 +14232,7 @@ Submodules }
],
"default": null,
- "description": "List of parts that constitute a function response. Each part may\n have a different IANA MIME type.",
+ "description": "Optional. Ordered `Parts` that constitute a function response. Parts may have different IANA MIME types.",
"title": "Parts"
},
"id": {
@@ -14158,7 +14258,7 @@ Submodules }
],
"default": null,
- "description": "Required. The name of the function to call. Matches [FunctionDeclaration.name] and [FunctionCall.name].",
+ "description": "Required. The name of the function to call. Matches FunctionDeclaration.name and FunctionCall.name.",
"title": "Name"
},
"response": {
@@ -14181,7 +14281,7 @@ Submodules },
"FunctionResponseBlob": {
"additionalProperties": false,
- "description": "Raw media bytes for function response.\n\nText should not be sent as raw bytes, use the FunctionResponse.response\nfield.",
+ "description": "Raw media bytes for function response.\n\nText should not be sent as raw bytes, use the 'text' field.",
"properties": {
"mimeType": {
"anyOf": [
@@ -14207,7 +14307,7 @@ Submodules }
],
"default": null,
- "description": "Required. Inline media bytes.",
+ "description": "Required. Raw bytes.",
"title": "Data"
},
"displayName": {
@@ -14220,7 +14320,7 @@ Submodules }
],
"default": null,
- "description": "Optional. Display name of the blob.\n Used to provide a label or filename to distinguish blobs.",
+ "description": "Optional. Display name of the blob. Used to provide a label or filename to distinguish blobs. This field is only returned in PromptMessage for prompt management. It is currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled. This field is not supported in Gemini API.",
"title": "Displayname"
}
},
@@ -14229,7 +14329,7 @@ Submodules },
"FunctionResponseFileData": {
"additionalProperties": false,
- "description": "URI based data for function response.",
+ "description": "URI based data for function response.\n\nThis data type is not supported in Gemini API.",
"properties": {
"fileUri": {
"anyOf": [
@@ -14267,7 +14367,7 @@ Submodules }
],
"default": null,
- "description": "Optional. Display name of the file.\n Used to provide a label or filename to distinguish files.",
+ "description": "Optional. Display name of the file data. Used to provide a label or filename to distinguish file datas. This field is only returned in PromptMessage for prompt management. It is currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled.",
"title": "Displayname"
}
},
@@ -14276,7 +14376,7 @@ Submodules },
"FunctionResponsePart": {
"additionalProperties": false,
- "description": "A datatype containing media that is part of a `FunctionResponse` message.\n\nA `FunctionResponsePart` consists of data which has an associated datatype. A\n`FunctionResponsePart` can only contain one of the accepted types in\n`FunctionResponsePart.data`.\n\nA `FunctionResponsePart` must have a fixed IANA MIME type identifying the\ntype and subtype of the media if the `inline_data` field is filled with raw\nbytes.",
+ "description": "A datatype containing media that is part of a `FunctionResponse` message.\n\nA `FunctionResponsePart` consists of data which has an associated datatype. A\n`FunctionResponsePart` can only contain one of the accepted types in\n`FunctionResponsePart.data`. A `FunctionResponsePart` must have a fixed IANA\nMIME type identifying the type and subtype of the media if the `inline_data`\nfield is filled with raw bytes.",
"properties": {
"inlineData": {
"anyOf": [
@@ -14288,7 +14388,7 @@ Submodules }
],
"default": null,
- "description": "Optional. Inline media bytes."
+ "description": "Inline media bytes."
},
"fileData": {
"anyOf": [
@@ -14300,14 +14400,14 @@ Submodules }
],
"default": null,
- "description": "Optional. URI based data."
+ "description": "URI based data. This field is not supported in Gemini API."
}
},
"title": "FunctionResponsePart",
"type": "object"
},
"FunctionResponseScheduling": {
- "description": "Specifies how the response should be scheduled in the conversation.",
+ "description": "Specifies how the response should be scheduled in the conversation.\n\nOnly applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults\nto WHEN_IDLE.",
"enum": [
"SCHEDULING_UNSPECIFIED",
"SILENT",
@@ -15335,7 +15435,7 @@ Submodules }
],
"default": null,
- "description": "Optional. Page number of the retrieved context. This field is not supported in Vertex AI.",
+ "description": "Optional. Page number of the retrieved context, if applicable. This field is not supported in Vertex AI.",
"title": "Pagenumber"
},
"mediaId": {
@@ -15348,7 +15448,7 @@ Submodules }
],
"default": null,
- "description": "Optional. Media ID. This field is not supported in Vertex AI.",
+ "description": "Optional. The media blob resource name for multimodal file search results. Format: fileSearchStores/{file_search_store_id}/media/{blob_id}. This field is not supported in Vertex AI.",
"title": "Mediaid"
}
},
@@ -16499,6 +16599,32 @@ Submodules "default": null,
"description": "The content of the chunk.",
"title": "Text"
+ },
+ "chunkId": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "The ID of the chunk.",
+ "title": "Chunkid"
+ },
+ "fileId": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "The ID of the file that the chunk belongs to.",
+ "title": "Fileid"
}
},
"title": "RagChunk",
@@ -17367,7 +17493,7 @@ Submodules }
],
"default": null,
- "description": "The name of the BigQuery table created, in `predictions_<timestamp>` format, into which the prediction output is written.",
+ "description": "The name of the BigQuery table created, in `predictions_TIMESTAMP` format, into which the prediction output is written.",
"title": "Bigqueryoutputtable"
}
},
@@ -17389,7 +17515,7 @@ Submodules
-
field bigquery_output_table:
Optional[str] = None (alias 'bigqueryOutputTable')¶
-The name of the BigQuery table created, in predictions_<timestamp> format, into which the prediction output is written.
+The name of the BigQuery table created, in predictions_TIMESTAMP format, into which the prediction output is written.
- Validated by:
@@ -17435,7 +17561,7 @@ Submodules
-
bigquery_output_table:
Optional[str]¶
-The name of the BigQuery table created, in predictions_<timestamp> format, into which the prediction output is written.
+The name of the BigQuery table created, in predictions_TIMESTAMP format, into which the prediction output is written.
@@ -19234,7 +19360,7 @@ Submodules },
"CodeExecutionResult": {
"additionalProperties": false,
- "description": "Result of executing the `ExecutableCode`.\n\nGenerated only when the `CodeExecution` tool is used.",
+ "description": "Result of executing the ExecutableCode.\n\nGenerated only when the `CodeExecution` tool is used.",
"properties": {
"outcome": {
"anyOf": [
@@ -19271,7 +19397,7 @@ Submodules }
],
"default": null,
- "description": "The identifier of the `ExecutableCode` part this result is for. Only populated if the corresponding `ExecutableCode` has an id.",
+ "description": "Optional. The identifier of the `ExecutableCode` part this result is for. Only populated if the corresponding `ExecutableCode` has an id. This field is not supported in Vertex AI.",
"title": "Id"
}
},
@@ -19317,7 +19443,7 @@ Submodules },
"ExecutableCode": {
"additionalProperties": false,
- "description": "Model-generated code executed server-side, results returned to the model.\n\nOnly generated when using the `CodeExecution` tool, in which the code will\nbe automatically executed, and a corresponding `CodeExecutionResult` will\nalso be generated.",
+ "description": "Code generated by the model that is meant to be executed, and the result returned to the model.\n\nGenerated when using the `CodeExecution` tool, in which the code will be\nautomatically executed, and a corresponding CodeExecutionResult will also be\ngenerated.",
"properties": {
"code": {
"anyOf": [
@@ -19354,7 +19480,7 @@ Submodules }
],
"default": null,
- "description": "Unique identifier of the `ExecutableCode` part. The server returns the `CodeExecutionResult` with the matching `id`.",
+ "description": "Optional. Unique identifier of the `ExecutableCode` part. The server returns the `CodeExecutionResult` with the matching `id`. This field is not supported in Vertex AI.",
"title": "Id"
}
},
@@ -19434,7 +19560,7 @@ Submodules },
"FunctionCall": {
"additionalProperties": false,
- "description": "A function call.",
+ "description": "A predicted FunctionCall returned from the model that contains a string representing the FunctionDeclaration.name and a structured JSON object containing the parameters and their values.",
"properties": {
"id": {
"anyOf": [
@@ -19446,7 +19572,7 @@ Submodules }
],
"default": null,
- "description": "The unique id of the function call. If populated, the client to execute the\n `function_call` and return the response with the matching `id`.",
+ "description": "Optional. The unique id of the function call. If populated, the client to execute the `function_call` and return the response with the matching `id`.",
"title": "Id"
},
"args": {
@@ -19460,7 +19586,7 @@ Submodules }
],
"default": null,
- "description": "Optional. The function parameters and values in JSON object format. See [FunctionDeclaration.parameters] for parameter details.",
+ "description": "Optional. The function parameters and values in JSON object format. See FunctionDeclaration.parameters for parameter details.",
"title": "Args"
},
"name": {
@@ -19473,7 +19599,7 @@ Submodules }
],
"default": null,
- "description": "Optional. The name of the function to call. Matches [FunctionDeclaration.name].",
+ "description": "Optional. The name of the function to call. Matches FunctionDeclaration.name.",
"title": "Name"
},
"partialArgs": {
@@ -19511,7 +19637,7 @@ Submodules },
"FunctionResponse": {
"additionalProperties": false,
- "description": "A function response.",
+ "description": "The result output from a FunctionCall that contains a string representing the FunctionDeclaration.name and a structured JSON object containing any output from the function is used as context to the model.\n\nThis should contain the result of a `FunctionCall` made based on model\nprediction.",
"properties": {
"willContinue": {
"anyOf": [
@@ -19523,7 +19649,7 @@ Submodules }
],
"default": null,
- "description": "Signals that function call continues, and more responses will be returned, turning the function call into a generator. Is only applicable to NON_BLOCKING function calls (see FunctionDeclaration.behavior for details), ignored otherwise. If false, the default, future responses will not be considered. Is only applicable to NON_BLOCKING function calls, is ignored otherwise. If set to false, future responses will not be considered. It is allowed to return empty `response` with `will_continue=False` to signal that the function call is finished.",
+ "description": "Optional. Signals that function call continues, and more responses will be returned, turning the function call into a generator. Is only applicable to NON_BLOCKING function calls, is ignored otherwise. If set to false, future responses will not be considered. It is allowed to return empty `response` with `will_continue=False` to signal that the function call is finished. This may still trigger the model generation. To avoid triggering the generation and finish the function call, additionally set `scheduling` to `SILENT`. This field is not supported in Vertex AI.",
"title": "Willcontinue"
},
"scheduling": {
@@ -19536,7 +19662,7 @@ Submodules }
],
"default": null,
- "description": "Specifies how the response should be scheduled in the conversation. Only applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults to WHEN_IDLE."
+ "description": "Optional. Specifies how the response should be scheduled in the conversation. Only applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults to WHEN_IDLE."
},
"parts": {
"anyOf": [
@@ -19551,7 +19677,7 @@ Submodules }
],
"default": null,
- "description": "List of parts that constitute a function response. Each part may\n have a different IANA MIME type.",
+ "description": "Optional. Ordered `Parts` that constitute a function response. Parts may have different IANA MIME types.",
"title": "Parts"
},
"id": {
@@ -19577,7 +19703,7 @@ Submodules }
],
"default": null,
- "description": "Required. The name of the function to call. Matches [FunctionDeclaration.name] and [FunctionCall.name].",
+ "description": "Required. The name of the function to call. Matches FunctionDeclaration.name and FunctionCall.name.",
"title": "Name"
},
"response": {
@@ -19600,7 +19726,7 @@ Submodules },
"FunctionResponseBlob": {
"additionalProperties": false,
- "description": "Raw media bytes for function response.\n\nText should not be sent as raw bytes, use the FunctionResponse.response\nfield.",
+ "description": "Raw media bytes for function response.\n\nText should not be sent as raw bytes, use the 'text' field.",
"properties": {
"mimeType": {
"anyOf": [
@@ -19626,7 +19752,7 @@ Submodules }
],
"default": null,
- "description": "Required. Inline media bytes.",
+ "description": "Required. Raw bytes.",
"title": "Data"
},
"displayName": {
@@ -19639,7 +19765,7 @@ Submodules }
],
"default": null,
- "description": "Optional. Display name of the blob.\n Used to provide a label or filename to distinguish blobs.",
+ "description": "Optional. Display name of the blob. Used to provide a label or filename to distinguish blobs. This field is only returned in PromptMessage for prompt management. It is currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled. This field is not supported in Gemini API.",
"title": "Displayname"
}
},
@@ -19648,7 +19774,7 @@ Submodules },
"FunctionResponseFileData": {
"additionalProperties": false,
- "description": "URI based data for function response.",
+ "description": "URI based data for function response.\n\nThis data type is not supported in Gemini API.",
"properties": {
"fileUri": {
"anyOf": [
@@ -19686,7 +19812,7 @@ Submodules }
],
"default": null,
- "description": "Optional. Display name of the file.\n Used to provide a label or filename to distinguish files.",
+ "description": "Optional. Display name of the file data. Used to provide a label or filename to distinguish file datas. This field is only returned in PromptMessage for prompt management. It is currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled.",
"title": "Displayname"
}
},
@@ -19695,7 +19821,7 @@ Submodules },
"FunctionResponsePart": {
"additionalProperties": false,
- "description": "A datatype containing media that is part of a `FunctionResponse` message.\n\nA `FunctionResponsePart` consists of data which has an associated datatype. A\n`FunctionResponsePart` can only contain one of the accepted types in\n`FunctionResponsePart.data`.\n\nA `FunctionResponsePart` must have a fixed IANA MIME type identifying the\ntype and subtype of the media if the `inline_data` field is filled with raw\nbytes.",
+ "description": "A datatype containing media that is part of a `FunctionResponse` message.\n\nA `FunctionResponsePart` consists of data which has an associated datatype. A\n`FunctionResponsePart` can only contain one of the accepted types in\n`FunctionResponsePart.data`. A `FunctionResponsePart` must have a fixed IANA\nMIME type identifying the type and subtype of the media if the `inline_data`\nfield is filled with raw bytes.",
"properties": {
"inlineData": {
"anyOf": [
@@ -19707,7 +19833,7 @@ Submodules }
],
"default": null,
- "description": "Optional. Inline media bytes."
+ "description": "Inline media bytes."
},
"fileData": {
"anyOf": [
@@ -19719,14 +19845,14 @@ Submodules }
],
"default": null,
- "description": "Optional. URI based data."
+ "description": "URI based data. This field is not supported in Gemini API."
}
},
"title": "FunctionResponsePart",
"type": "object"
},
"FunctionResponseScheduling": {
- "description": "Specifies how the response should be scheduled in the conversation.",
+ "description": "Specifies how the response should be scheduled in the conversation.\n\nOnly applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults\nto WHEN_IDLE.",
"enum": [
"SCHEDULING_UNSPECIFIED",
"SILENT",
@@ -20394,7 +20520,7 @@ Submodules }
],
"default": null,
- "description": "Optional. Page number of the retrieved context. This field is not supported in Vertex AI.",
+ "description": "Optional. Page number of the retrieved context, if applicable. This field is not supported in Vertex AI.",
"title": "Pagenumber"
},
"mediaId": {
@@ -20407,7 +20533,7 @@ Submodules }
],
"default": null,
- "description": "Optional. Media ID. This field is not supported in Vertex AI.",
+ "description": "Optional. The media blob resource name for multimodal file search results. Format: fileSearchStores/{file_search_store_id}/media/{blob_id}. This field is not supported in Vertex AI.",
"title": "Mediaid"
}
},
@@ -21269,6 +21395,32 @@ Submodules "default": null,
"description": "The content of the chunk.",
"title": "Text"
+ },
+ "chunkId": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "The ID of the chunk.",
+ "title": "Chunkid"
+ },
+ "fileId": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "The ID of the file that the chunk belongs to.",
+ "title": "Fileid"
}
},
"title": "RagChunk",
@@ -22733,7 +22885,7 @@ Submodules
pydantic model genai.types.CodeExecutionResult¶
Bases: BaseModel
-Result of executing the ExecutableCode.
+Result of executing the ExecutableCode.
Generated only when the CodeExecution tool is used.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
@@ -22742,7 +22894,7 @@
Submodules
Show JSON schema {
"title": "CodeExecutionResult",
- "description": "Result of executing the `ExecutableCode`.\n\nGenerated only when the `CodeExecution` tool is used.",
+ "description": "Result of executing the ExecutableCode.\n\nGenerated only when the `CodeExecution` tool is used.",
"type": "object",
"properties": {
"outcome": {
@@ -22780,7 +22932,7 @@ Submodules }
],
"default": null,
- "description": "The identifier of the `ExecutableCode` part this result is for. Only populated if the corresponding `ExecutableCode` has an id.",
+ "description": "Optional. The identifier of the `ExecutableCode` part this result is for. Only populated if the corresponding `ExecutableCode` has an id. This field is not supported in Vertex AI.",
"title": "Id"
}
},
@@ -22815,7 +22967,7 @@ Submodules
-
field id:
Optional[str] = None¶
-The identifier of the ExecutableCode part this result is for. Only populated if the corresponding ExecutableCode has an id.
+Optional. The identifier of the ExecutableCode part this result is for. Only populated if the corresponding ExecutableCode has an id. This field is not supported in Vertex AI.
- Validated by:
@@ -22857,12 +23009,12 @@ Submodules
class genai.types.CodeExecutionResultDict¶
Bases: TypedDict
-Result of executing the ExecutableCode.
+Result of executing the ExecutableCode.
Generated only when the CodeExecution tool is used.
-
id:
Optional[str]¶
-The identifier of the ExecutableCode part this result is for. Only populated if the corresponding ExecutableCode has an id.
+Optional. The identifier of the ExecutableCode part this result is for. Only populated if the corresponding ExecutableCode has an id. This field is not supported in Vertex AI.
@@ -23051,252 +23203,25 @@ Submodules
--
-pydantic model genai.types.ComputationBasedMetricSpec¶
-Bases: BaseModel
-Specification for a computation based metric.
-Create a new model by parsing and validating input data from keyword arguments.
-Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
-validated to form a valid model.
-self is explicitly positional-only to allow self as a field name.
-
-Show JSON schema
{
- "title": "ComputationBasedMetricSpec",
- "description": "Specification for a computation based metric.",
- "type": "object",
- "properties": {
- "type": {
- "anyOf": [
- {
- "$ref": "#/$defs/ComputationBasedMetricType"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "The type of the computation based metric."
- },
- "parameters": {
- "anyOf": [
- {
- "additionalProperties": true,
- "type": "object"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "A map of parameters for the metric. ROUGE example: {\"rouge_type\": \"rougeL\", \"split_summaries\": True, \"use_stemmer\": True}. BLEU example: {\"use_effective_order\": True}.",
- "title": "Parameters"
- }
- },
- "$defs": {
- "ComputationBasedMetricType": {
- "description": "Represents the type of the computation based metric.",
- "enum": [
- "COMPUTATION_BASED_METRIC_TYPE_UNSPECIFIED",
- "EXACT_MATCH",
- "BLEU",
- "ROUGE"
- ],
- "title": "ComputationBasedMetricType",
- "type": "string"
- }
- },
- "additionalProperties": false
-}
-
-
-
-- Fields:
--
-
-- Validators:
-
-
-
--
-field parameters:
Optional[dict[str, Any]] = None¶
-A map of parameters for the metric. ROUGE example: {“rouge_type”: “rougeL”, “split_summaries”: True, “use_stemmer”: True}. BLEU example: {“use_effective_order”: True}.
-
-- Validated by:
-
-_check_field_type_mismatches
-
-
-
-
-
-
--
-field type:
Optional[ComputationBasedMetricType] = None¶
-The type of the computation based metric.
-
-- Validated by:
-
-_check_field_type_mismatches
-
-
-
-
-
-
-
-
--
-class genai.types.ComputationBasedMetricSpecDict¶
-Bases: TypedDict
-Specification for a computation based metric.
-
--
-parameters:
Optional[dict[str, Any]]¶
-“rougeL”, “split_summaries”: True, “use_stemmer”: True}. BLEU example: {“use_effective_order”: True}.
-
-- Type:
-A map of parameters for the metric. ROUGE example
-
-- Type:
-{“rouge_type”
-
-
-
-
-
--
-type:
Optional[ComputationBasedMetricType]¶
-The type of the computation based metric.
-
-
-
-
-
--
-class genai.types.ComputationBasedMetricType(*values)¶
-Bases: CaseInSensitiveEnum
-Represents the type of the computation based metric.
-
--
-BLEU = 'BLEU'¶
-BLEU metric.
-
-
-
--
-COMPUTATION_BASED_METRIC_TYPE_UNSPECIFIED = 'COMPUTATION_BASED_METRIC_TYPE_UNSPECIFIED'¶
-Computation based metric type is unspecified.
-
-
-
--
-EXACT_MATCH = 'EXACT_MATCH'¶
-Exact match metric.
-
-
-
--
-ROUGE = 'ROUGE'¶
-ROUGE metric.
-
-
-
-
-
--
-pydantic model genai.types.ComputeTokensConfig¶
-Bases: BaseModel
-Optional parameters for computing tokens.
-Create a new model by parsing and validating input data from keyword arguments.
-Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
-validated to form a valid model.
-self is explicitly positional-only to allow self as a field name.
-
-Show JSON schema
{
- "title": "ComputeTokensConfig",
- "type": "object",
- "properties": {
- "httpOptions": {
- "default": null,
- "title": "Httpoptions"
- }
- },
- "additionalProperties": false
-}
-
-
-
-- Fields:
--
-
-- Validators:
-
-
-
--
-field http_options:
Optional[HttpOptions] = None (alias 'httpOptions')¶
-Used to override HTTP request options.
-
-- Validated by:
-
-_check_field_type_mismatches
-
-
-
-
-
-
-
-
--
-class genai.types.ComputeTokensConfigDict¶
-Bases: TypedDict
-Optional parameters for computing tokens.
-
--
-http_options:
Optional[HttpOptionsDict]¶
-Used to override HTTP request options.
-
-
-
-
-
--
-pydantic model genai.types.ComputeTokensResponse¶
+-
+pydantic model genai.types.CompositeReinforcementTuningRewardConfig¶
Bases: BaseModel
-Response for computing tokens.
+Composite reinforcement tuning reward config.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{
- "title": "ComputeTokensResponse",
- "description": "Response for computing tokens.",
+ "title": "CompositeReinforcementTuningRewardConfig",
+ "description": "Composite reinforcement tuning reward config.",
"type": "object",
"properties": {
- "sdkHttpResponse": {
- "anyOf": [
- {
- "$ref": "#/$defs/HttpResponse"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "Used to retain the full HTTP response."
- },
- "tokensInfo": {
+ "weightedRewardConfigs": {
"anyOf": [
{
"items": {
- "$ref": "#/$defs/TokensInfo"
+ "$ref": "#/$defs/CompositeReinforcementTuningRewardConfigWeightedRewardConfig"
},
"type": "array"
},
@@ -23305,642 +23230,258 @@ Submodules }
],
"default": null,
- "description": "Lists of tokens info from the input. A ComputeTokensRequest could have multiple instances with a prompt in each instance. We also need to return lists of tokens info for the request with multiple instances.",
- "title": "Tokensinfo"
+ "description": "",
+ "title": "Weightedrewardconfigs"
}
},
"$defs": {
- "HttpResponse": {
+ "AutoraterConfig": {
"additionalProperties": false,
- "description": "A wrapper class for the http response.",
+ "description": "Autorater config used for evaluation.",
"properties": {
- "headers": {
+ "samplingCount": {
"anyOf": [
{
- "additionalProperties": {
- "type": "string"
- },
- "type": "object"
+ "type": "integer"
},
{
"type": "null"
}
],
"default": null,
- "description": "Used to retain the processed HTTP headers in the response.",
- "title": "Headers"
+ "description": "Number of samples for each instance in the dataset.\n If not specified, the default is 4. Minimum value is 1, maximum value\n is 32.",
+ "title": "Samplingcount"
},
- "body": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "The raw HTTP response body, in JSON format.",
- "title": "Body"
- }
- },
- "title": "HttpResponse",
- "type": "object"
- },
- "TokensInfo": {
- "additionalProperties": false,
- "description": "Tokens info with a list of tokens and the corresponding list of token ids.",
- "properties": {
- "role": {
+ "flipEnabled": {
"anyOf": [
{
- "type": "string"
+ "type": "boolean"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional fields for the role from the corresponding Content.",
- "title": "Role"
+ "description": "Optional. Default is true. Whether to flip the candidate and baseline\n responses. This is only applicable to the pairwise metric. If enabled, also\n provide PairwiseMetricSpec.candidate_response_field_name and\n PairwiseMetricSpec.baseline_response_field_name. When rendering\n PairwiseMetricSpec.metric_prompt_template, the candidate and baseline\n fields will be flipped for half of the samples to reduce bias.",
+ "title": "Flipenabled"
},
- "tokenIds": {
+ "autoraterModel": {
"anyOf": [
{
- "items": {
- "type": "integer"
- },
- "type": "array"
+ "type": "string"
},
{
"type": "null"
}
],
"default": null,
- "description": "A list of token ids from the input.",
- "title": "Tokenids"
+ "description": "The fully qualified name of the publisher model or tuned autorater\n endpoint to use.\n\n Publisher model format:\n `projects/{project}/locations/{location}/publishers/{publisher}/models/{model}`\n\n Tuned model endpoint format:\n `projects/{project}/locations/{location}/endpoints/{endpoint}`",
+ "title": "Autoratermodel"
},
- "tokens": {
+ "generationConfig": {
"anyOf": [
{
- "items": {
- "format": "base64url",
- "type": "string"
- },
- "type": "array"
+ "$ref": "#/$defs/GenerationConfig"
},
{
"type": "null"
}
],
"default": null,
- "description": "A list of tokens from the input.",
- "title": "Tokens"
+ "description": "Configuration options for model generation and outputs."
}
},
- "title": "TokensInfo",
+ "title": "AutoraterConfig",
"type": "object"
- }
- },
- "additionalProperties": false
-}
-
-
-
-- Fields:
--
-
-- Validators:
-
-
-
--
-field sdk_http_response:
Optional[HttpResponse] = None (alias 'sdkHttpResponse')¶
-Used to retain the full HTTP response.
-
-- Validated by:
-
-_check_field_type_mismatches
-
-
-
-
-
-
--
-field tokens_info:
Optional[list[TokensInfo]] = None (alias 'tokensInfo')¶
-Lists of tokens info from the input. A ComputeTokensRequest could have multiple instances with a prompt in each instance. We also need to return lists of tokens info for the request with multiple instances.
-
-- Validated by:
-
-_check_field_type_mismatches
-
-
-
-
-
-
-
-
--
-class genai.types.ComputeTokensResponseDict¶
-Bases: TypedDict
-Response for computing tokens.
-
--
-sdk_http_response:
Optional[HttpResponseDict]¶
-Used to retain the full HTTP response.
-
-
-
--
-tokens_info:
Optional[list[TokensInfoDict]]¶
-Lists of tokens info from the input. A ComputeTokensRequest could have multiple instances with a prompt in each instance. We also need to return lists of tokens info for the request with multiple instances.
-
-
-
-
-
--
-pydantic model genai.types.ComputeTokensResult¶
-Bases: BaseModel
-Local tokenizer compute tokens result.
-Create a new model by parsing and validating input data from keyword arguments.
-Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
-validated to form a valid model.
-self is explicitly positional-only to allow self as a field name.
-
-Show JSON schema
{
- "title": "ComputeTokensResult",
- "description": "Local tokenizer compute tokens result.",
- "type": "object",
- "properties": {
- "tokensInfo": {
- "anyOf": [
- {
- "items": {
- "$ref": "#/$defs/TokensInfo"
- },
- "type": "array"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "Lists of tokens info from the input.",
- "title": "Tokensinfo"
- }
- },
- "$defs": {
- "TokensInfo": {
+ },
+ "CompositeReinforcementTuningRewardConfigWeightedRewardConfig": {
"additionalProperties": false,
- "description": "Tokens info with a list of tokens and the corresponding list of token ids.",
+ "description": "Composite reinforcement tuning reward config weighted reward config.",
"properties": {
- "role": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "Optional fields for the role from the corresponding Content.",
- "title": "Role"
- },
- "tokenIds": {
+ "rewardConfig": {
"anyOf": [
{
- "items": {
- "type": "integer"
- },
- "type": "array"
+ "$ref": "#/$defs/SingleReinforcementTuningRewardConfig"
},
{
"type": "null"
}
],
"default": null,
- "description": "A list of token ids from the input.",
- "title": "Tokenids"
+ "description": ""
},
- "tokens": {
+ "weight": {
"anyOf": [
{
- "items": {
- "format": "base64url",
- "type": "string"
- },
- "type": "array"
+ "type": "number"
},
{
"type": "null"
}
],
"default": null,
- "description": "A list of tokens from the input.",
- "title": "Tokens"
+ "description": "How much this single reward contributes to the total overall reward.",
+ "title": "Weight"
}
},
- "title": "TokensInfo",
+ "title": "CompositeReinforcementTuningRewardConfigWeightedRewardConfig",
"type": "object"
- }
- },
- "additionalProperties": false
-}
-
-
-
-- Fields:
--
-
-- Validators:
-
-
-
--
-field tokens_info:
Optional[list[TokensInfo]] = None (alias 'tokensInfo')¶
-Lists of tokens info from the input.
-
-- Validated by:
-
-_check_field_type_mismatches
-
-
-
-
-
-
-
-
--
-class genai.types.ComputeTokensResultDict¶
-Bases: TypedDict
-Local tokenizer compute tokens result.
-
--
-tokens_info:
Optional[list[TokensInfoDict]]¶
-Lists of tokens info from the input.
-
-
-
-
-
--
-pydantic model genai.types.ComputerUse¶
-Bases: BaseModel
-Tool to support computer use.
-Create a new model by parsing and validating input data from keyword arguments.
-Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
-validated to form a valid model.
-self is explicitly positional-only to allow self as a field name.
-
-Show JSON schema
{
- "title": "ComputerUse",
- "description": "Tool to support computer use.",
- "type": "object",
- "properties": {
- "environment": {
- "anyOf": [
- {
- "$ref": "#/$defs/Environment"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "Required. The environment being operated."
},
- "excludedPredefinedFunctions": {
- "anyOf": [
- {
- "items": {
- "type": "string"
- },
- "type": "array"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "By default, predefined functions are included in the final model call.\n Some of them can be explicitly excluded from being automatically included.\n This can serve two purposes:\n 1. Using a more restricted / different action space.\n 2. Improving the definitions / instructions of predefined functions.",
- "title": "Excludedpredefinedfunctions"
- }
- },
- "$defs": {
- "Environment": {
- "description": "The environment being operated.",
+ "FeatureSelectionPreference": {
+ "description": "Options for feature selection preference.",
"enum": [
- "ENVIRONMENT_UNSPECIFIED",
- "ENVIRONMENT_BROWSER"
+ "FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",
+ "PRIORITIZE_QUALITY",
+ "BALANCED",
+ "PRIORITIZE_COST"
],
- "title": "Environment",
+ "title": "FeatureSelectionPreference",
"type": "string"
- }
- },
- "additionalProperties": false
-}
-
-
-
-- Fields:
--
-
-- Validators:
-
-
-
--
-field environment:
Optional[Environment] = None¶
-Required. The environment being operated.
-
-- Validated by:
-
-_check_field_type_mismatches
-
-
-
-
-
-
--
-field excluded_predefined_functions:
Optional[list[str]] = None (alias 'excludedPredefinedFunctions')¶
-By default, predefined functions are included in the final model call.
-Some of them can be explicitly excluded from being automatically included.
-This can serve two purposes:
-
-
-Using a more restricted / different action space.
-Improving the definitions / instructions of predefined functions.
-
-
-
-- Validated by:
-
-_check_field_type_mismatches
-
-
-
-
-
-
-
-
--
-class genai.types.ComputerUseDict¶
-Bases: TypedDict
-Tool to support computer use.
-
--
-environment:
Optional[Environment]¶
-Required. The environment being operated.
-
-
-
--
-excluded_predefined_functions:
Optional[list[str]]¶
-By default, predefined functions are included in the final model call.
-Some of them can be explicitly excluded from being automatically included.
-This can serve two purposes:
-
-
-Using a more restricted / different action space.
-Improving the definitions / instructions of predefined functions.
-
-
-
-
-
-
-
--
-pydantic model genai.types.Content¶
-Bases: BaseModel
-Contains the multi-part content of a message.
-Create a new model by parsing and validating input data from keyword arguments.
-Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
-validated to form a valid model.
-self is explicitly positional-only to allow self as a field name.
-
-Show JSON schema
{
- "title": "Content",
- "description": "Contains the multi-part content of a message.",
- "type": "object",
- "properties": {
- "parts": {
- "anyOf": [
- {
- "items": {
- "$ref": "#/$defs/Part"
- },
- "type": "array"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "List of parts that constitute a single message. Each part may have\n a different IANA MIME type.",
- "title": "Parts"
},
- "role": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "Optional. The producer of the content. Must be either 'user' or 'model'. If not set, the service will default to 'user'.",
- "title": "Role"
- }
- },
- "$defs": {
- "Blob": {
+ "GenerationConfig": {
"additionalProperties": false,
- "description": "A content blob.\n\nA Blob contains data of a specific media type. It is used to represent images,\naudio, and video.",
+ "description": "Generation config.",
"properties": {
- "data": {
+ "modelSelectionConfig": {
"anyOf": [
{
- "format": "base64url",
- "type": "string"
+ "$ref": "#/$defs/ModelSelectionConfig"
},
{
"type": "null"
}
],
"default": null,
- "description": "Required. The raw bytes of the data.",
- "title": "Data"
+ "description": "Optional. Config for model selection."
},
- "displayName": {
+ "responseJsonSchema": {
"anyOf": [
- {
- "type": "string"
- },
+ {},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. The display name of the blob. Used to provide a label or filename to distinguish blobs. This field is only returned in `PromptMessage` for prompt management. It is used in the Gemini calls only when server-side tools (`code_execution`, `google_search`, and `url_context`) are enabled. This field is not supported in Gemini API.",
- "title": "Displayname"
+ "description": "Output schema of the generated response. This is an alternative to\n `response_schema` that accepts [JSON Schema](https://json-schema.org/).\n ",
+ "title": "Responsejsonschema"
},
- "mimeType": {
+ "audioTimestamp": {
"anyOf": [
{
- "type": "string"
+ "type": "boolean"
},
{
"type": "null"
}
],
"default": null,
- "description": "Required. The IANA standard MIME type of the source data.",
- "title": "Mimetype"
- }
- },
- "title": "Blob",
- "type": "object"
- },
- "CodeExecutionResult": {
- "additionalProperties": false,
- "description": "Result of executing the `ExecutableCode`.\n\nGenerated only when the `CodeExecution` tool is used.",
- "properties": {
- "outcome": {
+ "description": "Optional. If enabled, audio timestamps will be included in the request to the model. This can be useful for synchronizing audio with other modalities in the response. This field is not supported in Gemini API.",
+ "title": "Audiotimestamp"
+ },
+ "candidateCount": {
"anyOf": [
{
- "$ref": "#/$defs/Outcome"
+ "type": "integer"
},
{
"type": "null"
}
],
"default": null,
- "description": "Required. Outcome of the code execution."
+ "description": "Optional. The number of candidate responses to generate. A higher `candidate_count` can provide more options to choose from, but it also consumes more resources. This can be useful for generating a variety of responses and selecting the best one.",
+ "title": "Candidatecount"
},
- "output": {
+ "enableAffectiveDialog": {
"anyOf": [
{
- "type": "string"
+ "type": "boolean"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. Contains stdout when code execution is successful, stderr or other description otherwise.",
- "title": "Output"
+ "description": "Optional. If enabled, the model will detect emotions and adapt its responses accordingly. For example, if the model detects that the user is frustrated, it may provide a more empathetic response. This field is not supported in Gemini API.",
+ "title": "Enableaffectivedialog"
},
- "id": {
+ "frequencyPenalty": {
"anyOf": [
{
- "type": "string"
+ "type": "number"
},
{
"type": "null"
}
],
"default": null,
- "description": "The identifier of the `ExecutableCode` part this result is for. Only populated if the corresponding `ExecutableCode` has an id.",
- "title": "Id"
- }
- },
- "title": "CodeExecutionResult",
- "type": "object"
- },
- "ExecutableCode": {
- "additionalProperties": false,
- "description": "Model-generated code executed server-side, results returned to the model.\n\nOnly generated when using the `CodeExecution` tool, in which the code will\nbe automatically executed, and a corresponding `CodeExecutionResult` will\nalso be generated.",
- "properties": {
- "code": {
+ "description": "Optional. Penalizes tokens based on their frequency in the generated text. A positive value helps to reduce the repetition of words and phrases. Valid values can range from [-2.0, 2.0].",
+ "title": "Frequencypenalty"
+ },
+ "logprobs": {
"anyOf": [
{
- "type": "string"
+ "type": "integer"
},
{
"type": "null"
}
],
"default": null,
- "description": "Required. The code to be executed.",
- "title": "Code"
+ "description": "Optional. The number of top log probabilities to return for each token. This can be used to see which other tokens were considered likely candidates for a given position. A higher value will return more options, but it will also increase the size of the response.",
+ "title": "Logprobs"
},
- "language": {
+ "maxOutputTokens": {
"anyOf": [
{
- "$ref": "#/$defs/Language"
+ "type": "integer"
},
{
"type": "null"
}
],
"default": null,
- "description": "Required. Programming language of the `code`."
+ "description": "Optional. The maximum number of tokens to generate in the response. A token is approximately four characters. The default value varies by model. This parameter can be used to control the length of the generated text and prevent overly long responses.",
+ "title": "Maxoutputtokens"
},
- "id": {
+ "mediaResolution": {
"anyOf": [
{
- "type": "string"
+ "$ref": "#/$defs/MediaResolution"
},
{
"type": "null"
}
],
"default": null,
- "description": "Unique identifier of the `ExecutableCode` part. The server returns the `CodeExecutionResult` with the matching `id`.",
- "title": "Id"
- }
- },
- "title": "ExecutableCode",
- "type": "object"
- },
- "FileData": {
- "additionalProperties": false,
- "description": "URI-based data.\n\nA FileData message contains a URI pointing to data of a specific media type.\nIt is used to represent images, audio, and video stored in Google Cloud\nStorage.",
- "properties": {
- "displayName": {
+ "description": "Optional. The token resolution at which input media content is sampled. This is used to control the trade-off between the quality of the response and the number of tokens used to represent the media. A higher resolution allows the model to perceive more detail, which can lead to a more nuanced response, but it will also use more tokens. This does not affect the image dimensions sent to the model."
+ },
+ "presencePenalty": {
"anyOf": [
{
- "type": "string"
+ "type": "number"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. The display name of the file. Used to provide a label or filename to distinguish files. This field is only returned in `PromptMessage` for prompt management. It is used in the Gemini calls only when server side tools (`code_execution`, `google_search`, and `url_context`) are enabled. This field is not supported in Gemini API.",
- "title": "Displayname"
+ "description": "Optional. Penalizes tokens that have already appeared in the generated text. A positive value encourages the model to generate more diverse and less repetitive text. Valid values can range from [-2.0, 2.0].",
+ "title": "Presencepenalty"
},
- "fileUri": {
+ "responseLogprobs": {
"anyOf": [
{
- "type": "string"
+ "type": "boolean"
},
{
"type": "null"
}
],
"default": null,
- "description": "Required. The URI of the file in Google Cloud Storage.",
- "title": "Fileuri"
+ "description": "Optional. If set to true, the log probabilities of the output tokens are returned. Log probabilities are the logarithm of the probability of a token appearing in the output. A higher log probability means the token is more likely to be generated. This can be useful for analyzing the model's confidence in its own output and for debugging.",
+ "title": "Responselogprobs"
},
- "mimeType": {
+ "responseMimeType": {
"anyOf": [
{
"type": "string"
@@ -23950,213 +23491,203 @@ Submodules }
],
"default": null,
- "description": "Required. The IANA standard MIME type of the source data.",
- "title": "Mimetype"
- }
- },
- "title": "FileData",
- "type": "object"
- },
- "FunctionCall": {
- "additionalProperties": false,
- "description": "A function call.",
- "properties": {
- "id": {
+ "description": "Optional. The IANA standard MIME type of the response. The model will generate output that conforms to this MIME type. Supported values include 'text/plain' (default) and 'application/json'. The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined.",
+ "title": "Responsemimetype"
+ },
+ "responseModalities": {
"anyOf": [
{
- "type": "string"
+ "items": {
+ "$ref": "#/$defs/Modality"
+ },
+ "type": "array"
},
{
"type": "null"
}
],
"default": null,
- "description": "The unique id of the function call. If populated, the client to execute the\n `function_call` and return the response with the matching `id`.",
- "title": "Id"
+ "description": "Optional. The modalities of the response. The model will generate a response that includes all the specified modalities. For example, if this is set to `[TEXT, IMAGE]`, the response will include both text and an image.",
+ "title": "Responsemodalities"
},
- "args": {
+ "responseSchema": {
"anyOf": [
{
- "additionalProperties": true,
- "type": "object"
+ "$ref": "#/$defs/Schema"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. The function parameters and values in JSON object format. See [FunctionDeclaration.parameters] for parameter details.",
- "title": "Args"
+ "description": "Optional. Lets you to specify a schema for the model's response, ensuring that the output conforms to a particular structure. This is useful for generating structured data such as JSON. The schema is a subset of the [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema) object. When this field is set, you must also set the `response_mime_type` to `application/json`."
},
- "name": {
+ "routingConfig": {
"anyOf": [
{
- "type": "string"
+ "$ref": "#/$defs/GenerationConfigRoutingConfig"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. The name of the function to call. Matches [FunctionDeclaration.name].",
- "title": "Name"
+ "description": "Optional. Routing configuration. This field is not supported in Gemini API."
},
- "partialArgs": {
+ "seed": {
"anyOf": [
{
- "items": {
- "$ref": "#/$defs/PartialArg"
- },
- "type": "array"
+ "type": "integer"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. The partial argument value of the function call. If provided, represents the arguments/fields that are streamed incrementally. This field is not supported in Gemini API.",
- "title": "Partialargs"
+ "description": "Optional. A seed for the random number generator. By setting a seed, you can make the model's output mostly deterministic. For a given prompt and parameters (like temperature, top_p, etc.), the model will produce the same response every time. However, it's not a guaranteed absolute deterministic behavior. This is different from parameters like `temperature`, which control the *level* of randomness. `seed` ensures that the \"random\" choices the model makes are the same on every run, making it essential for testing and ensuring reproducible results.",
+ "title": "Seed"
},
- "willContinue": {
+ "speechConfig": {
"anyOf": [
{
- "type": "boolean"
+ "$ref": "#/$defs/SpeechConfig"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. Whether this is the last part of the FunctionCall. If true, another partial message for the current FunctionCall is expected to follow. This field is not supported in Gemini API.",
- "title": "Willcontinue"
- }
- },
- "title": "FunctionCall",
- "type": "object"
- },
- "FunctionResponse": {
- "additionalProperties": false,
- "description": "A function response.",
- "properties": {
- "willContinue": {
+ "description": "Optional. The speech generation config."
+ },
+ "stopSequences": {
"anyOf": [
{
- "type": "boolean"
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
},
{
"type": "null"
}
],
"default": null,
- "description": "Signals that function call continues, and more responses will be returned, turning the function call into a generator. Is only applicable to NON_BLOCKING function calls (see FunctionDeclaration.behavior for details), ignored otherwise. If false, the default, future responses will not be considered. Is only applicable to NON_BLOCKING function calls, is ignored otherwise. If set to false, future responses will not be considered. It is allowed to return empty `response` with `will_continue=False` to signal that the function call is finished.",
- "title": "Willcontinue"
+ "description": "Optional. A list of character sequences that will stop the model from generating further tokens. If a stop sequence is generated, the output will end at that point. This is useful for controlling the length and structure of the output. For example, you can use [\"\n\", \"###\"] to stop generation at a new line or a specific marker.",
+ "title": "Stopsequences"
},
- "scheduling": {
+ "temperature": {
"anyOf": [
{
- "$ref": "#/$defs/FunctionResponseScheduling"
+ "type": "number"
},
{
"type": "null"
}
],
"default": null,
- "description": "Specifies how the response should be scheduled in the conversation. Only applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults to WHEN_IDLE."
+ "description": "Optional. Controls the randomness of the output. A higher temperature results in more creative and diverse responses, while a lower temperature makes the output more predictable and focused. The valid range is (0.0, 2.0].",
+ "title": "Temperature"
},
- "parts": {
+ "thinkingConfig": {
"anyOf": [
{
- "items": {
- "$ref": "#/$defs/FunctionResponsePart"
- },
- "type": "array"
+ "$ref": "#/$defs/ThinkingConfig"
},
{
"type": "null"
}
],
"default": null,
- "description": "List of parts that constitute a function response. Each part may\n have a different IANA MIME type.",
- "title": "Parts"
+ "description": "Optional. Configuration for thinking features. An error will be returned if this field is set for models that don't support thinking."
},
- "id": {
+ "topK": {
"anyOf": [
{
- "type": "string"
+ "type": "number"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. The id of the function call this response is for. Populated by the client to match the corresponding function call `id`.",
- "title": "Id"
+ "description": "Optional. Specifies the top-k sampling threshold. The model considers only the top k most probable tokens for the next token. This can be useful for generating more coherent and less random text. For example, a `top_k` of 40 means the model will choose the next word from the 40 most likely words.",
+ "title": "Topk"
},
- "name": {
+ "topP": {
"anyOf": [
{
- "type": "string"
+ "type": "number"
},
{
"type": "null"
}
],
"default": null,
- "description": "Required. The name of the function to call. Matches [FunctionDeclaration.name] and [FunctionCall.name].",
- "title": "Name"
+ "description": "Optional. Specifies the nucleus sampling threshold. The model considers only the smallest set of tokens whose cumulative probability is at least `top_p`. This helps generate more diverse and less repetitive responses. For example, a `top_p` of 0.9 means the model considers tokens until the cumulative probability of the tokens to select from reaches 0.9. It's recommended to adjust either temperature or `top_p`, but not both.",
+ "title": "Topp"
},
- "response": {
+ "enableEnhancedCivicAnswers": {
"anyOf": [
{
- "additionalProperties": true,
- "type": "object"
+ "type": "boolean"
},
{
"type": "null"
}
],
"default": null,
- "description": "Required. The function response in JSON object format. Use \"output\" key to specify function output and \"error\" key to specify error details (if any). If \"output\" and \"error\" keys are not specified, then whole \"response\" is treated as function output.",
- "title": "Response"
+ "description": "Optional. Enables enhanced civic answers. It may not be available for all models. This field is not supported in Vertex AI.",
+ "title": "Enableenhancedcivicanswers"
}
},
- "title": "FunctionResponse",
+ "title": "GenerationConfig",
"type": "object"
},
- "FunctionResponseBlob": {
+ "GenerationConfigRoutingConfig": {
"additionalProperties": false,
- "description": "Raw media bytes for function response.\n\nText should not be sent as raw bytes, use the FunctionResponse.response\nfield.",
+ "description": "The configuration for routing the request to a specific model.\n\nThis can be used to control which model is used for the generation, either\nautomatically or by specifying a model name. This data type is not supported\nin Gemini API.",
"properties": {
- "mimeType": {
+ "autoMode": {
"anyOf": [
{
- "type": "string"
+ "$ref": "#/$defs/GenerationConfigRoutingConfigAutoRoutingMode"
},
{
"type": "null"
}
],
"default": null,
- "description": "Required. The IANA standard MIME type of the source data.",
- "title": "Mimetype"
+ "description": "In this mode, the model is selected automatically based on the content of the request."
},
- "data": {
+ "manualMode": {
"anyOf": [
{
- "format": "base64url",
- "type": "string"
+ "$ref": "#/$defs/GenerationConfigRoutingConfigManualRoutingMode"
},
{
"type": "null"
}
],
"default": null,
- "description": "Required. Inline media bytes.",
- "title": "Data"
- },
- "displayName": {
+ "description": "In this mode, the model is specified manually."
+ }
+ },
+ "title": "GenerationConfigRoutingConfig",
+ "type": "object"
+ },
+ "GenerationConfigRoutingConfigAutoRoutingMode": {
+ "additionalProperties": false,
+ "description": "The configuration for automated routing.\n\nWhen automated routing is specified, the routing will be determined by the\npretrained routing model and customer provided model routing preference. This\ndata type is not supported in Gemini API.",
+ "properties": {
+ "modelRoutingPreference": {
"anyOf": [
{
+ "enum": [
+ "UNKNOWN",
+ "PRIORITIZE_QUALITY",
+ "BALANCED",
+ "PRIORITIZE_COST"
+ ],
"type": "string"
},
{
@@ -24164,18 +23695,18 @@ Submodules }
],
"default": null,
- "description": "Optional. Display name of the blob.\n Used to provide a label or filename to distinguish blobs.",
- "title": "Displayname"
+ "description": "The model routing preference.",
+ "title": "Modelroutingpreference"
}
},
- "title": "FunctionResponseBlob",
+ "title": "GenerationConfigRoutingConfigAutoRoutingMode",
"type": "object"
},
- "FunctionResponseFileData": {
+ "GenerationConfigRoutingConfigManualRoutingMode": {
"additionalProperties": false,
- "description": "URI based data for function response.",
+ "description": "The configuration for manual routing.\n\nWhen manual routing is specified, the model will be selected based on the\nmodel name provided. This data type is not supported in Gemini API.",
"properties": {
- "fileUri": {
+ "modelName": {
"anyOf": [
{
"type": "string"
@@ -24185,10 +23716,129 @@ Submodules }
],
"default": null,
- "description": "Required. URI.",
- "title": "Fileuri"
+ "description": "The name of the model to use. Only public LLM models are accepted.",
+ "title": "Modelname"
+ }
+ },
+ "title": "GenerationConfigRoutingConfigManualRoutingMode",
+ "type": "object"
+ },
+ "MatchOperation": {
+ "description": "Match operation to use for evaluation.",
+ "enum": [
+ "MATCH_OPERATION_UNSPECIFIED",
+ "REGEX_CONTAINS",
+ "PARTIAL_MATCH",
+ "EXACT_MATCH"
+ ],
+ "title": "MatchOperation",
+ "type": "string"
+ },
+ "MediaResolution": {
+ "description": "The media resolution to use.",
+ "enum": [
+ "MEDIA_RESOLUTION_UNSPECIFIED",
+ "MEDIA_RESOLUTION_LOW",
+ "MEDIA_RESOLUTION_MEDIUM",
+ "MEDIA_RESOLUTION_HIGH"
+ ],
+ "title": "MediaResolution",
+ "type": "string"
+ },
+ "Modality": {
+ "description": "Server content modalities.",
+ "enum": [
+ "MODALITY_UNSPECIFIED",
+ "TEXT",
+ "IMAGE",
+ "AUDIO",
+ "VIDEO"
+ ],
+ "title": "Modality",
+ "type": "string"
+ },
+ "ModelSelectionConfig": {
+ "additionalProperties": false,
+ "description": "Config for model selection.",
+ "properties": {
+ "featureSelectionPreference": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/FeatureSelectionPreference"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Options for feature selection preference."
+ }
+ },
+ "title": "ModelSelectionConfig",
+ "type": "object"
+ },
+ "MultiSpeakerVoiceConfig": {
+ "additionalProperties": false,
+ "description": "Configuration for a multi-speaker text-to-speech request.",
+ "properties": {
+ "speakerVoiceConfigs": {
+ "anyOf": [
+ {
+ "items": {
+ "$ref": "#/$defs/SpeakerVoiceConfig"
+ },
+ "type": "array"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Required. A list of configurations for the voices of the speakers. Exactly two speaker voice configurations must be provided.",
+ "title": "Speakervoiceconfigs"
+ }
+ },
+ "title": "MultiSpeakerVoiceConfig",
+ "type": "object"
+ },
+ "PrebuiltVoiceConfig": {
+ "additionalProperties": false,
+ "description": "Configuration for a prebuilt voice.",
+ "properties": {
+ "voiceName": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "The name of the prebuilt voice to use.",
+ "title": "Voicename"
+ }
+ },
+ "title": "PrebuiltVoiceConfig",
+ "type": "object"
+ },
+ "ReinforcementTuningAutoraterScorer": {
+ "additionalProperties": false,
+ "description": "Reinforcement tuning autorater scorer.",
+ "properties": {
+ "autoraterConfig": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/AutoraterConfig"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Autorater config for evaluation."
},
- "mimeType": {
+ "autoraterPrompt": {
"anyOf": [
{
"type": "string"
@@ -24198,10 +23848,80 @@ Submodules }
],
"default": null,
- "description": "Required. The IANA standard MIME type of the source data.",
- "title": "Mimetype"
+ "description": "Allows substituting `prompt`, `response`, `system_instruction` and `references.reference` (each wrapped in double curly braces) into the autorater prompt.",
+ "title": "Autoraterprompt"
},
- "displayName": {
+ "autoraterResponseParseConfig": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/ReinforcementTuningParseResponseConfig"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Parses autorater returned response."
+ },
+ "parsedResponseConversionScorer": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/ReinforcementTuningAutoraterScorerParsedResponseConversionScorer"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Scores autorater responses by directly converting parsed autorater response to float reward."
+ },
+ "exactMatchScorer": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/ReinforcementTuningAutoraterScorerExactMatchScorer"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Scores autorater responses by using exact string match reward scorer."
+ }
+ },
+ "title": "ReinforcementTuningAutoraterScorer",
+ "type": "object"
+ },
+ "ReinforcementTuningAutoraterScorerExactMatchScorer": {
+ "additionalProperties": false,
+ "description": "Scores autorater responses by using exact string match reward scorer.",
+ "properties": {
+ "correctAnswerReward": {
+ "anyOf": [
+ {
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Assigns this reward score if parsed response string equals the expression.",
+ "title": "Correctanswerreward"
+ },
+ "wrongAnswerReward": {
+ "anyOf": [
+ {
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Assigns this reward score if parsed reward value does not equal the expression.",
+ "title": "Wronganswerreward"
+ },
+ "expression": {
"anyOf": [
{
"type": "string"
@@ -24211,244 +23931,562 @@ Submodules }
],
"default": null,
- "description": "Optional. Display name of the file.\n Used to provide a label or filename to distinguish files.",
- "title": "Displayname"
+ "description": "The string expression to match against. Supports substitution in the format of `references.reference` (wrapped in double curly braces) before matching. No regex support.",
+ "title": "Expression"
}
},
- "title": "FunctionResponseFileData",
+ "title": "ReinforcementTuningAutoraterScorerExactMatchScorer",
"type": "object"
},
- "FunctionResponsePart": {
+ "ReinforcementTuningAutoraterScorerParsedResponseConversionScorer": {
+ "additionalProperties": false,
+ "description": "Scores responses by directly converting parsed autorater response to float reward (reward is clipped to be within [-1, 1]).",
+ "properties": {},
+ "title": "ReinforcementTuningAutoraterScorerParsedResponseConversionScorer",
+ "type": "object"
+ },
+ "ReinforcementTuningCloudRunRewardScorer": {
"additionalProperties": false,
- "description": "A datatype containing media that is part of a `FunctionResponse` message.\n\nA `FunctionResponsePart` consists of data which has an associated datatype. A\n`FunctionResponsePart` can only contain one of the accepted types in\n`FunctionResponsePart.data`.\n\nA `FunctionResponsePart` must have a fixed IANA MIME type identifying the\ntype and subtype of the media if the `inline_data` field is filled with raw\nbytes.",
+ "description": "Scores parsed responses by calling a Cloud Run service.",
"properties": {
- "inlineData": {
+ "cloudRunUri": {
"anyOf": [
{
- "$ref": "#/$defs/FunctionResponseBlob"
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "URI of the Cloud Run service that will be used to compute the reward. The Vertex AI Secure Fine Tuning Service Agent (`service-PROJECT_NUMBER@gcp-sa-vertex-tune.iam.gserviceaccount.com`, where `PROJECT_NUMBER` is the numeric project number) must be granted the permission (e.g. by granting `roles/run.invoker` in IAM) to invoke the Cloud Run service.",
+ "title": "Cloudrunuri"
+ }
+ },
+ "title": "ReinforcementTuningCloudRunRewardScorer",
+ "type": "object"
+ },
+ "ReinforcementTuningCodeExecutionRewardScorer": {
+ "additionalProperties": false,
+ "description": "Scores parsed responses for code execution use cases.",
+ "properties": {
+ "pythonCodeSnippet": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Example python code snippet which assigns reward of 1 to answer matching user provided reference answer in per prompt references map.",
+ "title": "Pythoncodesnippet"
+ }
+ },
+ "title": "ReinforcementTuningCodeExecutionRewardScorer",
+ "type": "object"
+ },
+ "ReinforcementTuningParseResponseConfig": {
+ "additionalProperties": false,
+ "description": "Defines how to parse sample response for reinforcement tuning.",
+ "properties": {
+ "parseType": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/ResponseParseType"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. Inline media bytes."
+ "description": "Defines how to parse sample response."
},
- "fileData": {
+ "regexExtractExpression": {
"anyOf": [
{
- "$ref": "#/$defs/FunctionResponseFileData"
+ "type": "string"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. URI based data."
+ "description": "Defines the regex to extract the important part of sample response. This field is only used when `parse_type` is `REGEX_EXTRACT`.",
+ "title": "Regexextractexpression"
}
},
- "title": "FunctionResponsePart",
+ "title": "ReinforcementTuningParseResponseConfig",
"type": "object"
},
- "FunctionResponseScheduling": {
- "description": "Specifies how the response should be scheduled in the conversation.",
- "enum": [
- "SCHEDULING_UNSPECIFIED",
- "SILENT",
- "WHEN_IDLE",
- "INTERRUPT"
- ],
- "title": "FunctionResponseScheduling",
- "type": "string"
+ "ReinforcementTuningStringMatchRewardScorer": {
+ "additionalProperties": false,
+ "description": "Scores parsed responses for string matching use cases.",
+ "properties": {
+ "wrongAnswerReward": {
+ "anyOf": [
+ {
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Wrong answer reward is returned if evaluator evaluates to `false`. All wrong answers get the same reward.",
+ "title": "Wronganswerreward"
+ },
+ "correctAnswerReward": {
+ "anyOf": [
+ {
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Correct answer reward is returned if evaluator evaluates to `true`. All correct answers get the same reward.",
+ "title": "Correctanswerreward"
+ },
+ "stringMatchExpression": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/ReinforcementTuningStringMatchRewardScorerStringMatchExpression"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Uses string match expression to evaluate parsed response."
+ },
+ "jsonMatchExpression": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/ReinforcementTuningStringMatchRewardScorerJsonMatchExpression"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Uses json match expression to evaluate parsed response."
+ }
+ },
+ "title": "ReinforcementTuningStringMatchRewardScorer",
+ "type": "object"
},
- "Language": {
- "description": "Programming language of the `code`.",
- "enum": [
- "LANGUAGE_UNSPECIFIED",
- "PYTHON"
- ],
- "title": "Language",
- "type": "string"
+ "ReinforcementTuningStringMatchRewardScorerJsonMatchExpression": {
+ "additionalProperties": false,
+ "description": "Converts parsed responses to JSON format, finds the first-level matching key, then performs StringMatchExpression on the value.",
+ "properties": {
+ "keyName": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Json key name to find the value to match against.",
+ "title": "Keyname"
+ },
+ "valueStringMatchExpression": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/ReinforcementTuningStringMatchRewardScorerStringMatchExpression"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "String match expression to match against the value of json key."
+ }
+ },
+ "title": "ReinforcementTuningStringMatchRewardScorerJsonMatchExpression",
+ "type": "object"
},
- "Outcome": {
- "description": "Outcome of the code execution.",
+ "ReinforcementTuningStringMatchRewardScorerStringMatchExpression": {
+ "additionalProperties": false,
+ "description": "Evaluates parsed response using match type against expression.",
+ "properties": {
+ "matchOperation": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/MatchOperation"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Match operation to use for evaluation."
+ },
+ "expression": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "String or regular expression to match against. Customer can also provide a references map (key/value pairs) whose value will be substituted into the expression by referencing `references.key_name` (wrapped in double curly braces).",
+ "title": "Expression"
+ }
+ },
+ "title": "ReinforcementTuningStringMatchRewardScorerStringMatchExpression",
+ "type": "object"
+ },
+ "ReplicatedVoiceConfig": {
+ "additionalProperties": false,
+ "description": "The configuration for the replicated voice to use.",
+ "properties": {
+ "mimeType": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "The mimetype of the voice sample. The only currently supported\n value is `audio/wav`. This represents 16-bit signed little-endian wav\n data, with a 24kHz sampling rate.\n ",
+ "title": "Mimetype"
+ },
+ "voiceSampleAudio": {
+ "anyOf": [
+ {
+ "format": "base64url",
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "The sample of the custom voice.\n ",
+ "title": "Voicesampleaudio"
+ },
+ "consentAudio": {
+ "anyOf": [
+ {
+ "format": "base64url",
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Recorded consent verifying ownership of the voice. This\n represents 16-bit signed little-endian wav data, with a 24kHz sampling\n rate.",
+ "title": "Consentaudio"
+ },
+ "voiceConsentSignature": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/VoiceConsentSignature"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Signature of a previously verified consent audio. This should be\n populated with a signature generated by the server for a previous\n request containing the consent_audio field. When provided, the\n signature is verified instead of the consent_audio field to reduce\n latency. Requests will fail if the signature is invalid or expired."
+ }
+ },
+ "title": "ReplicatedVoiceConfig",
+ "type": "object"
+ },
+ "ResponseParseType": {
+ "description": "Defines how to parse sample response.",
"enum": [
- "OUTCOME_UNSPECIFIED",
- "OUTCOME_OK",
- "OUTCOME_FAILED",
- "OUTCOME_DEADLINE_EXCEEDED"
+ "RESPONSE_PARSE_TYPE_UNSPECIFIED",
+ "IDENTITY",
+ "REGEX_EXTRACT"
],
- "title": "Outcome",
+ "title": "ResponseParseType",
"type": "string"
},
- "Part": {
+ "Schema": {
"additionalProperties": false,
- "description": "A datatype containing media content.\n\nExactly one field within a Part should be set, representing the specific type\nof content being conveyed. Using multiple fields within the same `Part`\ninstance is considered invalid.",
+ "description": "Schema is used to define the format of input/output data.\n\nRepresents a select subset of an [OpenAPI 3.0 schema\nobject](https://spec.openapis.org/oas/v3.0.3#schema-object). More fields may\nbe added in the future as needed.",
"properties": {
- "mediaResolution": {
+ "additionalProperties": {
"anyOf": [
+ {},
{
- "$ref": "#/$defs/PartMediaResolution"
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Optional. Can either be a boolean or an object; controls the presence of additional properties.",
+ "title": "Additionalproperties"
+ },
+ "defs": {
+ "anyOf": [
+ {
+ "additionalProperties": {
+ "$ref": "#/$defs/Schema"
+ },
+ "type": "object"
},
{
"type": "null"
}
],
"default": null,
- "description": "Media resolution for the input media.\n "
+ "description": "Optional. A map of definitions for use by `ref` Only allowed at the root of the schema.",
+ "title": "Defs"
},
- "codeExecutionResult": {
+ "ref": {
"anyOf": [
{
- "$ref": "#/$defs/CodeExecutionResult"
+ "type": "string"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. The result of executing the ExecutableCode."
+ "description": "Optional. Allows indirect references between schema nodes. The value should be a valid reference to a child of the root `defs`. For example, the following schema defines a reference to a schema node named \"Pet\": type: object properties: pet: ref: #/defs/Pet defs: Pet: type: object properties: name: type: string The value of the \"pet\" property is a reference to the schema node named \"Pet\". See details in https://json-schema.org/understanding-json-schema/structuring",
+ "title": "Ref"
},
- "executableCode": {
+ "anyOf": {
"anyOf": [
{
- "$ref": "#/$defs/ExecutableCode"
+ "items": {
+ "$ref": "#/$defs/Schema"
+ },
+ "type": "array"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. Code generated by the model that is intended to be executed."
+ "description": "Optional. The instance must be valid against any (one or more) of the subschemas listed in `any_of`.",
+ "title": "Anyof"
},
- "fileData": {
+ "default": {
"anyOf": [
+ {},
{
- "$ref": "#/$defs/FileData"
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Optional. Default value to use if the field is not specified.",
+ "title": "Default"
+ },
+ "description": {
+ "anyOf": [
+ {
+ "type": "string"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. The URI-based data of the part. This can be used to include files from Google Cloud Storage."
+ "description": "Optional. Describes the data. The model uses this field to understand the purpose of the schema and how to use it. It is a best practice to provide a clear and descriptive explanation for the schema and its properties here, rather than in the prompt.",
+ "title": "Description"
},
- "functionCall": {
+ "enum": {
"anyOf": [
{
- "$ref": "#/$defs/FunctionCall"
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. A predicted function call returned from the model. This contains the name of the function to call and the arguments to pass to the function."
+ "description": "Optional. Possible values of the field. This field can be used to restrict a value to a fixed set of values. To mark a field as an enum, set `format` to `enum` and provide the list of possible values in `enum`. For example: 1. To define directions: `{type:STRING, format:enum, enum:[\"EAST\", \"NORTH\", \"SOUTH\", \"WEST\"]}` 2. To define apartment numbers: `{type:INTEGER, format:enum, enum:[\"101\", \"201\", \"301\"]}`",
+ "title": "Enum"
},
- "functionResponse": {
+ "example": {
+ "anyOf": [
+ {},
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Optional. Example of an instance of this schema.",
+ "title": "Example"
+ },
+ "format": {
"anyOf": [
{
- "$ref": "#/$defs/FunctionResponse"
+ "type": "string"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. The result of a function call. This is used to provide the model with the result of a function call that it predicted."
+ "description": "Optional. The format of the data. For `NUMBER` type, format can be `float` or `double`. For `INTEGER` type, format can be `int32` or `int64`. For `STRING` type, format can be `email`, `byte`, `date`, `date-time`, `password`, and other formats to further refine the data type.",
+ "title": "Format"
},
- "inlineData": {
+ "items": {
"anyOf": [
{
- "$ref": "#/$defs/Blob"
+ "$ref": "#/$defs/Schema"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. The inline data content of the part. This can be used to include images, audio, or video in a request."
+ "description": "Optional. If type is `ARRAY`, `items` specifies the schema of elements in the array."
},
- "text": {
+ "maxItems": {
"anyOf": [
{
- "type": "string"
+ "type": "integer"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. The text content of the part. When sent from the VSCode Gemini Code Assist extension, references to @mentioned items will be converted to markdown boldface text. For example `@my-repo` will be converted to and sent as `**my-repo**` by the IDE agent.",
- "title": "Text"
+ "description": "Optional. If type is `ARRAY`, `max_items` specifies the maximum number of items in an array.",
+ "title": "Maxitems"
},
- "thought": {
+ "maxLength": {
"anyOf": [
{
- "type": "boolean"
+ "type": "integer"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. Indicates whether the `part` represents the model's thought process or reasoning.",
- "title": "Thought"
+ "description": "Optional. If type is `STRING`, `max_length` specifies the maximum length of the string.",
+ "title": "Maxlength"
},
- "thoughtSignature": {
+ "maxProperties": {
"anyOf": [
{
- "format": "base64url",
- "type": "string"
+ "type": "integer"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. An opaque signature for the thought so it can be reused in subsequent requests.",
- "title": "Thoughtsignature"
+ "description": "Optional. If type is `OBJECT`, `max_properties` specifies the maximum number of properties that can be provided.",
+ "title": "Maxproperties"
},
- "videoMetadata": {
+ "maximum": {
"anyOf": [
{
- "$ref": "#/$defs/VideoMetadata"
+ "type": "number"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. Video metadata. The metadata should only be specified while the video data is presented in inline_data or file_data."
+ "description": "Optional. If type is `INTEGER` or `NUMBER`, `maximum` specifies the maximum allowed value.",
+ "title": "Maximum"
},
- "toolCall": {
+ "minItems": {
"anyOf": [
{
- "$ref": "#/$defs/ToolCall"
+ "type": "integer"
},
{
"type": "null"
}
],
"default": null,
- "description": "Server-side tool call. This field is populated when the model predicts a tool invocation that should be executed on the server. The client is expected to echo this message back to the API."
+ "description": "Optional. If type is `ARRAY`, `min_items` specifies the minimum number of items in an array.",
+ "title": "Minitems"
},
- "toolResponse": {
+ "minLength": {
"anyOf": [
{
- "$ref": "#/$defs/ToolResponse"
+ "type": "integer"
},
{
"type": "null"
}
],
"default": null,
- "description": "The output from a server-side ToolCall execution. This field is populated by the client with the results of executing the corresponding ToolCall."
+ "description": "Optional. If type is `STRING`, `min_length` specifies the minimum length of the string.",
+ "title": "Minlength"
},
- "partMetadata": {
+ "minProperties": {
"anyOf": [
{
- "additionalProperties": true,
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Optional. If type is `OBJECT`, `min_properties` specifies the minimum number of properties that can be provided.",
+ "title": "Minproperties"
+ },
+ "minimum": {
+ "anyOf": [
+ {
+ "type": "number"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Optional. If type is `INTEGER` or `NUMBER`, `minimum` specifies the minimum allowed value.",
+ "title": "Minimum"
+ },
+ "nullable": {
+ "anyOf": [
+ {
+ "type": "boolean"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Optional. Indicates if the value of this field can be null.",
+ "title": "Nullable"
+ },
+ "pattern": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Optional. If type is `STRING`, `pattern` specifies a regular expression that the string must match.",
+ "title": "Pattern"
+ },
+ "properties": {
+ "anyOf": [
+ {
+ "additionalProperties": {
+ "$ref": "#/$defs/Schema"
+ },
"type": "object"
},
{
@@ -24456,76 +24494,87 @@ Submodules }
],
"default": null,
- "description": "Custom metadata associated with the Part. Agents using genai.Part as content representation may need to keep track of the additional information. For example it can be name of a file/source from which the Part originates or a way to multiplex multiple Part streams. This field is not supported in Vertex AI.",
- "title": "Partmetadata"
- }
- },
- "title": "Part",
- "type": "object"
- },
- "PartMediaResolution": {
- "additionalProperties": false,
- "description": "Media resolution for the input media.",
- "properties": {
- "level": {
+ "description": "Optional. If type is `OBJECT`, `properties` is a map of property names to schema definitions for each property of the object.",
+ "title": "Properties"
+ },
+ "propertyOrdering": {
"anyOf": [
{
- "$ref": "#/$defs/PartMediaResolutionLevel"
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
},
{
"type": "null"
}
],
"default": null,
- "description": "The tokenization quality used for given media.\n "
+ "description": "Optional. Order of properties displayed or used where order matters. This is not a standard field in OpenAPI specification, but can be used to control the order of properties.",
+ "title": "Propertyordering"
},
- "numTokens": {
+ "required": {
"anyOf": [
{
- "type": "integer"
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
},
{
"type": "null"
}
],
"default": null,
- "description": "Specifies the required sequence length for media tokenization.\n ",
- "title": "Numtokens"
+ "description": "Optional. If type is `OBJECT`, `required` lists the names of properties that must be present.",
+ "title": "Required"
+ },
+ "title": {
+ "anyOf": [
+ {
+ "type": "string"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Optional. Title for the schema.",
+ "title": "Title"
+ },
+ "type": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/Type"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Optional. Data type of the schema field."
}
},
- "title": "PartMediaResolution",
+ "title": "Schema",
"type": "object"
},
- "PartMediaResolutionLevel": {
- "description": "The tokenization quality used for given media.",
- "enum": [
- "MEDIA_RESOLUTION_UNSPECIFIED",
- "MEDIA_RESOLUTION_LOW",
- "MEDIA_RESOLUTION_MEDIUM",
- "MEDIA_RESOLUTION_HIGH",
- "MEDIA_RESOLUTION_ULTRA_HIGH"
- ],
- "title": "PartMediaResolutionLevel",
- "type": "string"
- },
- "PartialArg": {
+ "SingleReinforcementTuningRewardConfig": {
"additionalProperties": false,
- "description": "Partial argument value of the function call.\n\nThis data type is not supported in Gemini API.",
+ "description": "Single reinforcement tuning reward config.",
"properties": {
- "boolValue": {
+ "autoraterScorer": {
"anyOf": [
{
- "type": "boolean"
+ "$ref": "#/$defs/ReinforcementTuningAutoraterScorer"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. Represents a boolean value.",
- "title": "Boolvalue"
+ "description": "Scores parsed responses for autorater use cases by using a model to compute the reward."
},
- "jsonPath": {
+ "rewardName": {
"anyOf": [
{
"type": "string"
@@ -24535,71 +24584,66 @@ Submodules }
],
"default": null,
- "description": "Required. A JSON Path (RFC 9535) to the argument being streamed. https://datatracker.ietf.org/doc/html/rfc9535. e.g. \"$.foo.bar[0].data\".",
- "title": "Jsonpath"
+ "description": "A unique reward name used to identify each single reinforcement tuning reward.",
+ "title": "Rewardname"
},
- "nullValue": {
+ "parseResponseConfig": {
"anyOf": [
{
- "const": "NULL_VALUE",
- "type": "string"
+ "$ref": "#/$defs/ReinforcementTuningParseResponseConfig"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. Represents a null value.",
- "title": "Nullvalue"
+ "description": "Defines how to parse sample response."
},
- "numberValue": {
+ "codeExecutionRewardScorer": {
"anyOf": [
{
- "type": "number"
+ "$ref": "#/$defs/ReinforcementTuningCodeExecutionRewardScorer"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. Represents a double value.",
- "title": "Numbervalue"
+ "description": "Scores parsed responses for code execution use cases."
},
- "stringValue": {
+ "stringMatchRewardScorer": {
"anyOf": [
{
- "type": "string"
+ "$ref": "#/$defs/ReinforcementTuningStringMatchRewardScorer"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. Represents a string value.",
- "title": "Stringvalue"
+ "description": "Scores parsed responses for simple string matching use cases against reference answer without writing python code."
},
- "willContinue": {
+ "cloudRunRewardScorer": {
"anyOf": [
{
- "type": "boolean"
+ "$ref": "#/$defs/ReinforcementTuningCloudRunRewardScorer"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. Whether this is not the last part of the same json_path. If true, another PartialArg message for the current json_path is expected to follow.",
- "title": "Willcontinue"
+ "description": "Scores parsed responses by calling a Cloud Run service."
}
},
- "title": "PartialArg",
+ "title": "SingleReinforcementTuningRewardConfig",
"type": "object"
},
- "ToolCall": {
+ "SpeakerVoiceConfig": {
"additionalProperties": false,
- "description": "A predicted server-side `ToolCall` returned from the model.\n\nThis message contains information about a tool that the model wants to invoke.\nThe client is NOT expected to execute this `ToolCall`. Instead, the\nclient should pass this `ToolCall` back to the API in a subsequent turn\nwithin a `Content` message, along with the corresponding `ToolResponse`.",
+ "description": "Configuration for a single speaker in a multi-speaker setup.",
"properties": {
- "id": {
+ "speaker": {
"anyOf": [
{
"type": "string"
@@ -24609,130 +24653,180 @@ Submodules }
],
"default": null,
- "description": "Unique identifier of the tool call. The server returns the tool response with the matching `id`.",
- "title": "Id"
+ "description": "Required. The name of the speaker. This should be the same as the speaker name used in the prompt.",
+ "title": "Speaker"
},
- "toolType": {
+ "voiceConfig": {
"anyOf": [
{
- "$ref": "#/$defs/ToolType"
+ "$ref": "#/$defs/VoiceConfig"
},
{
"type": "null"
}
],
"default": null,
- "description": "The type of tool that was called."
+ "description": "Required. The configuration for the voice of this speaker."
+ }
+ },
+ "title": "SpeakerVoiceConfig",
+ "type": "object"
+ },
+ "SpeechConfig": {
+ "additionalProperties": false,
+ "description": "Config for speech generation and transcription.",
+ "properties": {
+ "voiceConfig": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/VoiceConfig"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "The configuration in case of single-voice output."
},
- "args": {
+ "languageCode": {
"anyOf": [
{
- "additionalProperties": true,
- "type": "object"
+ "type": "string"
},
{
"type": "null"
}
],
"default": null,
- "description": "The tool call arguments. Example: {\"arg1\": \"value1\", \"arg2\": \"value2\"}.",
- "title": "Args"
+ "description": "Optional. The language code (ISO 639-1) for the speech synthesis.",
+ "title": "Languagecode"
+ },
+ "multiSpeakerVoiceConfig": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/MultiSpeakerVoiceConfig"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "The configuration for a multi-speaker text-to-speech request. This field is mutually exclusive with `voice_config`."
}
},
- "title": "ToolCall",
+ "title": "SpeechConfig",
"type": "object"
},
- "ToolResponse": {
+ "ThinkingConfig": {
"additionalProperties": false,
- "description": "The output from a server-side `ToolCall` execution.\n\nThis message contains the results of a tool invocation that was initiated by a\n`ToolCall` from the model. The client should pass this `ToolResponse` back to\nthe API in a subsequent turn within a `Content` message, along with the\ncorresponding `ToolCall`.",
+ "description": "The thinking features configuration.",
"properties": {
- "id": {
+ "includeThoughts": {
"anyOf": [
{
- "type": "string"
+ "type": "boolean"
},
{
"type": "null"
}
],
"default": null,
- "description": "The identifier of the tool call this response is for.",
- "title": "Id"
+ "description": "Indicates whether to include thoughts in the response. If true, thoughts are returned only if the model supports thought and thoughts are available.\n ",
+ "title": "Includethoughts"
},
- "toolType": {
+ "thinkingBudget": {
"anyOf": [
{
- "$ref": "#/$defs/ToolType"
+ "type": "integer"
},
{
"type": "null"
}
],
"default": null,
- "description": "The type of tool that was called, matching the tool_type in the corresponding ToolCall."
+ "description": "Indicates the thinking budget in tokens. 0 is DISABLED. -1 is AUTOMATIC. The default values and allowed ranges are model dependent.\n ",
+ "title": "Thinkingbudget"
},
- "response": {
+ "thinkingLevel": {
"anyOf": [
{
- "additionalProperties": true,
- "type": "object"
+ "$ref": "#/$defs/ThinkingLevel"
},
{
"type": "null"
}
],
"default": null,
- "description": "The tool response.",
- "title": "Response"
+ "description": "Optional. The number of thoughts tokens that the model should generate."
}
},
- "title": "ToolResponse",
+ "title": "ThinkingConfig",
"type": "object"
},
- "ToolType": {
- "description": "The type of tool in the function call.",
+ "ThinkingLevel": {
+ "description": "The number of thoughts tokens that the model should generate.",
"enum": [
- "TOOL_TYPE_UNSPECIFIED",
- "GOOGLE_SEARCH_WEB",
- "GOOGLE_SEARCH_IMAGE",
- "URL_CONTEXT",
- "GOOGLE_MAPS",
- "FILE_SEARCH"
+ "THINKING_LEVEL_UNSPECIFIED",
+ "MINIMAL",
+ "LOW",
+ "MEDIUM",
+ "HIGH"
],
- "title": "ToolType",
+ "title": "ThinkingLevel",
"type": "string"
},
- "VideoMetadata": {
+ "Type": {
+ "description": "Data type of the schema field.",
+ "enum": [
+ "TYPE_UNSPECIFIED",
+ "STRING",
+ "NUMBER",
+ "INTEGER",
+ "BOOLEAN",
+ "ARRAY",
+ "OBJECT",
+ "NULL"
+ ],
+ "title": "Type",
+ "type": "string"
+ },
+ "VoiceConfig": {
"additionalProperties": false,
- "description": "Provides metadata for a video, including the start and end offsets for clipping and the frame rate.",
+ "description": "The configuration for the voice to use.",
"properties": {
- "endOffset": {
+ "replicatedVoiceConfig": {
"anyOf": [
{
- "type": "string"
+ "$ref": "#/$defs/ReplicatedVoiceConfig"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. The end offset of the video.",
- "title": "Endoffset"
+ "description": "The configuration for a replicated voice, which is a clone of a\n user's voice that can be used for speech synthesis. If this is unset, a\n default voice is used."
},
- "fps": {
+ "prebuiltVoiceConfig": {
"anyOf": [
{
- "type": "number"
+ "$ref": "#/$defs/PrebuiltVoiceConfig"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. The frame rate of the video sent to the model. If not specified, the default value is 1.0. The valid range is (0.0, 24.0].",
- "title": "Fps"
- },
- "startOffset": {
+ "description": "The configuration for a prebuilt voice."
+ }
+ },
+ "title": "VoiceConfig",
+ "type": "object"
+ },
+ "VoiceConsentSignature": {
+ "additionalProperties": false,
+ "description": "The signature of the voice consent check.",
+ "properties": {
+ "signature": {
"anyOf": [
{
"type": "string"
@@ -24742,11 +24836,11 @@ Submodules }
],
"default": null,
- "description": "Optional. The start offset of the video.",
- "title": "Startoffset"
+ "description": "The signature string.\n ",
+ "title": "Signature"
}
},
- "title": "VideoMetadata",
+ "title": "VoiceConsentSignature",
"type": "object"
}
},
@@ -24757,32 +24851,16 @@ Submodules
- Fields:
-
- Validators:
--
-field parts:
Optional[list[Part]] = None¶
-List of parts that constitute a single message. Each part may have
-a different IANA MIME type.
-
-- Validated by:
-
-_check_field_type_mismatches
-
-
-
-
-
-
--
-field role:
Optional[str] = None¶
-Optional. The producer of the content. Must be either ‘user’ or ‘model’. If not set, the service will default to ‘user’.
-
+-
+field weighted_reward_configs:
Optional[list[CompositeReinforcementTuningRewardConfigWeightedRewardConfig]] = None (alias 'weightedRewardConfigs')¶
+
- Validated by:
_check_field_type_mismatches
@@ -24794,75 +24872,77 @@ Submodules
--
-class genai.types.ContentDict¶
+-
+class genai.types.CompositeReinforcementTuningRewardConfigDict¶
Bases: TypedDict
-Contains the multi-part content of a message.
-
--
-parts:
Optional[list[PartDict]]¶
-List of parts that constitute a single message. Each part may have
-a different IANA MIME type.
-
-
+Composite reinforcement tuning reward config.
--
-role:
Optional[str]¶
-Optional. The producer of the content. Must be either ‘user’ or ‘model’. If not set, the service will default to ‘user’.
-
+-
+weighted_reward_configs:
Optional[list[CompositeReinforcementTuningRewardConfigWeightedRewardConfigDict]]¶
+
--
-pydantic model genai.types.ContentEmbedding¶
+-
+pydantic model genai.types.CompositeReinforcementTuningRewardConfigWeightedRewardConfig¶
Bases: BaseModel
-The embedding generated from an input content.
+Composite reinforcement tuning reward config weighted reward config.
Create a new model by parsing and validating input data from keyword arguments.
Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
validated to form a valid model.
self is explicitly positional-only to allow self as a field name.
Show JSON schema
{
- "title": "ContentEmbedding",
- "description": "The embedding generated from an input content.",
+ "title": "CompositeReinforcementTuningRewardConfigWeightedRewardConfig",
+ "description": "Composite reinforcement tuning reward config weighted reward config.",
"type": "object",
"properties": {
- "values": {
+ "rewardConfig": {
"anyOf": [
{
- "items": {
- "type": "number"
- },
- "type": "array"
+ "$ref": "#/$defs/SingleReinforcementTuningRewardConfig"
},
{
"type": "null"
}
],
"default": null,
- "description": "A list of floats representing an embedding.\n ",
- "title": "Values"
+ "description": ""
},
- "statistics": {
+ "weight": {
"anyOf": [
{
- "$ref": "#/$defs/ContentEmbeddingStatistics"
+ "type": "number"
},
{
"type": "null"
}
],
"default": null,
- "description": "Gemini Enterprise Agent Platform only. Statistics of the input text associated with this\n embedding.\n "
+ "description": "How much this single reward contributes to the total overall reward.",
+ "title": "Weight"
}
},
"$defs": {
- "ContentEmbeddingStatistics": {
+ "AutoraterConfig": {
"additionalProperties": false,
- "description": "Statistics of the input text associated with the result of content embedding.",
+ "description": "Autorater config used for evaluation.",
"properties": {
- "truncated": {
+ "samplingCount": {
+ "anyOf": [
+ {
+ "type": "integer"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Number of samples for each instance in the dataset.\n If not specified, the default is 4. Minimum value is 1, maximum value\n is 32.",
+ "title": "Samplingcount"
+ },
+ "flipEnabled": {
"anyOf": [
{
"type": "boolean"
@@ -24872,433 +24952,90 @@ Submodules }
],
"default": null,
- "description": "Gemini Enterprise Agent Platform only. If the input text was truncated due to having\n a length longer than the allowed maximum input.\n ",
- "title": "Truncated"
+ "description": "Optional. Default is true. Whether to flip the candidate and baseline\n responses. This is only applicable to the pairwise metric. If enabled, also\n provide PairwiseMetricSpec.candidate_response_field_name and\n PairwiseMetricSpec.baseline_response_field_name. When rendering\n PairwiseMetricSpec.metric_prompt_template, the candidate and baseline\n fields will be flipped for half of the samples to reduce bias.",
+ "title": "Flipenabled"
},
- "tokenCount": {
+ "autoraterModel": {
"anyOf": [
{
- "type": "number"
+ "type": "string"
},
{
"type": "null"
}
],
"default": null,
- "description": "Gemini Enterprise Agent Platform only. Number of tokens of the input text.\n ",
- "title": "Tokencount"
+ "description": "The fully qualified name of the publisher model or tuned autorater\n endpoint to use.\n\n Publisher model format:\n `projects/{project}/locations/{location}/publishers/{publisher}/models/{model}`\n\n Tuned model endpoint format:\n `projects/{project}/locations/{location}/endpoints/{endpoint}`",
+ "title": "Autoratermodel"
+ },
+ "generationConfig": {
+ "anyOf": [
+ {
+ "$ref": "#/$defs/GenerationConfig"
+ },
+ {
+ "type": "null"
+ }
+ ],
+ "default": null,
+ "description": "Configuration options for model generation and outputs."
}
},
- "title": "ContentEmbeddingStatistics",
+ "title": "AutoraterConfig",
"type": "object"
- }
- },
- "additionalProperties": false
-}
-
-
-
-- Fields:
--
-
-- Validators:
-
-
-
--
-field statistics:
Optional[ContentEmbeddingStatistics] = None¶
-Gemini Enterprise Agent Platform only. Statistics of the input text associated with this
-embedding.
-
-- Validated by:
-
-_check_field_type_mismatches
-
-
-
-
-
-
--
-field values:
Optional[list[float]] = None¶
-A list of floats representing an embedding.
-
-- Validated by:
-
-_check_field_type_mismatches
-
-
-
-
-
-
-
-
--
-class genai.types.ContentEmbeddingDict¶
-Bases: TypedDict
-The embedding generated from an input content.
-
--
-statistics:
Optional[ContentEmbeddingStatisticsDict]¶
-Gemini Enterprise Agent Platform only. Statistics of the input text associated with this
-embedding.
-
-
-
-
-
--
-pydantic model genai.types.ContentEmbeddingStatistics¶
-Bases: BaseModel
-Statistics of the input text associated with the result of content embedding.
-Create a new model by parsing and validating input data from keyword arguments.
-Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
-validated to form a valid model.
-self is explicitly positional-only to allow self as a field name.
-
-Show JSON schema
{
- "title": "ContentEmbeddingStatistics",
- "description": "Statistics of the input text associated with the result of content embedding.",
- "type": "object",
- "properties": {
- "truncated": {
- "anyOf": [
- {
- "type": "boolean"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "Gemini Enterprise Agent Platform only. If the input text was truncated due to having\n a length longer than the allowed maximum input.\n ",
- "title": "Truncated"
- },
- "tokenCount": {
- "anyOf": [
- {
- "type": "number"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "Gemini Enterprise Agent Platform only. Number of tokens of the input text.\n ",
- "title": "Tokencount"
- }
- },
- "additionalProperties": false
-}
-
-
-
-- Fields:
--
-
-- Validators:
-
-
-
--
-field token_count:
Optional[float] = None (alias 'tokenCount')¶
-Gemini Enterprise Agent Platform only. Number of tokens of the input text.
-
-- Validated by:
-
-_check_field_type_mismatches
-
-
-
-
-
-
--
-field truncated:
Optional[bool] = None¶
-Gemini Enterprise Agent Platform only. If the input text was truncated due to having
-a length longer than the allowed maximum input.
-
-- Validated by:
-
-_check_field_type_mismatches
-
-
-
-
-
-
-
-
--
-class genai.types.ContentEmbeddingStatisticsDict¶
-Bases: TypedDict
-Statistics of the input text associated with the result of content embedding.
-
--
-token_count:
Optional[float]¶
-Gemini Enterprise Agent Platform only. Number of tokens of the input text.
-
-
-
--
-truncated:
Optional[bool]¶
-Gemini Enterprise Agent Platform only. If the input text was truncated due to having
-a length longer than the allowed maximum input.
-
-
-
-
-
--
-pydantic model genai.types.ContentReferenceImage¶
-Bases: BaseModel
-A content reference image.
-A content reference image represents a subject to reference (ex. person,
-product, animal) provided by the user. It can optionally be provided in
-addition to a style reference image (ex. background, style reference).
-Create a new model by parsing and validating input data from keyword arguments.
-Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
-validated to form a valid model.
-self is explicitly positional-only to allow self as a field name.
-
-Show JSON schema
{
- "title": "ContentReferenceImage",
- "description": "A content reference image.\n\nA content reference image represents a subject to reference (ex. person,\nproduct, animal) provided by the user. It can optionally be provided in\naddition to a style reference image (ex. background, style reference).",
- "type": "object",
- "properties": {
- "referenceImage": {
- "anyOf": [
- {
- "$ref": "#/$defs/Image"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "The reference image for the editing operation."
},
- "referenceId": {
- "anyOf": [
- {
- "type": "integer"
- },
- {
- "type": "null"
- }
+ "FeatureSelectionPreference": {
+ "description": "Options for feature selection preference.",
+ "enum": [
+ "FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",
+ "PRIORITIZE_QUALITY",
+ "BALANCED",
+ "PRIORITIZE_COST"
],
- "default": null,
- "description": "The id of the reference image.",
- "title": "Referenceid"
+ "title": "FeatureSelectionPreference",
+ "type": "string"
},
- "referenceType": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "The type of the reference image. Only set by the SDK.",
- "title": "Referencetype"
- }
- },
- "$defs": {
- "Image": {
+ "GenerationConfig": {
"additionalProperties": false,
- "description": "An image.",
+ "description": "Generation config.",
"properties": {
- "gcsUri": {
+ "modelSelectionConfig": {
"anyOf": [
{
- "type": "string"
+ "$ref": "#/$defs/ModelSelectionConfig"
},
{
"type": "null"
}
],
"default": null,
- "description": "The Cloud Storage URI of the image. ``Image`` can contain a value\n for this field or the ``image_bytes`` field but not both.",
- "title": "Gcsuri"
+ "description": "Optional. Config for model selection."
},
- "imageBytes": {
+ "responseJsonSchema": {
"anyOf": [
- {
- "format": "base64url",
- "type": "string"
- },
+ {},
{
"type": "null"
}
],
"default": null,
- "description": "The image bytes data. ``Image`` can contain a value for this field\n or the ``gcs_uri`` field but not both.",
- "title": "Imagebytes"
+ "description": "Output schema of the generated response. This is an alternative to\n `response_schema` that accepts [JSON Schema](https://json-schema.org/).\n ",
+ "title": "Responsejsonschema"
},
- "mimeType": {
+ "audioTimestamp": {
"anyOf": [
{
- "type": "string"
+ "type": "boolean"
},
{
"type": "null"
}
],
"default": null,
- "description": "The MIME type of the image.",
- "title": "Mimetype"
- }
- },
- "title": "Image",
- "type": "object"
- }
- },
- "additionalProperties": false
-}
-
-
-
-- Fields:
--
-
-- Validators:
-
-_validate_mask_image_config » all fields
-
-
-
-
--
-field reference_id:
Optional[int] = None (alias 'referenceId')¶
-The id of the reference image.
-
-- Validated by:
-
-_check_field_type_mismatches
-_validate_mask_image_config
-
-
-
-
-
-
--
-field reference_image:
Optional[Image] = None (alias 'referenceImage')¶
-The reference image for the editing operation.
-
-- Validated by:
-
-_check_field_type_mismatches
-_validate_mask_image_config
-
-
-
-
-
-
--
-field reference_type:
Optional[str] = None (alias 'referenceType')¶
-The type of the reference image. Only set by the SDK.
-
-- Validated by:
-
-_check_field_type_mismatches
-_validate_mask_image_config
-
-
-
-
-
-
-
-
--
-class genai.types.ContentReferenceImageDict¶
-Bases: TypedDict
-A content reference image.
-A content reference image represents a subject to reference (ex. person,
-product, animal) provided by the user. It can optionally be provided in
-addition to a style reference image (ex. background, style reference).
-
--
-reference_id:
Optional[int]¶
-The id of the reference image.
-
-
-
-
-
--
-reference_type:
Optional[str]¶
-The type of the reference image. Only set by the SDK.
-
-
-
-
-
--
-pydantic model genai.types.ContextWindowCompressionConfig¶
-Bases: BaseModel
-Enables context window compression – mechanism managing model context window so it does not exceed given length.
-Create a new model by parsing and validating input data from keyword arguments.
-Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
-validated to form a valid model.
-self is explicitly positional-only to allow self as a field name.
-
-Show JSON schema
{
- "title": "ContextWindowCompressionConfig",
- "description": "Enables context window compression -- mechanism managing model context window so it does not exceed given length.",
- "type": "object",
- "properties": {
- "triggerTokens": {
- "anyOf": [
- {
- "type": "integer"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "Number of tokens (before running turn) that triggers context window compression mechanism.",
- "title": "Triggertokens"
- },
- "slidingWindow": {
- "anyOf": [
- {
- "$ref": "#/$defs/SlidingWindow"
+ "description": "Optional. If enabled, audio timestamps will be included in the request to the model. This can be useful for synchronizing audio with other modalities in the response. This field is not supported in Gemini API.",
+ "title": "Audiotimestamp"
},
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "Sliding window compression mechanism."
- }
- },
- "$defs": {
- "SlidingWindow": {
- "additionalProperties": false,
- "description": "Context window will be truncated by keeping only suffix of it.\n\nContext window will always be cut at start of USER role turn. System\ninstructions and `BidiGenerateContentSetup.prefix_turns` will not be\nsubject to the sliding window mechanism, they will always stay at the\nbeginning of context window.",
- "properties": {
- "targetTokens": {
+ "candidateCount": {
"anyOf": [
{
"type": "integer"
@@ -25308,652 +25045,100 @@ Submodules }
],
"default": null,
- "description": "Session reduction target -- how many tokens we should keep. Window shortening operation has some latency costs, so we should avoid running it on every turn. Should be < trigger_tokens. If not set, trigger_tokens/2 is assumed.",
- "title": "Targettokens"
- }
- },
- "title": "SlidingWindow",
- "type": "object"
- }
- },
- "additionalProperties": false
-}
-
-
-
-- Fields:
--
-
-- Validators:
-
-
-
--
-field sliding_window:
Optional[SlidingWindow] = None (alias 'slidingWindow')¶
-Sliding window compression mechanism.
-
-- Validated by:
-
-_check_field_type_mismatches
-
-
-
-
-
-
--
-field trigger_tokens:
Optional[int] = None (alias 'triggerTokens')¶
-Number of tokens (before running turn) that triggers context window compression mechanism.
-
-- Validated by:
-
-_check_field_type_mismatches
-
-
-
-
-
-
-
-
--
-class genai.types.ContextWindowCompressionConfigDict¶
-Bases: TypedDict
-Enables context window compression – mechanism managing model context window so it does not exceed given length.
-
--
-sliding_window:
Optional[SlidingWindowDict]¶
-Sliding window compression mechanism.
-
-
-
--
-trigger_tokens:
Optional[int]¶
-Number of tokens (before running turn) that triggers context window compression mechanism.
-
-
-
-
-
--
-pydantic model genai.types.ControlReferenceConfig¶
-Bases: BaseModel
-Configuration for a Control reference image.
-Create a new model by parsing and validating input data from keyword arguments.
-Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
-validated to form a valid model.
-self is explicitly positional-only to allow self as a field name.
-
-Show JSON schema
{
- "title": "ControlReferenceConfig",
- "description": "Configuration for a Control reference image.",
- "type": "object",
- "properties": {
- "controlType": {
- "anyOf": [
- {
- "$ref": "#/$defs/ControlReferenceType"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "The type of control reference image to use."
- },
- "enableControlImageComputation": {
- "anyOf": [
- {
- "type": "boolean"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "Defaults to False. When set to True, the control image will be\n computed by the model based on the control type. When set to False,\n the control image must be provided by the user.",
- "title": "Enablecontrolimagecomputation"
- }
- },
- "$defs": {
- "ControlReferenceType": {
- "description": "Enum representing the control type of a control reference image.",
- "enum": [
- "CONTROL_TYPE_DEFAULT",
- "CONTROL_TYPE_CANNY",
- "CONTROL_TYPE_SCRIBBLE",
- "CONTROL_TYPE_FACE_MESH"
- ],
- "title": "ControlReferenceType",
- "type": "string"
- }
- },
- "additionalProperties": false
-}
-
-
-
-- Fields:
--
-
-- Validators:
-
-
-
--
-field control_type:
Optional[ControlReferenceType] = None (alias 'controlType')¶
-The type of control reference image to use.
-
-- Validated by:
-
-_check_field_type_mismatches
-
-
-
-
-
-
--
-field enable_control_image_computation:
Optional[bool] = None (alias 'enableControlImageComputation')¶
-Defaults to False. When set to True, the control image will be
-computed by the model based on the control type. When set to False,
-the control image must be provided by the user.
-
-- Validated by:
-
-_check_field_type_mismatches
-
-
-
-
-
-
-
-
--
-class genai.types.ControlReferenceConfigDict¶
-Bases: TypedDict
-Configuration for a Control reference image.
-
--
-control_type:
Optional[ControlReferenceType]¶
-The type of control reference image to use.
-
-
-
--
-enable_control_image_computation:
Optional[bool]¶
-Defaults to False. When set to True, the control image will be
-computed by the model based on the control type. When set to False,
-the control image must be provided by the user.
-
-
-
-
-
--
-pydantic model genai.types.ControlReferenceImage¶
-Bases: BaseModel
-A control reference image.
-The image of the control reference image is either a control image provided
-by the user, or a regular image which the backend will use to generate a
-control image of. In the case of the latter, the
-enable_control_image_computation field in the config should be set to True.
-A control image is an image that represents a sketch image of areas for the
-model to fill in based on the prompt.
-Create a new model by parsing and validating input data from keyword arguments.
-Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
-validated to form a valid model.
-self is explicitly positional-only to allow self as a field name.
-
-Show JSON schema
{
- "title": "ControlReferenceImage",
- "description": "A control reference image.\n\nThe image of the control reference image is either a control image provided\nby the user, or a regular image which the backend will use to generate a\ncontrol image of. In the case of the latter, the\nenable_control_image_computation field in the config should be set to True.\n\nA control image is an image that represents a sketch image of areas for the\nmodel to fill in based on the prompt.",
- "type": "object",
- "properties": {
- "referenceImage": {
- "anyOf": [
- {
- "$ref": "#/$defs/Image"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "The reference image for the editing operation."
- },
- "referenceId": {
- "anyOf": [
- {
- "type": "integer"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "The id of the reference image.",
- "title": "Referenceid"
- },
- "referenceType": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "The type of the reference image. Only set by the SDK.",
- "title": "Referencetype"
- },
- "config": {
- "anyOf": [
- {
- "$ref": "#/$defs/ControlReferenceConfig"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "Configuration for the control reference image."
- },
- "controlImageConfig": {
- "anyOf": [
- {
- "$ref": "#/$defs/ControlReferenceConfig"
+ "description": "Optional. The number of candidate responses to generate. A higher `candidate_count` can provide more options to choose from, but it also consumes more resources. This can be useful for generating a variety of responses and selecting the best one.",
+ "title": "Candidatecount"
},
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": ""
- }
- },
- "$defs": {
- "ControlReferenceConfig": {
- "additionalProperties": false,
- "description": "Configuration for a Control reference image.",
- "properties": {
- "controlType": {
+ "enableAffectiveDialog": {
"anyOf": [
{
- "$ref": "#/$defs/ControlReferenceType"
+ "type": "boolean"
},
{
"type": "null"
}
],
"default": null,
- "description": "The type of control reference image to use."
+ "description": "Optional. If enabled, the model will detect emotions and adapt its responses accordingly. For example, if the model detects that the user is frustrated, it may provide a more empathetic response. This field is not supported in Gemini API.",
+ "title": "Enableaffectivedialog"
},
- "enableControlImageComputation": {
+ "frequencyPenalty": {
"anyOf": [
{
- "type": "boolean"
+ "type": "number"
},
{
"type": "null"
}
],
"default": null,
- "description": "Defaults to False. When set to True, the control image will be\n computed by the model based on the control type. When set to False,\n the control image must be provided by the user.",
- "title": "Enablecontrolimagecomputation"
- }
- },
- "title": "ControlReferenceConfig",
- "type": "object"
- },
- "ControlReferenceType": {
- "description": "Enum representing the control type of a control reference image.",
- "enum": [
- "CONTROL_TYPE_DEFAULT",
- "CONTROL_TYPE_CANNY",
- "CONTROL_TYPE_SCRIBBLE",
- "CONTROL_TYPE_FACE_MESH"
- ],
- "title": "ControlReferenceType",
- "type": "string"
- },
- "Image": {
- "additionalProperties": false,
- "description": "An image.",
- "properties": {
- "gcsUri": {
+ "description": "Optional. Penalizes tokens based on their frequency in the generated text. A positive value helps to reduce the repetition of words and phrases. Valid values can range from [-2.0, 2.0].",
+ "title": "Frequencypenalty"
+ },
+ "logprobs": {
"anyOf": [
{
- "type": "string"
+ "type": "integer"
},
{
"type": "null"
}
],
"default": null,
- "description": "The Cloud Storage URI of the image. ``Image`` can contain a value\n for this field or the ``image_bytes`` field but not both.",
- "title": "Gcsuri"
+ "description": "Optional. The number of top log probabilities to return for each token. This can be used to see which other tokens were considered likely candidates for a given position. A higher value will return more options, but it will also increase the size of the response.",
+ "title": "Logprobs"
},
- "imageBytes": {
+ "maxOutputTokens": {
"anyOf": [
{
- "format": "base64url",
- "type": "string"
+ "type": "integer"
},
{
"type": "null"
}
],
"default": null,
- "description": "The image bytes data. ``Image`` can contain a value for this field\n or the ``gcs_uri`` field but not both.",
- "title": "Imagebytes"
+ "description": "Optional. The maximum number of tokens to generate in the response. A token is approximately four characters. The default value varies by model. This parameter can be used to control the length of the generated text and prevent overly long responses.",
+ "title": "Maxoutputtokens"
},
- "mimeType": {
+ "mediaResolution": {
"anyOf": [
{
- "type": "string"
+ "$ref": "#/$defs/MediaResolution"
},
{
"type": "null"
}
],
"default": null,
- "description": "The MIME type of the image.",
- "title": "Mimetype"
- }
- },
- "title": "Image",
- "type": "object"
- }
- },
- "additionalProperties": false
-}
-
-
-
-- Fields:
--
-
-- Validators:
-
-_validate_mask_image_config » all fields
-
-
-
-
--
-field config:
Optional[ControlReferenceConfig] = None¶
-Re-map config to control_reference_config to send to API.
-Configuration for the control reference image.
-
-- Validated by:
-
-_check_field_type_mismatches
-_validate_mask_image_config
-
-
-
-
-
-
--
-field control_image_config:
Optional[ControlReferenceConfig] = None (alias 'controlImageConfig')¶
-
-- Validated by:
-
-_check_field_type_mismatches
-_validate_mask_image_config
-
-
-
-
-
-
--
-field reference_id:
Optional[int] = None (alias 'referenceId')¶
-The id of the reference image.
-
-- Validated by:
-
-_check_field_type_mismatches
-_validate_mask_image_config
-
-
-
-
-
-
--
-field reference_image:
Optional[Image] = None (alias 'referenceImage')¶
-The reference image for the editing operation.
-
-- Validated by:
-
-_check_field_type_mismatches
-_validate_mask_image_config
-
-
-
-
-
-
--
-field reference_type:
Optional[str] = None (alias 'referenceType')¶
-The type of the reference image. Only set by the SDK.
-
-- Validated by:
-
-_check_field_type_mismatches
-_validate_mask_image_config
-
-
-
-
-
-
-
-
--
-class genai.types.ControlReferenceImageDict¶
-Bases: TypedDict
-A control reference image.
-The image of the control reference image is either a control image provided
-by the user, or a regular image which the backend will use to generate a
-control image of. In the case of the latter, the
-enable_control_image_computation field in the config should be set to True.
-A control image is an image that represents a sketch image of areas for the
-model to fill in based on the prompt.
-
--
-config:
Optional[ControlReferenceConfigDict]¶
-Configuration for the control reference image.
-
-
-
--
-reference_id:
Optional[int]¶
-The id of the reference image.
-
-
-
-
-
--
-reference_type:
Optional[str]¶
-The type of the reference image. Only set by the SDK.
-
-
-
-
-
--
-class genai.types.ControlReferenceType(*values)¶
-Bases: CaseInSensitiveEnum
-Enum representing the control type of a control reference image.
-
--
-CONTROL_TYPE_CANNY = 'CONTROL_TYPE_CANNY'¶
-
-
-
--
-CONTROL_TYPE_DEFAULT = 'CONTROL_TYPE_DEFAULT'¶
-
-
-
--
-CONTROL_TYPE_FACE_MESH = 'CONTROL_TYPE_FACE_MESH'¶
-
-
-
--
-CONTROL_TYPE_SCRIBBLE = 'CONTROL_TYPE_SCRIBBLE'¶
-
-
-
-
-
--
-pydantic model genai.types.CountTokensConfig¶
-Bases: BaseModel
-Config for the count_tokens method.
-Create a new model by parsing and validating input data from keyword arguments.
-Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be
-validated to form a valid model.
-self is explicitly positional-only to allow self as a field name.
-
-Show JSON schema
{
- "title": "CountTokensConfig",
- "type": "object",
- "properties": {
- "httpOptions": {
- "default": null,
- "title": "Httpoptions"
- },
- "systemInstruction": {
- "anyOf": [
- {
- "$ref": "#/$defs/Content"
- },
- {
- "type": "string"
- },
- {
- "$ref": "#/$defs/File"
- },
- {
- "$ref": "#/$defs/Part"
- },
- {
- "items": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "$ref": "#/$defs/File"
- },
- {
- "$ref": "#/$defs/Part"
- }
- ]
- },
- "type": "array"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "Instructions for the model to steer it toward better performance.\n ",
- "title": "Systeminstruction"
- },
- "tools": {
- "anyOf": [
- {
- "items": {
- "$ref": "#/$defs/Tool"
- },
- "type": "array"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "Code that enables the system to interact with external systems to\n perform an action outside of the knowledge and scope of the model.\n ",
- "title": "Tools"
- },
- "generationConfig": {
- "anyOf": [
- {
- "$ref": "#/$defs/GenerationConfig"
+ "description": "Optional. The token resolution at which input media content is sampled. This is used to control the trade-off between the quality of the response and the number of tokens used to represent the media. A higher resolution allows the model to perceive more detail, which can lead to a more nuanced response, but it will also use more tokens. This does not affect the image dimensions sent to the model."
},
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "Configuration that the model uses to generate the response. Not\n supported by the Gemini Developer API.\n "
- }
- },
- "$defs": {
- "ApiAuth": {
- "additionalProperties": false,
- "description": "The generic reusable api auth config.\n\nDeprecated. Please use AuthConfig (google/cloud/aiplatform/master/auth.proto)\ninstead. This data type is not supported in Gemini API.",
- "properties": {
- "apiKeyConfig": {
+ "presencePenalty": {
"anyOf": [
{
- "$ref": "#/$defs/ApiAuthApiKeyConfig"
+ "type": "number"
},
{
"type": "null"
}
],
"default": null,
- "description": "The API secret."
- }
- },
- "title": "ApiAuth",
- "type": "object"
- },
- "ApiAuthApiKeyConfig": {
- "additionalProperties": false,
- "description": "The API secret. This data type is not supported in Gemini API.",
- "properties": {
- "apiKeySecretVersion": {
+ "description": "Optional. Penalizes tokens that have already appeared in the generated text. A positive value encourages the model to generate more diverse and less repetitive text. Valid values can range from [-2.0, 2.0].",
+ "title": "Presencepenalty"
+ },
+ "responseLogprobs": {
"anyOf": [
{
- "type": "string"
+ "type": "boolean"
},
{
"type": "null"
}
],
"default": null,
- "description": "Required. The SecretManager secret version resource name storing API key. e.g. projects/{project}/secrets/{secret}/versions/{version}",
- "title": "Apikeysecretversion"
+ "description": "Optional. If set to true, the log probabilities of the output tokens are returned. Log probabilities are the logarithm of the probability of a token appearing in the output. A higher log probability means the token is more likely to be generated. This can be useful for analyzing the model's confidence in its own output and for debugging.",
+ "title": "Responselogprobs"
},
- "apiKeyString": {
+ "responseMimeType": {
"anyOf": [
{
"type": "string"
@@ -25963,237 +25148,203 @@ Submodules }
],
"default": null,
- "description": "The API key string. Either this or `api_key_secret_version` must be set.",
- "title": "Apikeystring"
- }
- },
- "title": "ApiAuthApiKeyConfig",
- "type": "object"
- },
- "ApiKeyConfig": {
- "additionalProperties": false,
- "description": "Config for authentication with API key.\n\nThis data type is not supported in Gemini API.",
- "properties": {
- "apiKeySecret": {
+ "description": "Optional. The IANA standard MIME type of the response. The model will generate output that conforms to this MIME type. Supported values include 'text/plain' (default) and 'application/json'. The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined.",
+ "title": "Responsemimetype"
+ },
+ "responseModalities": {
"anyOf": [
{
- "type": "string"
+ "items": {
+ "$ref": "#/$defs/Modality"
+ },
+ "type": "array"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. The name of the SecretManager secret version resource storing the API key. Format: `projects/{project}/secrets/{secrete}/versions/{version}` - If both `api_key_secret` and `api_key_string` are specified, this field takes precedence over `api_key_string`. - If specified, the `secretmanager.versions.access` permission should be granted to Vertex AI Extension Service Agent (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the specified resource.",
- "title": "Apikeysecret"
+ "description": "Optional. The modalities of the response. The model will generate a response that includes all the specified modalities. For example, if this is set to `[TEXT, IMAGE]`, the response will include both text and an image.",
+ "title": "Responsemodalities"
},
- "apiKeyString": {
+ "responseSchema": {
"anyOf": [
{
- "type": "string"
+ "$ref": "#/$defs/Schema"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. The API key to be used in the request directly.",
- "title": "Apikeystring"
+ "description": "Optional. Lets you to specify a schema for the model's response, ensuring that the output conforms to a particular structure. This is useful for generating structured data such as JSON. The schema is a subset of the [OpenAPI 3.0 schema object](https://spec.openapis.org/oas/v3.0.3#schema) object. When this field is set, you must also set the `response_mime_type` to `application/json`."
},
- "httpElementLocation": {
+ "routingConfig": {
"anyOf": [
{
- "$ref": "#/$defs/HttpElementLocation"
+ "$ref": "#/$defs/GenerationConfigRoutingConfig"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. The location of the API key."
+ "description": "Optional. Routing configuration. This field is not supported in Gemini API."
},
- "name": {
+ "seed": {
"anyOf": [
{
- "type": "string"
+ "type": "integer"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. The parameter name of the API key. E.g. If the API request is \"https://example.com/act?api_key=\", \"api_key\" would be the parameter name.",
- "title": "Name"
- }
- },
- "title": "ApiKeyConfig",
- "type": "object"
- },
- "ApiSpec": {
- "description": "The API spec that the external API implements.\n\nThis enum is not supported in Gemini API.",
- "enum": [
- "API_SPEC_UNSPECIFIED",
- "SIMPLE_SEARCH",
- "ELASTIC_SEARCH"
- ],
- "title": "ApiSpec",
- "type": "string"
- },
- "AuthConfig": {
- "additionalProperties": false,
- "description": "The authentication config to access the API.",
- "properties": {
- "apiKey": {
+ "description": "Optional. A seed for the random number generator. By setting a seed, you can make the model's output mostly deterministic. For a given prompt and parameters (like temperature, top_p, etc.), the model will produce the same response every time. However, it's not a guaranteed absolute deterministic behavior. This is different from parameters like `temperature`, which control the *level* of randomness. `seed` ensures that the \"random\" choices the model makes are the same on every run, making it essential for testing and ensuring reproducible results.",
+ "title": "Seed"
+ },
+ "speechConfig": {
"anyOf": [
{
- "type": "string"
+ "$ref": "#/$defs/SpeechConfig"
},
{
"type": "null"
}
],
"default": null,
- "description": "The authentication config to access the API. Only API key is supported. This field is not supported in Gemini API.",
- "title": "Apikey"
+ "description": "Optional. The speech generation config."
},
- "apiKeyConfig": {
+ "stopSequences": {
"anyOf": [
{
- "$ref": "#/$defs/ApiKeyConfig"
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
},
{
"type": "null"
}
],
"default": null,
- "description": "Config for API key auth."
+ "description": "Optional. A list of character sequences that will stop the model from generating further tokens. If a stop sequence is generated, the output will end at that point. This is useful for controlling the length and structure of the output. For example, you can use [\"\n\", \"###\"] to stop generation at a new line or a specific marker.",
+ "title": "Stopsequences"
},
- "authType": {
+ "temperature": {
"anyOf": [
{
- "$ref": "#/$defs/AuthType"
+ "type": "number"
},
{
"type": "null"
}
],
"default": null,
- "description": "Type of auth scheme."
+ "description": "Optional. Controls the randomness of the output. A higher temperature results in more creative and diverse responses, while a lower temperature makes the output more predictable and focused. The valid range is (0.0, 2.0].",
+ "title": "Temperature"
},
- "googleServiceAccountConfig": {
+ "thinkingConfig": {
"anyOf": [
{
- "$ref": "#/$defs/AuthConfigGoogleServiceAccountConfig"
+ "$ref": "#/$defs/ThinkingConfig"
},
{
"type": "null"
}
],
"default": null,
- "description": "Config for Google Service Account auth."
+ "description": "Optional. Configuration for thinking features. An error will be returned if this field is set for models that don't support thinking."
},
- "httpBasicAuthConfig": {
+ "topK": {
"anyOf": [
{
- "$ref": "#/$defs/AuthConfigHttpBasicAuthConfig"
+ "type": "number"
},
{
"type": "null"
}
],
"default": null,
- "description": "Config for HTTP Basic auth."
+ "description": "Optional. Specifies the top-k sampling threshold. The model considers only the top k most probable tokens for the next token. This can be useful for generating more coherent and less random text. For example, a `top_k` of 40 means the model will choose the next word from the 40 most likely words.",
+ "title": "Topk"
},
- "oauthConfig": {
+ "topP": {
"anyOf": [
{
- "$ref": "#/$defs/AuthConfigOauthConfig"
+ "type": "number"
},
{
"type": "null"
}
],
"default": null,
- "description": "Config for user oauth."
+ "description": "Optional. Specifies the nucleus sampling threshold. The model considers only the smallest set of tokens whose cumulative probability is at least `top_p`. This helps generate more diverse and less repetitive responses. For example, a `top_p` of 0.9 means the model considers tokens until the cumulative probability of the tokens to select from reaches 0.9. It's recommended to adjust either temperature or `top_p`, but not both.",
+ "title": "Topp"
},
- "oidcConfig": {
+ "enableEnhancedCivicAnswers": {
"anyOf": [
{
- "$ref": "#/$defs/AuthConfigOidcConfig"
+ "type": "boolean"
},
{
"type": "null"
}
],
"default": null,
- "description": "Config for user OIDC auth."
+ "description": "Optional. Enables enhanced civic answers. It may not be available for all models. This field is not supported in Vertex AI.",
+ "title": "Enableenhancedcivicanswers"
}
},
- "title": "AuthConfig",
+ "title": "GenerationConfig",
"type": "object"
},
- "AuthConfigGoogleServiceAccountConfig": {
+ "GenerationConfigRoutingConfig": {
"additionalProperties": false,
- "description": "Config for Google Service Account Authentication.\n\nThis data type is not supported in Gemini API.",
+ "description": "The configuration for routing the request to a specific model.\n\nThis can be used to control which model is used for the generation, either\nautomatically or by specifying a model name. This data type is not supported\nin Gemini API.",
"properties": {
- "serviceAccount": {
+ "autoMode": {
"anyOf": [
{
- "type": "string"
+ "$ref": "#/$defs/GenerationConfigRoutingConfigAutoRoutingMode"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. The service account that the extension execution service runs as. - If the service account is specified, the `iam.serviceAccounts.getAccessToken` permission should be granted to Vertex AI Extension Service Agent (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the specified service account. - If not specified, the Vertex AI Extension Service Agent will be used to execute the Extension.",
- "title": "Serviceaccount"
- }
- },
- "title": "AuthConfigGoogleServiceAccountConfig",
- "type": "object"
- },
- "AuthConfigHttpBasicAuthConfig": {
- "additionalProperties": false,
- "description": "Config for HTTP Basic Authentication.\n\nThis data type is not supported in Gemini API.",
- "properties": {
- "credentialSecret": {
+ "description": "In this mode, the model is selected automatically based on the content of the request."
+ },
+ "manualMode": {
"anyOf": [
{
- "type": "string"
+ "$ref": "#/$defs/GenerationConfigRoutingConfigManualRoutingMode"
},
{
"type": "null"
}
],
"default": null,
- "description": "Required. The name of the SecretManager secret version resource storing the base64 encoded credentials. Format: `projects/{project}/secrets/{secrete}/versions/{version}` - If specified, the `secretmanager.versions.access` permission should be granted to Vertex AI Extension Service Agent (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the specified resource.",
- "title": "Credentialsecret"
+ "description": "In this mode, the model is specified manually."
}
},
- "title": "AuthConfigHttpBasicAuthConfig",
+ "title": "GenerationConfigRoutingConfig",
"type": "object"
},
- "AuthConfigOauthConfig": {
+ "GenerationConfigRoutingConfigAutoRoutingMode": {
"additionalProperties": false,
- "description": "Config for user oauth. This data type is not supported in Gemini API.",
+ "description": "The configuration for automated routing.\n\nWhen automated routing is specified, the routing will be determined by the\npretrained routing model and customer provided model routing preference. This\ndata type is not supported in Gemini API.",
"properties": {
- "accessToken": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "Access token for extension endpoint. Only used to propagate token from [[ExecuteExtensionRequest.runtime_auth_config]] at request time.",
- "title": "Accesstoken"
- },
- "serviceAccount": {
+ "modelRoutingPreference": {
"anyOf": [
{
+ "enum": [
+ "UNKNOWN",
+ "PRIORITIZE_QUALITY",
+ "BALANCED",
+ "PRIORITIZE_COST"
+ ],
"type": "string"
},
{
@@ -26201,31 +25352,18 @@ Submodules }
],
"default": null,
- "description": "The service account used to generate access tokens for executing the Extension. - If the service account is specified, the `iam.serviceAccounts.getAccessToken` permission should be granted to Vertex AI Extension Service Agent (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents) on the provided service account.",
- "title": "Serviceaccount"
+ "description": "The model routing preference.",
+ "title": "Modelroutingpreference"
}
},
- "title": "AuthConfigOauthConfig",
+ "title": "GenerationConfigRoutingConfigAutoRoutingMode",
"type": "object"
},
- "AuthConfigOidcConfig": {
+ "GenerationConfigRoutingConfigManualRoutingMode": {
"additionalProperties": false,
- "description": "Config for user OIDC auth.\n\nThis data type is not supported in Gemini API.",
+ "description": "The configuration for manual routing.\n\nWhen manual routing is specified, the model will be selected based on the\nmodel name provided. This data type is not supported in Gemini API.",
"properties": {
- "idToken": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "OpenID Connect formatted ID token for extension endpoint. Only used to propagate token from [[ExecuteExtensionRequest.runtime_auth_config]] at request time.",
- "title": "Idtoken"
- },
- "serviceAccount": {
+ "modelName": {
"anyOf": [
{
"type": "string"
@@ -26235,69 +25373,96 @@ Submodules }
],
"default": null,
- "description": "The service account used to generate an OpenID Connect (OIDC)-compatible JWT token signed by the Google OIDC Provider (accounts.google.com) for extension endpoint (https://cloud.google.com/iam/docs/create-short-lived-credentials-direct#sa-credentials-oidc). - The audience for the token will be set to the URL in the server url defined in the OpenApi spec. - If the service account is provided, the service account should grant `iam.serviceAccounts.getOpenIdToken` permission to Vertex AI Extension Service Agent (https://cloud.google.com/vertex-ai/docs/general/access-control#service-agents).",
- "title": "Serviceaccount"
+ "description": "The name of the model to use. Only public LLM models are accepted.",
+ "title": "Modelname"
}
},
- "title": "AuthConfigOidcConfig",
+ "title": "GenerationConfigRoutingConfigManualRoutingMode",
"type": "object"
},
- "AuthType": {
- "description": "Type of auth scheme. This enum is not supported in Gemini API.",
+ "MatchOperation": {
+ "description": "Match operation to use for evaluation.",
"enum": [
- "AUTH_TYPE_UNSPECIFIED",
- "NO_AUTH",
- "API_KEY_AUTH",
- "HTTP_BASIC_AUTH",
- "GOOGLE_SERVICE_ACCOUNT_AUTH",
- "OAUTH",
- "OIDC_AUTH"
+ "MATCH_OPERATION_UNSPECIFIED",
+ "REGEX_CONTAINS",
+ "PARTIAL_MATCH",
+ "EXACT_MATCH"
],
- "title": "AuthType",
+ "title": "MatchOperation",
"type": "string"
},
- "Behavior": {
- "description": "Specifies the function Behavior.\n\nCurrently only non-blocking functions are supported. If not specified, the\nsystem keeps the current function call behavior. This field is currently only\nsupported by the BidiGenerateContent method.",
+ "MediaResolution": {
+ "description": "The media resolution to use.",
"enum": [
- "UNSPECIFIED",
- "BLOCKING",
- "NON_BLOCKING"
+ "MEDIA_RESOLUTION_UNSPECIFIED",
+ "MEDIA_RESOLUTION_LOW",
+ "MEDIA_RESOLUTION_MEDIUM",
+ "MEDIA_RESOLUTION_HIGH"
],
- "title": "Behavior",
+ "title": "MediaResolution",
"type": "string"
},
- "Blob": {
+ "Modality": {
+ "description": "Server content modalities.",
+ "enum": [
+ "MODALITY_UNSPECIFIED",
+ "TEXT",
+ "IMAGE",
+ "AUDIO",
+ "VIDEO"
+ ],
+ "title": "Modality",
+ "type": "string"
+ },
+ "ModelSelectionConfig": {
"additionalProperties": false,
- "description": "A content blob.\n\nA Blob contains data of a specific media type. It is used to represent images,\naudio, and video.",
+ "description": "Config for model selection.",
"properties": {
- "data": {
+ "featureSelectionPreference": {
"anyOf": [
{
- "format": "base64url",
- "type": "string"
+ "$ref": "#/$defs/FeatureSelectionPreference"
},
{
"type": "null"
}
],
"default": null,
- "description": "Required. The raw bytes of the data.",
- "title": "Data"
- },
- "displayName": {
+ "description": "Options for feature selection preference."
+ }
+ },
+ "title": "ModelSelectionConfig",
+ "type": "object"
+ },
+ "MultiSpeakerVoiceConfig": {
+ "additionalProperties": false,
+ "description": "Configuration for a multi-speaker text-to-speech request.",
+ "properties": {
+ "speakerVoiceConfigs": {
"anyOf": [
{
- "type": "string"
+ "items": {
+ "$ref": "#/$defs/SpeakerVoiceConfig"
+ },
+ "type": "array"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. The display name of the blob. Used to provide a label or filename to distinguish blobs. This field is only returned in `PromptMessage` for prompt management. It is used in the Gemini calls only when server-side tools (`code_execution`, `google_search`, and `url_context`) are enabled. This field is not supported in Gemini API.",
- "title": "Displayname"
- },
- "mimeType": {
+ "description": "Required. A list of configurations for the voices of the speakers. Exactly two speaker voice configurations must be provided.",
+ "title": "Speakervoiceconfigs"
+ }
+ },
+ "title": "MultiSpeakerVoiceConfig",
+ "type": "object"
+ },
+ "PrebuiltVoiceConfig": {
+ "additionalProperties": false,
+ "description": "Configuration for a prebuilt voice.",
+ "properties": {
+ "voiceName": {
"anyOf": [
{
"type": "string"
@@ -26307,30 +25472,30 @@ Submodules }
],
"default": null,
- "description": "Required. The IANA standard MIME type of the source data.",
- "title": "Mimetype"
+ "description": "The name of the prebuilt voice to use.",
+ "title": "Voicename"
}
},
- "title": "Blob",
+ "title": "PrebuiltVoiceConfig",
"type": "object"
},
- "CodeExecutionResult": {
+ "ReinforcementTuningAutoraterScorer": {
"additionalProperties": false,
- "description": "Result of executing the `ExecutableCode`.\n\nGenerated only when the `CodeExecution` tool is used.",
+ "description": "Reinforcement tuning autorater scorer.",
"properties": {
- "outcome": {
+ "autoraterConfig": {
"anyOf": [
{
- "$ref": "#/$defs/Outcome"
+ "$ref": "#/$defs/AutoraterConfig"
},
{
"type": "null"
}
],
"default": null,
- "description": "Required. Outcome of the code execution."
+ "description": "Autorater config for evaluation."
},
- "output": {
+ "autoraterPrompt": {
"anyOf": [
{
"type": "string"
@@ -26340,104 +25505,67 @@ Submodules }
],
"default": null,
- "description": "Optional. Contains stdout when code execution is successful, stderr or other description otherwise.",
- "title": "Output"
+ "description": "Allows substituting `prompt`, `response`, `system_instruction` and `references.reference` (each wrapped in double curly braces) into the autorater prompt.",
+ "title": "Autoraterprompt"
},
- "id": {
+ "autoraterResponseParseConfig": {
"anyOf": [
{
- "type": "string"
+ "$ref": "#/$defs/ReinforcementTuningParseResponseConfig"
},
{
"type": "null"
}
],
"default": null,
- "description": "The identifier of the `ExecutableCode` part this result is for. Only populated if the corresponding `ExecutableCode` has an id.",
- "title": "Id"
- }
- },
- "title": "CodeExecutionResult",
- "type": "object"
- },
- "ComputerUse": {
- "additionalProperties": false,
- "description": "Tool to support computer use.",
- "properties": {
- "environment": {
+ "description": "Parses autorater returned response."
+ },
+ "parsedResponseConversionScorer": {
"anyOf": [
{
- "$ref": "#/$defs/Environment"
+ "$ref": "#/$defs/ReinforcementTuningAutoraterScorerParsedResponseConversionScorer"
},
{
"type": "null"
}
],
"default": null,
- "description": "Required. The environment being operated."
+ "description": "Scores autorater responses by directly converting parsed autorater response to float reward."
},
- "excludedPredefinedFunctions": {
+ "exactMatchScorer": {
"anyOf": [
{
- "items": {
- "type": "string"
- },
- "type": "array"
+ "$ref": "#/$defs/ReinforcementTuningAutoraterScorerExactMatchScorer"
},
{
"type": "null"
}
],
"default": null,
- "description": "By default, predefined functions are included in the final model call.\n Some of them can be explicitly excluded from being automatically included.\n This can serve two purposes:\n 1. Using a more restricted / different action space.\n 2. Improving the definitions / instructions of predefined functions.",
- "title": "Excludedpredefinedfunctions"
+ "description": "Scores autorater responses by using exact string match reward scorer."
}
},
- "title": "ComputerUse",
+ "title": "ReinforcementTuningAutoraterScorer",
"type": "object"
},
- "Content": {
+ "ReinforcementTuningAutoraterScorerExactMatchScorer": {
"additionalProperties": false,
- "description": "Contains the multi-part content of a message.",
+ "description": "Scores autorater responses by using exact string match reward scorer.",
"properties": {
- "parts": {
+ "correctAnswerReward": {
"anyOf": [
{
- "items": {
- "$ref": "#/$defs/Part"
- },
- "type": "array"
+ "type": "number"
},
{
"type": "null"
}
],
"default": null,
- "description": "List of parts that constitute a single message. Each part may have\n a different IANA MIME type.",
- "title": "Parts"
+ "description": "Assigns this reward score if parsed response string equals the expression.",
+ "title": "Correctanswerreward"
},
- "role": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "Optional. The producer of the content. Must be either 'user' or 'model'. If not set, the service will default to 'user'.",
- "title": "Role"
- }
- },
- "title": "Content",
- "type": "object"
- },
- "DynamicRetrievalConfig": {
- "additionalProperties": false,
- "description": "Describes the options to customize dynamic retrieval.",
- "properties": {
- "dynamicThreshold": {
+ "wrongAnswerReward": {
"anyOf": [
{
"type": "number"
@@ -26447,84 +25575,59 @@ Submodules }
],
"default": null,
- "description": "Optional. The threshold to be used in dynamic retrieval. If not set, a system default value is used.",
- "title": "Dynamicthreshold"
+ "description": "Assigns this reward score if parsed reward value does not equal the expression.",
+ "title": "Wronganswerreward"
},
- "mode": {
+ "expression": {
"anyOf": [
{
- "$ref": "#/$defs/DynamicRetrievalConfigMode"
+ "type": "string"
},
{
"type": "null"
}
],
"default": null,
- "description": "The mode of the predictor to be used in dynamic retrieval."
+ "description": "The string expression to match against. Supports substitution in the format of `references.reference` (wrapped in double curly braces) before matching. No regex support.",
+ "title": "Expression"
}
},
- "title": "DynamicRetrievalConfig",
+ "title": "ReinforcementTuningAutoraterScorerExactMatchScorer",
"type": "object"
},
- "DynamicRetrievalConfigMode": {
- "description": "The mode of the predictor to be used in dynamic retrieval.",
- "enum": [
- "MODE_UNSPECIFIED",
- "MODE_DYNAMIC"
- ],
- "title": "DynamicRetrievalConfigMode",
- "type": "string"
+ "ReinforcementTuningAutoraterScorerParsedResponseConversionScorer": {
+ "additionalProperties": false,
+ "description": "Scores responses by directly converting parsed autorater response to float reward (reward is clipped to be within [-1, 1]).",
+ "properties": {},
+ "title": "ReinforcementTuningAutoraterScorerParsedResponseConversionScorer",
+ "type": "object"
},
- "EnterpriseWebSearch": {
+ "ReinforcementTuningCloudRunRewardScorer": {
"additionalProperties": false,
- "description": "Tool to search public web data, powered by Vertex AI Search and Sec4 compliance.\n\nThis data type is not supported in Gemini API.",
+ "description": "Scores parsed responses by calling a Cloud Run service.",
"properties": {
- "blockingConfidence": {
- "anyOf": [
- {
- "$ref": "#/$defs/PhishBlockThreshold"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "Optional. Sites with confidence level chosen & above this value will be blocked from the search results."
- },
- "excludeDomains": {
+ "cloudRunUri": {
"anyOf": [
{
- "items": {
- "type": "string"
- },
- "type": "array"
+ "type": "string"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. List of domains to be excluded from the search results. The default limit is 2000 domains.",
- "title": "Excludedomains"
+ "description": "URI of the Cloud Run service that will be used to compute the reward. The Vertex AI Secure Fine Tuning Service Agent (`service-PROJECT_NUMBER@gcp-sa-vertex-tune.iam.gserviceaccount.com`, where `PROJECT_NUMBER` is the numeric project number) must be granted the permission (e.g. by granting `roles/run.invoker` in IAM) to invoke the Cloud Run service.",
+ "title": "Cloudrunuri"
}
},
- "title": "EnterpriseWebSearch",
+ "title": "ReinforcementTuningCloudRunRewardScorer",
"type": "object"
},
- "Environment": {
- "description": "The environment being operated.",
- "enum": [
- "ENVIRONMENT_UNSPECIFIED",
- "ENVIRONMENT_BROWSER"
- ],
- "title": "Environment",
- "type": "string"
- },
- "ExecutableCode": {
+ "ReinforcementTuningCodeExecutionRewardScorer": {
"additionalProperties": false,
- "description": "Model-generated code executed server-side, results returned to the model.\n\nOnly generated when using the `CodeExecution` tool, in which the code will\nbe automatically executed, and a corresponding `CodeExecutionResult` will\nalso be generated.",
+ "description": "Scores parsed responses for code execution use cases.",
"properties": {
- "code": {
+ "pythonCodeSnippet": {
"anyOf": [
{
"type": "string"
@@ -26534,22 +25637,30 @@ Submodules }
],
"default": null,
- "description": "Required. The code to be executed.",
- "title": "Code"
- },
- "language": {
+ "description": "Example python code snippet which assigns reward of 1 to answer matching user provided reference answer in per prompt references map.",
+ "title": "Pythoncodesnippet"
+ }
+ },
+ "title": "ReinforcementTuningCodeExecutionRewardScorer",
+ "type": "object"
+ },
+ "ReinforcementTuningParseResponseConfig": {
+ "additionalProperties": false,
+ "description": "Defines how to parse sample response for reinforcement tuning.",
+ "properties": {
+ "parseType": {
"anyOf": [
{
- "$ref": "#/$defs/Language"
+ "$ref": "#/$defs/ResponseParseType"
},
{
"type": "null"
}
],
"default": null,
- "description": "Required. Programming language of the `code`."
+ "description": "Defines how to parse sample response."
},
- "id": {
+ "regexExtractExpression": {
"anyOf": [
{
"type": "string"
@@ -26559,66 +25670,76 @@ Submodules }
],
"default": null,
- "description": "Unique identifier of the `ExecutableCode` part. The server returns the `CodeExecutionResult` with the matching `id`.",
- "title": "Id"
+ "description": "Defines the regex to extract the important part of sample response. This field is only used when `parse_type` is `REGEX_EXTRACT`.",
+ "title": "Regexextractexpression"
}
},
- "title": "ExecutableCode",
+ "title": "ReinforcementTuningParseResponseConfig",
"type": "object"
},
- "ExternalApi": {
+ "ReinforcementTuningStringMatchRewardScorer": {
"additionalProperties": false,
- "description": "Retrieve from data source powered by external API for grounding.\n\nThe external API is not owned by Google, but need to follow the pre-defined\nAPI spec. This data type is not supported in Gemini API.",
+ "description": "Scores parsed responses for string matching use cases.",
"properties": {
- "apiAuth": {
+ "wrongAnswerReward": {
"anyOf": [
{
- "$ref": "#/$defs/ApiAuth"
+ "type": "number"
},
{
"type": "null"
}
],
"default": null,
- "description": "The authentication config to access the API. Deprecated. Please use auth_config instead."
+ "description": "Wrong answer reward is returned if evaluator evaluates to `false`. All wrong answers get the same reward.",
+ "title": "Wronganswerreward"
},
- "apiSpec": {
+ "correctAnswerReward": {
"anyOf": [
{
- "$ref": "#/$defs/ApiSpec"
+ "type": "number"
},
{
"type": "null"
}
],
"default": null,
- "description": "The API spec that the external API implements."
+ "description": "Correct answer reward is returned if evaluator evaluates to `true`. All correct answers get the same reward.",
+ "title": "Correctanswerreward"
},
- "authConfig": {
+ "stringMatchExpression": {
"anyOf": [
{
- "$ref": "#/$defs/AuthConfig"
+ "$ref": "#/$defs/ReinforcementTuningStringMatchRewardScorerStringMatchExpression"
},
{
"type": "null"
}
],
"default": null,
- "description": "The authentication config to access the API."
+ "description": "Uses string match expression to evaluate parsed response."
},
- "elasticSearchParams": {
+ "jsonMatchExpression": {
"anyOf": [
{
- "$ref": "#/$defs/ExternalApiElasticSearchParams"
+ "$ref": "#/$defs/ReinforcementTuningStringMatchRewardScorerJsonMatchExpression"
},
{
"type": "null"
}
],
"default": null,
- "description": "Parameters for the elastic search API."
- },
- "endpoint": {
+ "description": "Uses json match expression to evaluate parsed response."
+ }
+ },
+ "title": "ReinforcementTuningStringMatchRewardScorer",
+ "type": "object"
+ },
+ "ReinforcementTuningStringMatchRewardScorerJsonMatchExpression": {
+ "additionalProperties": false,
+ "description": "Converts parsed responses to JSON format, finds the first-level matching key, then performs StringMatchExpression on the value.",
+ "properties": {
+ "keyName": {
"anyOf": [
{
"type": "string"
@@ -26628,56 +25749,42 @@ Submodules }
],
"default": null,
- "description": "The endpoint of the external API. The system will call the API at this endpoint to retrieve the data for grounding. Example: https://acme.com:443/search",
- "title": "Endpoint"
+ "description": "Json key name to find the value to match against.",
+ "title": "Keyname"
},
- "simpleSearchParams": {
+ "valueStringMatchExpression": {
"anyOf": [
{
- "$ref": "#/$defs/ExternalApiSimpleSearchParams"
+ "$ref": "#/$defs/ReinforcementTuningStringMatchRewardScorerStringMatchExpression"
},
{
"type": "null"
}
],
"default": null,
- "description": "Parameters for the simple search API."
+ "description": "String match expression to match against the value of json key."
}
},
- "title": "ExternalApi",
+ "title": "ReinforcementTuningStringMatchRewardScorerJsonMatchExpression",
"type": "object"
},
- "ExternalApiElasticSearchParams": {
+ "ReinforcementTuningStringMatchRewardScorerStringMatchExpression": {
"additionalProperties": false,
- "description": "The search parameters to use for the ELASTIC_SEARCH spec.\n\nThis data type is not supported in Gemini API.",
+ "description": "Evaluates parsed response using match type against expression.",
"properties": {
- "index": {
- "anyOf": [
- {
- "type": "string"
- },
- {
- "type": "null"
- }
- ],
- "default": null,
- "description": "The ElasticSearch index to use.",
- "title": "Index"
- },
- "numHits": {
+ "matchOperation": {
"anyOf": [
{
- "type": "integer"
+ "$ref": "#/$defs/MatchOperation"
},
{
"type": "null"
}
],
"default": null,
- "description": "Optional. Number of hits (chunks) to request. When specified, it is passed to Elasticsearch as the `num_hits` param.",
- "title": "Numhits"
+ "description": "Match operation to use for evaluation."
},
- "searchTemplate": {
+ "expression": {
"anyOf": [
{
"type": "string"
@@ -26687,36 +25794,18 @@ Submodules }
],
"default": null,
- "description": "The ElasticSearch search template to use.",
- "title": "Searchtemplate"
+ "description": "String or regular expression to match against. Customer can also provide a references map (key/value pairs) whose value will be substituted into the expression by referencing `references.key_name` (wrapped in double curly braces).",
+ "title": "Expression"
}
},
- "title": "ExternalApiElasticSearchParams",
- "type": "object"
- },
- "ExternalApiSimpleSearchParams": {
- "additionalProperties": false,
- "description": "The search parameters to use for SIMPLE_SEARCH spec.\n\nThis data type is not supported in Gemini API.",
- "properties": {},
- "title": "ExternalApiSimpleSearchParams",
+ "title": "ReinforcementTuningStringMatchRewardScorerStringMatchExpression",
"type": "object"
},
- "FeatureSelectionPreference": {
- "description": "Options for feature selection preference.",
- "enum": [
- "FEATURE_SELECTION_PREFERENCE_UNSPECIFIED",
- "PRIORITIZE_QUALITY",
- "BALANCED",
- "PRIORITIZE_COST"
- ],
- "title": "FeatureSelectionPreference",
- "type": "string"
- },
- "File": {
+ "ReplicatedVoiceConfig": {
"additionalProperties": false,
- "description": "A file uploaded to the API.",
+ "description": "The configuration for the replicated voice to use.",
"properties": {
- "name": {
+ "mimeType": {
"anyOf": [
{
"type": "string"
@@ -26726,12 +25815,13 @@ Submodules