取得互動¶
您正在檢視 Interactions API 的 beta 版本。端點位於 /v1beta/ 之下。另有穩定的 v1 版本 可用。
GET https://generativelanguage.googleapis.com/v1beta/interactions/{id}
依 Interaction.id 擷取單一互動的完整詳細資料。
參數¶
api_version: required string
用於請求路由的 API 版本。
id: required string
要擷取的互動的唯一識別碼。
last_event_id: string
可選。若設定,將從事件 ID 所標記事件的下一個區塊起,繼續互動串流。僅能在 stream 為 true 時使用。
stream: boolean
若設為 true,生成的內容將以增量方式串流傳輸。
預設值:False
範例請求
curl -X GET "https://generativelanguage.googleapis.com/v1beta/interactions/$INTERACTION_ID" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
from google import genai
client = genai.Client()
interaction = client.interactions.get(id=created.id)
print(interaction.status)
import {GoogleGenAI} from '@google/genai';
const ai = new GoogleGenAI({});
const interaction = await ai.interactions.get(created.id);
console.log(interaction.status);
import com.google.genai.Client;
import com.google.genai.gaos.models.operations.GetInteractionByIdRequest;
import com.google.genai.gaos.models.operations.GetInteractionByIdResponse;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionStatus;
Client client = new Client();
GetInteractionByIdResponse getResponse =
client.interactions.get(new GetInteractionByIdRequest(interactionId));
Interaction interaction =
getResponse
.interaction()
.orElseThrow(() -> new RuntimeException("No interaction returned"));
System.out.println(interaction.status().map(InteractionStatus::value).orElse(""));
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
interaction, err := client.Interactions.Get(ctx, operations.GetInteractionByIDRequest{
ID: *created.Interaction.ID,
})
if err != nil {
log.Fatal(err)
}
if interaction.Interaction != nil {
fmt.Println(interaction.Interaction.Status)
}
}
回應¶
傳回 Interaction 資源。
範例回應
{
"created": "2025-11-26T12:25:15Z",
"id": "v1_ChdPU0F4YWFtNkFwS2kxZThQZ05lbXdROBIXT1NBeGFhbTZBcEtpMWU4UGdOZW13UTg",
"model": "gemini-3.8-flash",
"object": "interaction",
"status": "completed",
"steps": [
{
"type": "model_output",
"content": [
{
"type": "text",
"text": "I'm doing great, thank you for asking! How can I help you today?"
}
]
}
],
"updated": "2025-11-26T12:25:15Z"
}
資源¶
Interaction¶
Interaction 資源。
屬性:
id: required string
僅供輸出。互動完成的唯一識別碼。
**status**: required `string enum` 僅供輸出。 互動的狀態。
可能值: - `in_progress`: 互動進行中。 - `requires_action`: 互動需要使用者採取行動或提供輸入。 - `completed`: 互動已完成。 - `failed`: 互動失敗。 - `cancelled`: 互動已取消。 - `incomplete`: 互動已完成,但包含不完整的結果(例如達到 max_tokens)。 - `requires_continuation`: 互動至少還需要再提出一次請求才能完成。下一次請求應將 continuation_token 設為本次請求傳回的權杖。created: required string
僅供輸出。回應的建立時間,採 ISO 8601 格式(YYYY-MM-DDThh:mm:ssZ)。
updated: required string
僅供輸出。回應的最後更新時間,採 ISO 8601 格式(YYYY-MM-DDThh:mm:ssZ)。
steps: required Step array
僅供輸出。組成互動的步驟(包含於回應中時)。
**model**: `ModelOption` 用於生成互動的 `Model` 名稱。
可能值: - `gemma-4-26b-a4b-it`: Gemma 4 26B A4B IT - `gemma-4-31b-it`: Gemma 4 31B IT - `gemini-flash-latest`: Gemini Flash 的最新版本 - `gemini-flash-lite-latest`: Gemini Flash-Lite 的最新版本 - `gemini-pro-latest`: Gemini Pro 的最新版本 - `gemini-2.5-flash`: 我們的第一款混合推理模型,支援 100 萬權杖的上下文視窗,並具備思考預算。 - `gemini-2.5-pro`: 我們最先進的多用途模型,擅長程式設計與複雜推理工作。 - `gemini-2.5-flash-lite`: 我們最小且最具成本效益的模型,專為大規模使用而打造。 - `gemini-3.5-flash-lite`: Gemini 3.5 Flash-Lite:我們速度最快、最具成本效益的 3.5 模型,適合高輸送量執行。 - `gemini-2.5-flash-image`: 我們的原生圖片生成模型,針對速度、彈性與脈絡理解最佳化。文字輸入與輸出的計價與 2.5 Flash 相同。 - `gemini-3-flash-preview`: 我們為速度而打造的最聰明模型,結合前沿智慧與卓越的搜尋及接地能力。 - `gemini-3.1-pro-preview`: 我們最新的 SOTA 推理模型,具備前所未有的深度與細膩度,以及強大的多模態理解與程式設計能力。 - `gemini-3.1-pro-preview-customtools`: Gemini 3.1 Pro Preview,針對自訂工具使用最佳化 - `gemini-3.1-flash-lite`: 我們最具成本效益的模型,針對大量代理工作、翻譯與簡單資料處理最佳化。 - `gemini-3.1-flash-lite-image`: Gemini 3.1 Flash Lite Image。 - `gemini-3-pro-image`: Gemini 3 Pro Image - `nano-banana-pro-preview`: Gemini 3 Pro Image Preview - `gemini-3.1-flash-image`: Gemini 3.1 Flash Image。 - `gemini-nano-banana-2.1`: Gemini Nano Banana 2.1。 - `gemini-3.1-flash-tts-preview`: Gemini 3.1 Flash TTS:強大、低延遲的語音生成。提供自然的輸出、可引導的提示詞,以及全新富表現力的音訊標記,可精確控制旁白。 - `gemini-3.5-flash`: Gemini 3.5 Flash:我們較早期的 Flash 模型,為日常、高輸送量工作負載的速度與基礎效能而打造。 - `gemini-3.6-flash`: Gemini 3.6 Flash:我們前一代的 Flash 模型,在一般代理與日常工作中兼顧速度與多模態能力。 - `gemini-3.7-flash`: Gemini 3.7 Flash:我們高速且高效率的 Flash 模型,為日常程式設計、代理工具使用與可靠的多步驟執行而打造。 - `gemini-3.8-flash`: Gemini 3.8 Flash:我們最聰明的 Flash 模型,專為長程軟體工程、自主代理與複雜企業工作流程而設計。 - `gemini-4-argon`: Gemini 4 Argon:我們全新的前沿模型,為真實世界的軟體工程與知識工作而打造,能以深度與精確度解決最困難的問題。 - `gemini-4-carbon`: Gemini 4 Carbon:我們能力最強的推理模型,為持續性的代理程式設計、多模態知識工作、科學探索與資安防禦而打造。 - `gemini-4-hydrogen`: Gemini 4 Hydrogen:具備前沿級智慧的模型,為程式設計、代理工作流程與多模態知識工作提供快速可靠的執行。 - `gemini-3.8-flash-tts`: Gemini 3.8 Flash TTS:旗艦 TTS 模型,支援 Voice Design 與雙講者劇本控制。可提示自訂聲音角色、逐行引導語音呈現,並加入聲音爆發效果。 - `gemini-3.8-flash-lite-tts`: Gemini 3.8 Flash Lite TTS:高速且具成本效益,適合快速配音、媒體在地化與高輸送量語音代理。可直接取代 gemini-3.1-flash-tts-preview。 - `gemini-3.5-transcribe`: Gemini 3.5 Transcribe:低延遲的語音轉文字模型,具備以語句為單位的語言偵測、講者分離、單字級時間戳記與自訂詞彙偏置。 - `lyria-3-clip-preview`: 我們的低延遲音樂生成模型,針對高傳真音訊片段與精確的節奏控制最佳化。 - `lyria-3-pro-preview`: 我們先進的完整歌曲生成模型,具備深厚的作曲理解能力,針對精確的結構控制與多元音樂風格間的複雜轉場最佳化。 - `gemini-robotics-er-1.6-preview`: Gemini Robotics-ER 1.6 Preview - `gemini-robotics-er-2-preview`: Gemini Robotics Embodied Reasoning 2 Preview - `lyria-3.5`: 我們的旗艦音樂生成模型,針對結構複雜且連貫的完整長度歌曲最佳化。 - `gemini-omni-1.2-flash`: Gemini Omni 1.2 Flash:我們最新的多模態模型,支援快速、對話式的影片生成、編輯與電影級控制。 - `gemini-omni-1.1-flash`: 我們的高效能多模態模型,專為快速、對話式的影片生成、編輯與電影級控制而設計。 - `gemini-omni-flash-preview`: 我們多模態模型的預覽版本,支援對話式影片生成、編輯與電影級控制。**generation_config**: `GenerationConfig` 僅供輸入。 模型互動的設定參數。
**seed**: `integer` 解碼時使用的種子,以確保可重現性。 **stop_sequences**: `string array` 會停止互動輸出的字元序列清單。**tool_choice**: [`ToolChoiceConfig`](/api-reference/interactions-api/get-interaction-by-id/#Resource:ToolChoiceConfig) or `string enum` 工具選擇設定。
**可能類型**:**[ToolChoiceConfig](/api-reference/interactions-api/get-interaction-by-id/#Resource:ToolChoiceConfig)**
包含允許工具的工具選擇設定。**allowed_tools**: `AllowedTools` 允許的工具。
**mode**: `string enum` 工具選擇的模式。
可能值: - `auto`: 自動工具選擇。 - `any`: 任意工具選擇。 - `none`: 不使用工具選擇。 - `validated`: 已驗證的工具選擇。**string enum**
可能值: - `auto`: 自動工具選擇。 - `any`: 任意工具選擇。 - `none`: 不使用工具選擇。 - `validated`: 已驗證的工具選擇。**thinking_level**: `ThinkingLevel` 模型應生成的思考權杖等級。
可能值: - `minimal`: 幾乎不進行思考。 - `low`: 低思考等級。 - `medium`: 中思考等級。 - `high`: 高思考等級。 - `xhigh`: 超高思考等級,高於 `high`。**thinking_summaries**: `ThinkingSummaries` 是否在回應中包含思考摘要。
可能值: - `auto`: 自動思考摘要。 - `none`: 不提供思考摘要。**video_config**: `VideoConfig` 影片生成的設定。
**task**: `string enum` 影片生成的可選工作模式。若未指定,模型會依提供的文字提示詞與輸入媒體自動決定適當的模式。
可能值: - `text_to_video`: 僅依文字提示詞生成影片。 - `image_to_video`: 依一或兩張來源圖片生成影片。第一張圖片定義起始影格,第二張圖片(可選)定義結束影格。 - `reference_to_video`: 使用參考媒體(例如圖片、音訊或影片)生成影片。 - `edit`: 修改現有的輸入影片。 - `extend`: 延伸現有的輸入影片。**transcription_config**: `TranscriptionConfig` 可選。語音辨識(轉錄)的設定。若提供此欄位,將啟用 ASR。
**language_codes**: `string array` 可選。BCP-47 語言代碼,提供音訊中所含語言的提示。若省略或留空,預設為自動語言偵測。 **custom_vocabulary**: `string array` 可選。自訂詞彙片語清單,用來引導語音辨識模型偏向辨識特定詞彙。**mode**: `TranscriptionMode` or `string enum` 具區別性的轉錄模式選項或列舉。
**可能類型**:**SmartTranscriptionMode**
智慧轉錄模式的設定。 **type**: required `object` 值:`smart` **source_text**: `string` 要透過語音指令編輯或改寫的來源文字。提供此欄位時,模型會執行語音驅動的編輯,並輸出最終的取代文字。**VerbatimTranscriptionMode**
逐字轉錄模式的設定。 **type**: required `object` 值:`verbatim` **timestamp_granularities**: `string array` 可選。轉錄輸出中要包含的時間戳記粒度。支援的值:「word」。若留空,則不產生時間戳記。 **diarization_mode**: `string` 可選。設定講者分離。支援的值:「speaker」。**string enum**
可能值: - `verbatim`: 逐字轉錄模式。 - `smart`: 智慧轉錄模式。**structured_speech_config**: `SpeakerConfig` or `SpeechConfig array` 語音與多講者設定。
**可能類型**:**SpeakerConfig**
多講者與語音生成的設定。**speakers**: `SpeechConfig array` 個別講者設定。
**voice**: `string` 講者的聲音。 **language**: `string` 語音的語言。 **speaker**: `string` 講者的名稱,應與提示詞中給定的講者名稱一致。**SpeechConfig array**
語音互動的設定。 **voice**: `string` 講者的聲音。 **language**: `string` 語音的語言。 **speaker**: `string` 講者的名稱,應與提示詞中給定的講者名稱一致。system_instruction: string
互動的系統指令。
tools: Tool array
模型在互動期間可呼叫的工具宣告清單。
input: Content or Content array or Step array or string
互動的輸入。
**usage**: `Usage` 僅供輸出。 互動請求的權杖用量統計。
**total_input_tokens**: `integer` 提示詞(上下文)中的權杖數量。 **initial_input_tokens**: `integer` 本次互動第一輪所使用的輸入權杖數量。**input_tokens_by_modality**: `ModalityTokens array` 依模態區分的輸入權杖用量明細。
**modality**: `ResponseModality` 與權杖數量關聯的模態。
可能值: - `text`: 表示模型應傳回文字。 - `image`: 表示模型應傳回圖片。 - `audio`: 表示模型應傳回音訊。 - `video`: 表示模型應傳回影片。 - `document`: 表示模型應傳回文件。**cached_tokens_by_modality**: `ModalityTokens array` 依模態區分的快取權杖用量明細。
**modality**: `ResponseModality` 與權杖數量關聯的模態。
可能值: - `text`: 表示模型應傳回文字。 - `image`: 表示模型應傳回圖片。 - `audio`: 表示模型應傳回音訊。 - `video`: 表示模型應傳回影片。 - `document`: 表示模型應傳回文件。**output_tokens_by_modality**: `ModalityTokens array` 依模態區分的輸出權杖用量明細。
**modality**: `ResponseModality` 與權杖數量關聯的模態。
可能值: - `text`: 表示模型應傳回文字。 - `image`: 表示模型應傳回圖片。 - `audio`: 表示模型應傳回音訊。 - `video`: 表示模型應傳回影片。 - `document`: 表示模型應傳回文件。**tool_use_tokens_by_modality**: `ModalityTokens array` 依模態區分的工具使用權杖用量明細。
**modality**: `ResponseModality` 與權杖數量關聯的模態。
可能值: - `text`: 表示模型應傳回文字。 - `image`: 表示模型應傳回圖片。 - `audio`: 表示模型應傳回音訊。 - `video`: 表示模型應傳回影片。 - `document`: 表示模型應傳回文件。**grounding_tool_count**: `GroundingToolCount array` 接地工具計數。
**type**: `string enum` 與計數關聯的接地工具類型。
可能值: - `google_search`: 使用 Google 網頁搜尋與圖片搜尋接地,以及 Web Grounding for Enterprise。 - `google_maps`: 使用 Google 地圖接地。**response_format**: [`ResponseFormat`](/api-reference/interactions-api/get-interaction-by-id/#Resource:ResponseFormat) or [`ResponseFormat`](/api-reference/interactions-api/get-interaction-by-id/#Resource:ResponseFormat) `array` 強制生成的回應必須是符合此欄位所指定 JSON 架構的 JSON 物件。
**可能類型**:**[ResponseFormat](/api-reference/interactions-api/get-interaction-by-id/#Resource:ResponseFormat)**
**[ResponseFormat](/api-reference/interactions-api/get-interaction-by-id/#Resource:ResponseFormat) array**
清單中的每個項目為下列其中之一:`AudioResponseFormat`、`ImageResponseFormat`、`TextResponseFormat`、`VideoResponseFormat`。previous_interaction_id: string
前一次互動的 ID(如有)。
**environment**: [`EnvironmentConfig`](/api-reference/interactions-api/get-interaction-by-id/#Resource:EnvironmentConfig) or `string` 互動的環境設定。可以是指定遠端環境來源的物件,或是參照現有環境 ID 的字串。
**可能類型**:**[EnvironmentConfig](/api-reference/interactions-api/get-interaction-by-id/#Resource:EnvironmentConfig)**
自訂環境的設定。 **type**: required `object` 值:`remote`**sources**: `Source array`
**type**: `string enum`
可能值: - `gcs`: Cloud Storage 值區。 - `inline`: 行內內容。 - `repository`: 一般儲存庫。來源 URL 中的通訊協定前綴可識別提供者(例如 github://、gcs://)。**network**: [`EnvironmentNetworkEgressAllowlist`](/api-reference/interactions-api/get-interaction-by-id/#Resource:EnvironmentNetworkEgressAllowlist) or `string enum` 環境的網路設定。
**可能類型**:**[EnvironmentNetworkEgressAllowlist](/api-reference/interactions-api/get-interaction-by-id/#Resource:EnvironmentNetworkEgressAllowlist)**
環境的網路輸出流量設定。**allowlist**: `EgressRule array` or `string enum` 允許的網域及其設定清單。設為 `"disabled"` 可封鎖所有網路輸出流量。
**可能類型**:**EgressRule array**
單一網域允許清單規則,可選擇性注入標頭。 **domain**: required `string` 允許對外請求的網域。支援萬用字元(例如 '*.googleapis.com')。使用 '*' 可允許所有網域。 **transform**: `object` 要注入至符合此規則之請求的標頭。鍵:標頭名稱(例如「Authorization」)。值:標頭值(例如「Bearer your-token」)。 **credential**: `string` 可選。以 ID 參照伺服器管理的 Credential 資源。**string enum**
可能值: - `disabled`: 所有網路輸出流量皆被封鎖。**string enum**
可能值: - `disabled`: 所有網路輸出流量皆被封鎖。**env**: `object` or `string` 要在沙箱環境中設定的環境變數。
**可能類型**:**string**
直接的字串值。**mode**: `string enum` 此環境的運算生命週期模式。
可能值: - `on_demand`: 此環境的運算生命週期模式。 - `self_hosted`: 此環境的運算生命週期模式。**string**
直接的字串值。environment_id: string
僅供輸出。互動的環境 ID。僅在請求中設定了環境設定時才會填入。
**service_tier**: `ServiceTier` 互動的服務層級。
可能值: - `flex`: Flex 服務層級。 - `standard`: Standard 服務層級。 - `priority`: Priority 服務層級。**webhook_config**: `WebhookConfig` 可選。webhook 設定,用於在互動完成時接收通知。
**uris**: `string array` 可選。若設定,webhook 事件將使用這些 webhook URI,而非已註冊的 webhook。 **user_metadata**: `object` 可選。每次向 webhook 發送事件時一併傳回的使用者中繼資料。**safety_settings**: `SafetySetting array` 互動的安全設定。
**type**: required `HarmCategory` 要封鎖的危害類別類型。
可能值: - `hate_speech`: 基於特定屬性,宣揚暴力或煽動對個人或群體仇恨的內容。 - `dangerous_content`: 宣揚、協助或促成危險活動的內容。 - `harassment`: 辱罵、威脅,或意圖霸凌、折磨或嘲弄他人的內容。 - `sexually_explicit`: 包含露骨性內容的內容。 - `jailbreak`: 意圖繞過安全篩選器的提示詞。**threshold**: required `string enum` 封鎖內容的閾值。若有害機率超過此閾值,內容將被封鎖。
可能值: - `block_low_and_above`: 封鎖有害機率為低或更高的內容。 - `block_medium_and_above`: 封鎖有害機率為中或更高的內容。 - `block_only_high`: 封鎖有害機率為高的內容。 - `off`: 完全關閉安全篩選器。**method**: `string enum` 可選。封鎖內容的方法。若未指定,預設行為是使用機率分數。
可能值: - `severity`: 有害內容封鎖方法同時使用機率與嚴重程度分數。 - `probability`: 有害內容封鎖方法使用機率分數。labels: object
請求的標籤,包含使用者定義的中繼資料。標籤鍵與值的長度不得超過 63 個字元(Unicode 碼位),且只能包含小寫字母、數字字元、底線與連字號。允許使用國際字元。標籤值可省略。標籤鍵必須以字母開頭。
**errors**: `Error array` 僅供輸出。 記錄於互動上的診斷故障/平台錯誤。
**code**: `string` 識別錯誤類型的 URI。 **message**: `string` 人類可讀的錯誤訊息。continuation_token: string
用於繼續長時間解碼的不透明權杖。輸出:當狀態為 REQUIRES_CONTINUATION 且可繼續解碼時設定。輸入:在 CreateInteraction 中原封不動傳回最新權杖,即可繼續解碼。
stream: boolean
僅供輸入。互動是否以串流方式傳輸。
store: boolean
僅供輸入。是否儲存回應與請求,以供日後擷取。
background: boolean
僅供輸入。是否在背景執行模型互動。
**agent**: `AgentOption` 用於生成互動的 `Agent` 名稱。
可能值: - `deep-research-preview-04-2026`: Gemini Deep Research 代理 - `deep-research-max-preview-04-2026`: Gemini Deep Research Max 代理 - `antigravity-preview-05-2026`: 使用 Antigravity 受管理代理執行需要推理、檔案操作與工具使用的多步驟工作。 - `antigravity-preview-09-2026`: 使用 Antigravity 受管理代理執行需要推理、檔案操作與工具使用的多步驟工作。**agent_config**: `AntigravityAgentConfig` or `DeepResearchAgentConfig` or `DynamicAgentConfig` 代理互動的設定參數。
**可能類型**:**AntigravityAgentConfig**
Antigravity 代理執行階段的設定。提供伺服器端對代理執行環境與工具設定的控制。 **type**: required `object` 值:`antigravity` **model**: `string` 用於代理推理的模型。 **max_total_tokens**: `string` 代理執行的權杖總數上限。**DeepResearchAgentConfig**
Deep Research 代理的設定。 **type**: required `object` 值:`deep-research`**thinking_summaries**: `ThinkingSummaries` 是否在回應中包含思考摘要。
可能值: - `auto`: 自動思考摘要。 - `none`: 不提供思考摘要。**visualization**: `string enum` 是否在回應中包含視覺化內容。
可能值: - `off`: 不包含視覺化內容。 - `auto`: 自動包含視覺化內容。**DynamicAgentConfig**
動態代理的設定。 **type**: required `object` 值:`dynamic`max_total_tokens: string
代理執行的權杖總數上限。
範例
{
"created": "2025-12-04T15:01:45Z",
"id": "v1_ChdXS0l4YWZXTk9xbk0xZThQczhEcmlROBIXV0tJeGFmV05PcW5NMWU4UHM4RHJpUTg",
"model": "gemini-3.8-flash",
"object": "interaction",
"status": "completed",
"steps": [
{
"type": "model_output",
"content": [
{
"type": "text",
"text": "Hello! I'm doing well, functioning as expected. Thank you for asking! How are you doing today?"
}
]
}
],
"updated": "2025-12-04T15:01:45Z",
"usage": {
"input_tokens_by_modality": [
{
"modality": "text",
"tokens": 7
}
],
"total_cached_tokens": 0,
"total_input_tokens": 7,
"total_output_tokens": 23,
"total_thought_tokens": 49,
"total_tokens": 79,
"total_tool_use_tokens": 0
}
}
資料模型¶
Content¶
回應的內容。
多型類型:
**AudioContent**
音訊內容區塊。 **type**: required `object` 值:`audio` --- **data**: `string` 音訊內容。 --- **uri**: `string` 音訊的 URI。 --- **channels**: `integer` 音訊聲道數量。 --- **sample_rate**: `integer` 音訊的取樣率。 ---**mime_type**: `string enum` 音訊的 MIME 類型。
可能值: - `audio/wav`: WAV 音訊格式 - `audio/mp3`: MP3 音訊格式 - `audio/aiff`: AIFF 音訊格式 - `audio/aac`: AAC 音訊格式 - `audio/ogg`: OGG 音訊格式 - `audio/flac`: FLAC 音訊格式 - `audio/mpeg`: MPEG 音訊格式 - `audio/m4a`: M4A 音訊格式 - `audio/l16`: L16 音訊格式 - `audio/opus`: OPUS 音訊格式 - `audio/alaw`: ALAW 音訊格式 - `audio/mulaw`: MULAW 音訊格式 - `audio/webm`: WEBM 音訊格式{
"type": "audio",
"data": "BASE64_ENCODED_AUDIO",
"mime_type": "audio/wav"
}
**DocumentContent**
文件內容區塊。 **type**: required `object` 值:`document` --- **data**: `string` 文件內容。 --- **uri**: `string` 文件的 URI。 ---**mime_type**: `string enum` 文件的 MIME 類型。
可能值: - `application/pdf`: PDF 文件格式 - `text/csv`: CSV 文件格式 - `application/vnd.openxmlformats-officedocument.presentationml.presentation`: PPTX 簡報格式 - `application/vnd.ms-powerpoint`: PPT 簡報格式 - `application/vnd.oasis.opendocument.presentation`: ODP 簡報格式 - `application/vnd.openxmlformats-officedocument.wordprocessingml.document`: DOCX 文件格式 - `application/msword`: DOC 文件格式 - `application/vnd.openxmlformats-officedocument.wordprocessingml.template`: DOTX 文件範本格式 - `application/vnd.oasis.opendocument.text`: ODT 文件格式 - `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`: XLSX 試算表格式 - `application/vnd.ms-excel`: XLS 試算表格式 - `application/vnd.oasis.opendocument.spreadsheet`: ODS 試算表格式{
"type": "document",
"data": "BASE64_ENCODED_DOCUMENT",
"mime_type": "application/pdf"
}
**[ImageContent](/api-reference/interactions-api/get-interaction-by-id/#Resource:ImageContent)**
圖片內容區塊。 **type**: required `object` 值:`image` --- **data**: `string` 圖片內容。 --- **uri**: `string` 圖片的 URI。 ---**resolution**: `MediaResolution` 媒體的解析度。
可能值: - `low`: 低解析度。 - `medium`: 中解析度。 - `high`: 高解析度。 - `ultra_high`: 超高解析度。**mime_type**: `string enum` 圖片的 MIME 類型。
可能值: - `image/png`: PNG 圖片格式 - `image/jpeg`: JPEG 圖片格式 - `image/webp`: WebP 圖片格式 - `image/heic`: HEIC 圖片格式 - `image/heif`: HEIF 圖片格式 - `image/gif`: GIF 圖片格式 - `image/bmp`: BMP 圖片格式 - `image/tiff`: TIFF 圖片格式{
"type": "image",
"data": "BASE64_ENCODED_IMAGE",
"mime_type": "image/png"
}
**[TextContent](/api-reference/interactions-api/get-interaction-by-id/#Resource:TextContent)**
文字內容區塊。 **text**: required `string` 文字內容。 --- **type**: required `object` 值:`text` ---**annotations**: `Annotation array` 模型生成內容的引用資訊。
**可能類型**:**FileCitation**
檔案引用註記。 **type**: required `object` 值:`file_citation` **document_uri**: `string` 檔案的 URI。 **file_name**: `string` 檔案名稱。 **source**: `string` 文字某部分的出處來源。 **custom_metadata**: `object` 使用者提供的、關於所擷取上下文的中繼資料。 **page_number**: `integer` 所引用文件的頁碼(如適用)。 **media_id**: `string` 圖片引用時的媒體 ID(如適用)。 **start_index**: `integer` 回應中歸屬於此來源之片段的起始位置。索引表示片段的起點,以位元組為單位。 **end_index**: `integer` 歸屬片段的結束位置(不含該位置)。**PlaceCitation**
地點引用註記。 **type**: required `object` 值:`place_citation` **place_id**: `string` 地點的 ID,格式為 `places/{place_id}`。 **name**: `string` 地點的標題。 **url**: `string` 地點的 URI 參照。**review_snippets**: `ReviewSnippet array` 用於生成 Google 地圖中特定地點特色回答的評論片段。
**title**: `string` 評論的標題。 **url**: `string` 對應至 Google 地圖上使用者評論的連結。 **review_id**: `string` 評論片段的 ID。**SpeechAnnotation**
文字內容的語音註記。 **type**: required `object` 值:`speech_metadata` **speaker**: `string` 要與本輪對話關聯的講者。 **style**: `string` 語音合成的風格指令。 **start_index**: `integer` 回應中歸屬於此來源之片段的起始位置。索引表示片段的起點,以位元組為單位。 **end_index**: `integer` 歸屬片段的結束位置(不含該位置)。**UrlCitation**
URL 引用註記。 **type**: required `object` 值:`url_citation` **url**: `string` URL。 **title**: `string` URL 的標題。 **start_index**: `integer` 回應中歸屬於此來源之片段的起始位置。索引表示片段的起點,以位元組為單位。 **end_index**: `integer` 歸屬片段的結束位置(不含該位置)。**WordInfo**
轉錄輸出的單字級 ASR 註記。包含單字文字、可選的時間資訊,以及可選的講者歸屬。 **type**: required `object` 值:`word_info` **text**: `string` 轉錄出的單字。 **start_offset**: `string` 單字相對於音訊開頭的起始時間偏移。當 timestamp_granularities 包含「word」時才會出現。 **end_offset**: `string` 單字相對於音訊開頭的結束時間偏移。當 timestamp_granularities 包含「word」時才會出現。 **speaker**: `string` 可選。此單字的講者標籤(例如「spk_1」、「spk_2」)。當 TranscriptionConfig 中設定了 diarization_mode 時才會出現。 **start_index**: `integer` 回應中歸屬於此來源之片段的起始位置。索引表示片段的起點,以位元組為單位。 **end_index**: `integer` 歸屬片段的結束位置(不含該位置)。{
"type": "text",
"text": "Hello, how are you?"
}
**VideoContent**
影片內容區塊。 **type**: required `object` 值:`video` --- **data**: `string` 影片內容。 --- **uri**: `string` 影片的 URI。 ---**resolution**: `MediaResolution` 媒體的解析度。
可能值: - `low`: 低解析度。 - `medium`: 中解析度。 - `high`: 高解析度。 - `ultra_high`: 超高解析度。**processing**: `MediaProcessing` or `string enum` 模型如何處理此影片以進行理解。
**可能類型**:**MediaProcessing**
**type**: required `object` 值:`static` **start_offset**: `string` 可選。片段開始時間。以小數秒數表示,後接 's' 後綴,例如 "10.5s"。必須為非負數。 **end_offset**: `string` 可選。片段結束時間。以小數秒數表示,後接 's' 後綴,例如 "30s"。必須為非負數,且在設定 `start_offset` 時必須大於 `start_offset`。 **fps**: `number` 可選。影片影格率取樣密度。**string enum**
可能值: - `static`: 固定速率影格擷取。所有影格皆放入上下文。 - `agentic`: 由模型驅動的動態導覽。**mime_type**: `string enum` 影片的 MIME 類型。
可能值: - `video/mp4`: MP4 影片格式 - `video/mpeg`: MPEG 影片格式 - `video/mpg`: MPG 影片格式 - `video/mov`: MOV 影片格式 - `video/avi`: AVI 影片格式 - `video/x-flv`: FLV 影片格式 - `video/webm`: WebM 影片格式 - `video/wmv`: WMV 影片格式 - `video/3gpp`: 3GPP 影片格式{
"type": "video",
"uri": "https://www.youtube.com/watch?v=9hE5-98ZeCg"
}
Tool¶
模型可使用的工具。
多型類型:
**CodeExecution**
模型可用來執行程式碼的工具。 **type**: required `object` 值:`code_execution` **範例** === "REST"curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.8-flash",
"tools": [{
"type": "code_execution"
}],
"input": "Calculate the first 10 Fibonacci numbers"
}'
from google import genai
client = genai.Client()
response = client.interactions.create(
model="gemini-3.8-flash",
tools=[{"type": "code_execution"}],
input="Calculate the first 10 Fibonacci numbers",
)
print(response.output_text)
import {GoogleGenAI} from '@google/genai';
const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
model: 'gemini-3.8-flash',
tools: [{type: 'code_execution'}],
input: 'Calculate the first 10 Fibonacci numbers',
});
console.log(interaction.output_text);
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CodeExecution;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
Client client = new Client();
CreateModelInteraction params =
CreateModelInteraction.builder()
.model("gemini-3.8-flash")
.tools(List.of(new CodeExecution()))
.input(InteractionsInput.of("Calculate the first 10 Fibonacci numbers"))
.build();
CreateInteractionResponse response =
client.interactions.create(CreateInteractionRequestBody.of(params));
Interaction interaction =
response.interaction().orElseThrow(() -> new RuntimeException("No interaction returned"));
System.out.println(interaction.outputText().orElse(""));
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
gaos_interactions "google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
tool := gaos_interactions.NewTool(gaos_interactions.CodeExecution{})
body := operations.NewCreateInteractionRequestBody(gaos_interactions.CreateModelInteraction{
Model: gaos_interactions.Model("gemini-3.8-flash"),
Input: genai.Ptr(gaos_interactions.NewInteractionsInput("Calculate the first 10 Fibonacci numbers")),
Tools: []gaos_interactions.Tool{tool},
})
req := operations.CreateInteractionRequest{
Body: body,
}
res, err := client.Interactions.Create(ctx, req)
if err != nil {
log.Fatal(err)
}
if res.Interaction != nil && res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
**ComputerUse**
模型可用來與電腦互動的工具。 **type**: required `object` 值:`computer_use` ---**environment**: `string enum` 正在操作的環境。
可能值: - `browser`: 在網頁瀏覽器中運作。 - `mobile`: 在行動環境中運作。 - `desktop`: 在桌面環境中運作。**disabled_safety_policies**: `string enum array` 可選。電腦使用已停用的安全政策。
可能值: - `financial_transactions`: 金融交易的安全政策。 - `sensitive_data_modification`: 敏感資料修改的安全政策。 - `communication_tool`: 通訊工具(例如 Gmail、Chat、Meet)的安全政策。 - `account_creation`: 帳號建立的安全政策。 - `data_modification`: 資料修改的安全政策。 - `user_consent_management`: 使用者同意管理的安全政策。 - `legal_terms_and_agreements`: 法律條款與協議的安全政策。curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.8-flash",
"tools": [{
"type": "computer_use"
}],
"input": "Find a flight to Tokyo"
}'
from google import genai
client = genai.Client()
response = client.interactions.create(
model="gemini-3.8-flash",
tools=[{"type": "computer_use"}],
input="Find a flight to Tokyo",
)
print(response.output_text)
import {GoogleGenAI} from '@google/genai';
const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
model: 'gemini-3.8-flash',
tools: [{type: 'computer_use'}],
input: 'Find a flight to Tokyo',
});
console.log(interaction.output_text);
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.ComputerUse;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
Client client = new Client();
CreateModelInteraction params =
CreateModelInteraction.builder()
.model("gemini-3.8-flash")
.tools(List.of(new ComputerUse()))
.input(InteractionsInput.of("Find a flight to Tokyo"))
.build();
CreateInteractionResponse response =
client.interactions.create(CreateInteractionRequestBody.of(params));
Interaction interaction =
response.interaction().orElseThrow(() -> new RuntimeException("No interaction returned"));
System.out.println(interaction.outputText().orElse(""));
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
gaos_interactions "google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
tool := gaos_interactions.NewTool(gaos_interactions.ComputerUse{})
body := operations.NewCreateInteractionRequestBody(gaos_interactions.CreateModelInteraction{
Model: gaos_interactions.Model("gemini-3.8-flash"),
Input: genai.Ptr(gaos_interactions.NewInteractionsInput("Find a flight to Tokyo")),
Tools: []gaos_interactions.Tool{tool},
})
req := operations.CreateInteractionRequest{
Body: body,
}
res, err := client.Interactions.Create(ctx, req)
if err != nil {
log.Fatal(err)
}
if res.Interaction != nil && res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
**FileSearch**
模型可用來搜尋檔案的工具。 **type**: required `object` 值:`file_search` --- **file_search_store_names**: `string array` 要搜尋的檔案搜尋儲存庫名稱。 --- **top_k**: `integer` 要擷取的語意擷取區塊數量。 --- **metadata_filter**: `string` 要套用至語意擷取文件與區塊的中繼資料篩選條件。 **範例** === "REST"curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.8-flash",
"tools": [{
"type": "file_search",
"file_search_store_names": ["fileSearchStores/m64d1sevsr4y-xfyawui3fxqg"]
}],
"input": "Who is the author of the book?"
}'
from google import genai
client = genai.Client()
# Create a file search store so we have a valid one to use.
store = client.file_search_stores.create()
response = client.interactions.create(
model="gemini-3.8-flash",
tools=[
{"type": "file_search", "file_search_store_names": [store.name]}
],
input="What documents are available?",
)
print(response.output_text)
import {GoogleGenAI} from '@google/genai';
const ai = new GoogleGenAI({});
// Create a file search store so we have a valid one to use.
const store = await ai.fileSearchStores.create({});
if (!store.name) {
throw new Error('Store creation failed: Name is undefined');
}
const interaction = await ai.interactions.create({
model: 'gemini-3.8-flash',
tools: [
{
type: 'file_search',
file_search_store_names: [store.name],
},
],
input: 'What documents are available?',
});
console.log(interaction.output_text);
import com.google.genai.Client;
import com.google.genai.types.CreateFileSearchStoreConfig;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.FileSearch;
import com.google.genai.types.FileSearchStore;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
Client client = new Client();
// Create a file search store so we have a valid one to use.
FileSearchStore store =
client.fileSearchStores.create(CreateFileSearchStoreConfig.builder().build());
String storeName = store.name().orElseThrow();
FileSearch tool = FileSearch.builder().fileSearchStoreNames(List.of(storeName)).build();
CreateModelInteraction params =
CreateModelInteraction.builder()
.model("gemini-3.8-flash")
.tools(List.of(tool))
.input(InteractionsInput.of("What documents are available?"))
.build();
CreateInteractionResponse response =
client.interactions.create(CreateInteractionRequestBody.of(params));
Interaction interaction =
response.interaction().orElseThrow(() -> new RuntimeException("No interaction returned"));
System.out.println(interaction.outputText().orElse(""));
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
gaos_interactions "google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
tool := gaos_interactions.NewTool(gaos_interactions.FileSearch{
FileSearchStoreNames: []string{store.Name},
})
body := operations.NewCreateInteractionRequestBody(gaos_interactions.CreateModelInteraction{
Model: gaos_interactions.Model("gemini-3.8-flash"),
Input: genai.Ptr(gaos_interactions.NewInteractionsInput("What documents are available?")),
Tools: []gaos_interactions.Tool{tool},
})
req := operations.CreateInteractionRequest{
Body: body,
}
res, err := client.Interactions.Create(ctx, req)
if err != nil {
log.Fatal(err)
}
if res.Interaction != nil && res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
**Function**
模型可使用的工具。 **type**: required `object` 值:`function` --- **name**: `string` 函式名稱。 --- **description**: `string` 函式的說明。 --- **parameters**: `object` 函式參數的 JSON Schema。支援 JSON Schema 的子集。`minLength`、`maxLength`、`minProperties`、`maxProperties`、`uniqueItems`、`contains`、`minContains` 與 `maxContains` 會被忽略且不強制執行。 **範例** === "REST"curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.8-flash",
"tools": [{
"type": "function",
"name": "get_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": "The city and state, e.g. San Francisco, CA"
}
},
"required": ["location"]
}
}],
"input": "What is the weather like in Boston, MA?"
}'
from google import genai
client = genai.Client()
response = client.interactions.create(
model="gemini-3.8-flash",
tools=[{
"type": "function",
"name": "get_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {
"type": "string",
"description": (
"The city and state, e.g. San Francisco, CA"
),
}
},
"required": ["location"],
},
}],
input="What is the weather like in Boston?",
)
print(response.steps[-1])
import {GoogleGenAI} from '@google/genai';
const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
model: 'gemini-3.8-flash',
tools: [
{
type: 'function',
name: 'get_weather',
description: 'Get the current weather in a given location',
parameters: {
type: 'object',
properties: {
location: {
type: 'string',
description: 'The city and state, e.g. San Francisco, CA',
},
},
required: ['location'],
},
},
],
input: 'What is the weather like in Boston?',
});
console.log(interaction.steps.at(-1));
import com.google.genai.Client;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Function;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Step;
Client client = new Client();
Map<String, Object> parameters =
Map.of(
"type", "object",
"properties",
Map.of(
"location",
Map.of(
"type", "string",
"description", "The city and state, e.g. San Francisco, CA")),
"required", List.of("location"));
Function functionTool =
Function.builder()
.name("get_weather")
.description("Get the current weather in a given location")
.parameters(parameters)
.build();
CreateModelInteraction params =
CreateModelInteraction.builder()
.model("gemini-3.8-flash")
.tools(List.of(functionTool))
.input(InteractionsInput.of("What is the weather like in Boston?"))
.build();
CreateInteractionResponse response =
client.interactions.create(CreateInteractionRequestBody.of(params));
Interaction interaction =
response.interaction().orElseThrow(() -> new RuntimeException("No interaction returned"));
List<Step> steps = interaction.steps().orElse(List.of());
if (!steps.isEmpty()) {
System.out.println(steps.get(steps.size() - 1));
}
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
gaos_interactions "google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
function := gaos_interactions.Function{
Name: genai.Ptr("get_weather"),
Description: genai.Ptr("Get the current weather in a given location"),
Parameters: map[string]any{
"type": "object",
"properties": map[string]any{
"location": map[string]any{
"type": "string",
"description": "The city and state, e.g. San Francisco, CA",
},
},
"required": []string{"location"},
},
}
tool := gaos_interactions.NewTool(function)
body := operations.NewCreateInteractionRequestBody(gaos_interactions.CreateModelInteraction{
Model: gaos_interactions.Model("gemini-3.8-flash"),
Input: genai.Ptr(gaos_interactions.NewInteractionsInput("What is the weather like in Boston, MA?")),
Tools: []gaos_interactions.Tool{tool},
})
req := operations.CreateInteractionRequest{
Body: body,
}
res, err := client.Interactions.Create(ctx, req)
if err != nil {
log.Fatal(err)
}
if res.Interaction != nil {
for _, step := range res.Interaction.Steps {
if step.FunctionCallStep != nil {
fmt.Println("Function Call:", step.FunctionCallStep.Name)
fmt.Println("Arguments:", step.FunctionCallStep.Arguments)
}
}
}
}
**GoogleMaps**
模型可用來呼叫 Google 地圖的工具。 **type**: required `object` 值:`google_maps` --- **enable_widget**: `boolean` 是否在回應的工具呼叫結果中傳回小工具上下文權杖。 --- **latitude**: `number` 使用者位置的緯度。 --- **longitude**: `number` 使用者位置的經度。 **範例** === "REST"curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.8-flash",
"tools": [{
"type": "google_maps",
"latitude": 37.7749,
"longitude": -122.4194
}],
"input": "What is the best food near me?"
}'
from google import genai
client = genai.Client()
response = client.interactions.create(
model="gemini-3.8-flash",
tools=[
{"type": "google_maps", "latitude": 37.7749, "longitude": -122.4194}
],
input="What is the best food near me?",
)
print(response.output_text)
import {GoogleGenAI} from '@google/genai';
const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
model: 'gemini-3.8-flash',
tools: [
{
type: 'google_maps',
latitude: 37.7749,
longitude: -122.4194,
},
],
input: 'What is the best food near me?',
});
console.log(interaction.output_text);
import com.google.genai.Client;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.GoogleMaps;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
Client client = new Client();
GoogleMaps tool = GoogleMaps.builder().latitude(37.7749).longitude(-122.4194).build();
CreateModelInteraction params =
CreateModelInteraction.builder()
.model("gemini-3.8-flash")
.tools(List.of(tool))
.input(InteractionsInput.of("What is the best food near me?"))
.build();
CreateInteractionResponse response =
client.interactions.create(CreateInteractionRequestBody.of(params));
Interaction interaction =
response.interaction().orElseThrow(() -> new RuntimeException("No interaction returned"));
System.out.println(interaction.outputText().orElse(""));
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
gaos_interactions "google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
tool := gaos_interactions.NewTool(gaos_interactions.GoogleMaps{
Latitude: genai.Ptr(37.7749),
Longitude: genai.Ptr(-122.4194),
})
body := operations.NewCreateInteractionRequestBody(gaos_interactions.CreateModelInteraction{
Model: gaos_interactions.Model("gemini-3.8-flash"),
Input: genai.Ptr(gaos_interactions.NewInteractionsInput("What is the best food near me?")),
Tools: []gaos_interactions.Tool{tool},
})
req := operations.CreateInteractionRequest{
Body: body,
}
res, err := client.Interactions.Create(ctx, req)
if err != nil {
log.Fatal(err)
}
if res.Interaction != nil && res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
**GoogleSearch**
模型可用來搜尋 Google 的工具。 **type**: required `object` 值:`google_search` ---**search_types**: `string enum array` 要啟用的搜尋接地類型。
可能值: - `web_search`: 設定此欄位可啟用網頁搜尋。僅傳回文字結果。 - `image_search`: 設定此欄位可啟用圖片搜尋。傳回圖片位元組。curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.8-flash",
"tools": [{
"type": "google_search"
}],
"input": "Who is the current president of France?"
}'
from google import genai
client = genai.Client()
response = client.interactions.create(
model="gemini-3.8-flash",
tools=[{"type": "google_search"}],
input="Who is the current president of France?",
)
print(response.output_text)
import {GoogleGenAI} from '@google/genai';
const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
model: 'gemini-3.8-flash',
tools: [{type: 'google_search'}],
input: 'Who is the current president of France?',
});
console.log(interaction.output_text);
import com.google.genai.Client;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.GoogleSearch;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
Client client = new Client();
CreateModelInteraction params =
CreateModelInteraction.builder()
.model("gemini-3.8-flash")
.tools(List.of(new GoogleSearch()))
.input(InteractionsInput.of("Who is the current president of France?"))
.build();
CreateInteractionResponse response =
client.interactions.create(CreateInteractionRequestBody.of(params));
Interaction interaction =
response.interaction().orElseThrow(() -> new RuntimeException("No interaction returned"));
System.out.println(interaction.outputText().orElse(""));
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
gaos_interactions "google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
tool := gaos_interactions.NewTool(gaos_interactions.GoogleSearch{})
body := operations.NewCreateInteractionRequestBody(gaos_interactions.CreateModelInteraction{
Model: gaos_interactions.Model("gemini-3.8-flash"),
Input: genai.Ptr(gaos_interactions.NewInteractionsInput("Who is the current president of France?")),
Tools: []gaos_interactions.Tool{tool},
})
req := operations.CreateInteractionRequest{
Body: body,
}
res, err := client.Interactions.Create(ctx, req)
if err != nil {
log.Fatal(err)
}
if res.Interaction != nil && res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
**McpServer**
MCPServer 是可供模型呼叫以執行動作的伺服器。 **type**: required `object` 值:`mcp_server` --- **name**: `string` MCPServer 的名稱。 --- **url**: `string` MCPServer 端點的完整 URL。範例:「https://api.example.com/mcp」 --- **headers**: `object` 可選:如有需要,提供驗證標頭、逾時等欄位。 ---**allowed_tools**: `AllowedTools array` 允許的工具。
**mode**: `string enum` 工具選擇的模式。
可能值: - `auto`: 自動工具選擇。 - `any`: 任意工具選擇。 - `none`: 不使用工具選擇。 - `validated`: 已驗證的工具選擇。curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.8-flash",
"tools": [{
"type": "mcp_server",
"name": "weather_service",
"url": "https://gemini-api-demos.uc.r.appspot.com/mcp"
}],
"input": "Today is 12-05-2025, what is the temperature today in London?"
}'
import os
from google import genai
client = genai.Client()
response = client.interactions.create(
model="gemini-3.8-flash",
tools=[{
"type": "mcp_server",
"name": "weather_service",
"url": "https://gemini-api-demos.uc.r.appspot.com/mcp",
}],
input="Today is 12-05-2025, what is the temperature today in London?",
)
print(response.output_text)
import {GoogleGenAI} from '@google/genai';
const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
model: 'gemini-3.8-flash',
tools: [
{
type: 'mcp_server',
name: 'weather_service',
url: 'https://gemini-api-demos.uc.r.appspot.com/mcp',
},
],
input: 'Today is 12-05-2025, what is the temperature today in London?',
});
console.log(interaction.output_text);
import com.google.genai.Client;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.MCPServer;
Client client = new Client();
MCPServer mcpTool =
MCPServer.builder()
.name("weather_service")
.url("https://gemini-api-demos.uc.r.appspot.com/mcp")
.build();
CreateModelInteraction params =
CreateModelInteraction.builder()
.model("gemini-3.8-flash")
.tools(List.of(mcpTool))
.input(
InteractionsInput.of(
"Today is 12-05-2025, what is the temperature today in London?"))
.build();
CreateInteractionResponse response =
client.interactions.create(CreateInteractionRequestBody.of(params));
Interaction interaction =
response.interaction().orElseThrow(() -> new RuntimeException("No interaction returned"));
System.out.println(interaction.outputText().orElse(""));
package main
import (
"context"
"fmt"
"log"
"os"
"google.golang.org/genai"
gaos_interactions "google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
mcpServer := gaos_interactions.MCPServer{
Name: genai.Ptr("weather_service"),
URL: genai.Ptr("https://gemini-api-demos.uc.r.appspot.com/mcp"),
}
tool := gaos_interactions.NewTool(mcpServer)
body := operations.NewCreateInteractionRequestBody(gaos_interactions.CreateModelInteraction{
Model: gaos_interactions.Model("gemini-3.8-flash"),
Input: genai.Ptr(gaos_interactions.NewInteractionsInput("Today is 12-05-2025, what is the temperature today in London?")),
Tools: []gaos_interactions.Tool{tool},
})
req := operations.CreateInteractionRequest{
Body: body,
}
res, err := client.Interactions.Create(ctx, req)
if err != nil {
log.Fatal(err)
}
if res.Interaction != nil && res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
**UrlContext**
模型可用來擷取 URL 上下文的工具。 **type**: required `object` 值:`url_context` **範例** === "REST"curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.8-flash",
"tools": [{
"type": "url_context"
}],
"input": "Summarize https://www.example.com"
}'
from google import genai
client = genai.Client()
response = client.interactions.create(
model="gemini-3.8-flash",
tools=[{"type": "url_context"}],
input="Summarize https://www.example.com",
)
print(response.output_text)
import {GoogleGenAI} from '@google/genai';
const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
model: 'gemini-3.8-flash',
tools: [{type: 'url_context'}],
input: 'Summarize https://www.example.com',
});
console.log(interaction.output_text);
import com.google.genai.Client;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.URLContext;
Client client = new Client();
CreateModelInteraction params =
CreateModelInteraction.builder()
.model("gemini-3.8-flash")
.tools(List.of(new URLContext()))
.input(InteractionsInput.of("Summarize https://www.example.com"))
.build();
CreateInteractionResponse response =
client.interactions.create(CreateInteractionRequestBody.of(params));
Interaction interaction =
response.interaction().orElseThrow(() -> new RuntimeException("No interaction returned"));
System.out.println(interaction.outputText().orElse(""));
package main
import (
"context"
"fmt"
"log"
"google.golang.org/genai"
gaos_interactions "google.golang.org/genai/interactions/models/interactions"
"google.golang.org/genai/interactions/models/operations"
)
func main() {
ctx := context.Background()
client, err := genai.NewClient(ctx, nil)
if err != nil {
log.Fatal(err)
}
tool := gaos_interactions.NewTool(gaos_interactions.URLContext{})
body := operations.NewCreateInteractionRequestBody(gaos_interactions.CreateModelInteraction{
Model: gaos_interactions.Model("gemini-3.8-flash"),
Input: genai.Ptr(gaos_interactions.NewInteractionsInput("Summarize https://www.example.com")),
Tools: []gaos_interactions.Tool{tool},
})
req := operations.CreateInteractionRequest{
Body: body,
}
res, err := client.Interactions.Create(ctx, req)
if err != nil {
log.Fatal(err)
}
if res.Interaction != nil && res.Interaction.OutputText != nil {
fmt.Println(*res.Interaction.OutputText)
}
}
ResponseFormat¶
多型類型:
**AudioResponseFormat**
音訊輸出格式的設定。 **type**: required `object` 值:`audio` ---**mime_type**: `string enum` 音訊輸出的 MIME 類型。
可能值: - `audio/mp3`: MP3 音訊格式。 - `audio/ogg_opus`: OGG Opus 音訊格式。 - `audio/l16`: 原始 PCM(L16)音訊格式。 - `audio/wav`: WAV 音訊格式。 - `audio/alaw`: A-law 音訊格式。 - `audio/mulaw`: Mu-law 音訊格式。**delivery**: `string enum` 音訊輸出的傳遞模式。
可能值: - `inline`: 音訊資料以行內方式在回應中傳回。 - `uri`: 音訊資料以 URI 形式傳回。{
"type": "audio",
"sample_rate": 24000
}
**ImageResponseFormat**
圖片輸出格式的設定。 **type**: required `object` 值:`image` ---**mime_type**: `string enum` 圖片輸出的 MIME 類型。
可能值: - `image/jpeg`: JPEG 圖片格式。**delivery**: `string enum` 圖片輸出的傳遞模式。
可能值: - `inline`: 圖片資料以行內方式在回應中傳回。 - `uri`: 圖片資料以 URI 形式傳回。**aspect_ratio**: `string enum` 圖片輸出的長寬比。
可能值: - `1:1`: 1:1 長寬比。 - `2:3`: 2:3 長寬比。 - `3:2`: 3:2 長寬比。 - `3:4`: 3:4 長寬比。 - `4:3`: 4:3 長寬比。 - `4:5`: 4:5 長寬比。 - `5:4`: 5:4 長寬比。 - `9:16`: 9:16 長寬比。 - `16:9`: 16:9 長寬比。 - `21:9`: 21:9 長寬比。 - `1:8`: 1:8 長寬比。 - `8:1`: 8:1 長寬比。 - `1:4`: 1:4 長寬比。 - `4:1`: 4:1 長寬比。**image_size**: `string enum` 圖片輸出的尺寸。
可能值: - `512`: 512px 圖片尺寸。 - `1K`: 1K 圖片尺寸。 - `2K`: 2K 圖片尺寸。 - `4K`: 4K 圖片尺寸。{
"type": "image",
"aspect_ratio": "16:9",
"image_size": "1K",
"mime_type": "image/jpeg"
}
**TextResponseFormat**
文字輸出格式的設定。 **type**: required `object` 值:`text` ---**mime_type**: `string enum` 文字輸出的 MIME 類型。
可能值: - `application/json`: JSON 輸出格式。 - `text/plain`: 純文字輸出格式。{
"type": "text",
"mime_type": "application/json",
"schema": {
"type": "object",
"properties": {
"ingredients": {
"type": "array",
"items": {
"type": "string"
}
},
"recipe_name": {
"type": "string"
}
},
"required": [
"ingredients",
"recipe_name"
]
}
}
**VideoResponseFormat**
影片輸出格式的設定。 **type**: required `object` 值:`video` ---**delivery**: `string enum` 影片輸出的傳遞模式。
可能值: - `inline`: 影片資料以行內方式在回應中傳回。 - `uri`: 影片資料以 URI 形式傳回。**aspect_ratio**: `string enum` 影片輸出的長寬比。
可能值: - `16:9`: 16:9 長寬比。 - `9:16`: 9:16 長寬比。**resolution**: `string enum` 影片輸出解析度。預設為 720p。
可能值: - `360p`: 360p 解析度。 - `720p`: 720p 解析度。 - `1080p`: 1080p 解析度。 - `4k`: 4K 解析度。{
"type": "video",
"aspect_ratio": "16:9",
"delivery": "inline"
}
Step¶
互動中的一個步驟。
多型類型:
**CodeExecutionCallStep**
程式碼執行呼叫步驟。**arguments**: required `CodeExecutionCallStepArguments` 要傳遞給程式碼執行的引數。
**language**: `string enum` `code` 的程式語言。
可能值: - `python`: Python >= 3.10,可使用 numpy 與 simpy。 - `bash`: Bash。僅適用於 Gemini 3.0 以上模型。{
"type": "code_execution_call",
"arguments": {
"code": "print(sum(range(1, 11)))"
},
"id": "code_call_71021"
}
**CodeExecutionResultStep**
程式碼執行結果步驟。**result**: required [`Content`](/api-reference/interactions-api/get-interaction-by-id/#Resource:Content) `array` or `string` 程式碼執行的輸出。
**可能類型**:**[Content](/api-reference/interactions-api/get-interaction-by-id/#Resource:Content) array**
清單的內容。**string**
直接的字串值。{
"type": "code_execution_result",
"call_id": "code_call_71021",
"result": "55\n"
}
**FileSearchCallStep**
File Search 呼叫步驟。 **id**: required `string` 此特定工具呼叫的唯一 ID。 --- **type**: required `object` 值:`file_search_call` --- **signature**: `string` 供後端驗證的簽章雜湊。 **範例** **FileSearchCallStep**{
"type": "file_search_call",
"id": "file_call_88192"
}
**FileSearchResultStep**
File Search 結果步驟。 **call_id**: required `string` 用來與函式呼叫區塊中的 ID 對應的 ID。 --- **type**: required `object` 值:`file_search_result` --- **signature**: `string` 供後端驗證的簽章雜湊。 **範例** **FileSearchResultStep**{
"type": "file_search_result",
"call_id": "file_call_88192"
}
**FunctionCallStep**
函式工具呼叫步驟。 **name**: required `string` 要呼叫的工具名稱。 --- **arguments**: required `object` 要傳遞給函式的引數。 --- **id**: required `string` 此特定工具呼叫的唯一 ID。 --- **type**: required `object` 值:`function_call` **範例** **FunctionCallStep**{
"name": "get_weather",
"type": "function_call",
"arguments": {
"location": "Boston, MA"
},
"id": "call_98231"
}
**FunctionResultStep**
函式工具呼叫的結果。**result**: required `(`[`ImageContent`](/api-reference/interactions-api/get-interaction-by-id/#Resource:ImageContent) or [`TextContent`](/api-reference/interactions-api/get-interaction-by-id/#Resource:TextContent)`) array` or `object` or `string` 工具呼叫的結果。
**可能類型**:**([ImageContent](/api-reference/interactions-api/get-interaction-by-id/#Resource:ImageContent) or [TextContent](/api-reference/interactions-api/get-interaction-by-id/#Resource:TextContent)) array**
清單中的每個項目為下列其中之一:[`ImageContent`](/api-reference/interactions-api/get-interaction-by-id/#Resource:ImageContent)、[`TextContent`](/api-reference/interactions-api/get-interaction-by-id/#Resource:TextContent)。**string**
直接的字串值。{
"name": "get_weather",
"type": "function_result",
"call_id": "call_98231",
"result": [
{
"type": "text",
"text": "{\"weather\":\"sunny\"}"
}
]
}
**GoogleMapsCallStep**
Google 地圖呼叫步驟。 **id**: required `string` 此特定工具呼叫的唯一 ID。 --- **type**: required `object` 值:`google_maps_call` ---**arguments**: `GoogleMapsCallStepArguments` 要傳遞給 Google 地圖工具的引數。
**queries**: `string array` 要執行的查詢。{
"type": "google_maps_call",
"arguments": {
"latitude": 37.7749,
"longitude": -122.4194
},
"id": "maps_call_39201"
}
**GoogleMapsResultStep**
Google 地圖結果步驟。**result**: required `GoogleMapsResultItem array`
**places**: `GoogleMapsResultPlaces array`
**place_id**: `string` **name**: `string` **url**: `string`**review_snippets**: `ReviewSnippet array`
**title**: `string` 評論的標題。 **url**: `string` 對應至 Google 地圖上使用者評論的連結。 **review_id**: `string` 評論片段的 ID。{
"type": "google_maps_result",
"call_id": "maps_call_39201",
"result": [
{
"name": "Golden Gate Park",
"place_id": "ChIJIQBpAG2ahYAR9R7bNdTLg8M",
"rating": 4.8
}
]
}
**GoogleSearchCallStep**
Google 搜尋呼叫步驟。**arguments**: required `GoogleSearchCallStepArguments` 要傳遞給 Google 搜尋的引數。
**queries**: `string array` 後續網頁搜尋的網頁搜尋查詢。**search_type**: `string enum` 所啟用的搜尋接地類型。
可能值: - `web_search`: 設定此欄位可啟用網頁搜尋。僅傳回文字結果。 - `image_search`: 設定此欄位可啟用圖片搜尋。傳回圖片位元組。{
"type": "google_search_call",
"arguments": {
"query": "Who won the men's 100m in Paris 2024?"
},
"id": "search_call_19201"
}
**GoogleSearchResultStep**
Google 搜尋結果步驟。**result**: required `GoogleSearchResultItem array` Google 搜尋的結果。
**search_suggestions**: `string` 可嵌入網頁或應用程式 webview 的網頁內容片段。{
"type": "google_search_result",
"call_id": "search_call_19201",
"result": [
{
"title": "Paris 2024 Olympics: Noah Lyles wins men's 100m gold",
"url": "https://olympics.com/en/news/paris-2024-noah-lyles-wins-mens-100m-gold",
"snippet": "American Noah Lyles won the Olympic men's 100m gold medal in a photo finish."
}
]
}
**McpServerToolCallStep**
MCPServer 工具呼叫步驟。 **name**: required `string` 被呼叫的工具名稱。 --- **server_name**: required `string` 所使用的 MCP 伺服器名稱。 --- **arguments**: required `object` 函式引數的 JSON 物件。 --- **id**: required `string` 此特定工具呼叫的唯一 ID。 --- **type**: required `object` 值:`mcp_server_tool_call` **範例** **McpServerToolCallStep**{
"name": "calculate_tax",
"type": "mcp_server_tool_call",
"arguments": {
"income": 120000,
"state": "CA"
},
"id": "mcp_call_29012",
"server_name": "financial_mcp_server"
}
**McpServerToolResultStep**
MCPServer 工具結果步驟。**result**: required `(`[`ImageContent`](/api-reference/interactions-api/get-interaction-by-id/#Resource:ImageContent) or [`TextContent`](/api-reference/interactions-api/get-interaction-by-id/#Resource:TextContent)`) array` or `object` or `string` MCP 伺服器呼叫的輸出。可以是簡單文字或豐富內容。
**可能類型**:**([ImageContent](/api-reference/interactions-api/get-interaction-by-id/#Resource:ImageContent) or [TextContent](/api-reference/interactions-api/get-interaction-by-id/#Resource:TextContent)) array**
清單中的每個項目為下列其中之一:[`ImageContent`](/api-reference/interactions-api/get-interaction-by-id/#Resource:ImageContent)、[`TextContent`](/api-reference/interactions-api/get-interaction-by-id/#Resource:TextContent)。**string**
直接的字串值。{
"name": "calculate_tax",
"type": "mcp_server_tool_result",
"call_id": "mcp_call_29012",
"result": {
"tax_due": 32400
},
"server_name": "financial_mcp_server"
}
**ModelOutputStep**
模型生成的輸出。 **type**: required `object` 值:`model_output` --- **content**: [`Content`](/api-reference/interactions-api/get-interaction-by-id/#Resource:Content) `array` **範例** **ModelOutputStep**{
"type": "model_output",
"content": [
{
"type": "text",
"text": "The capital of France is Paris."
}
]
}
**ProcessingCallStep**
伺服器發起的處理步驟,用於媒體分析(例如影片 理解)。 **id**: required `string` 此特定工具呼叫的唯一 ID。 --- **type**: required `object` 值:`processing_call` --- **signature**: `string` 供後端驗證的簽章雜湊。**ProcessingResultStep**
伺服器發起的媒體處理步驟的結果。 **call_id**: required `string` 用來與函式呼叫區塊中的 ID 對應的 ID。 --- **type**: required `object` 值:`processing_result` --- **signature**: `string` 供後端驗證的簽章雜湊。**ThoughtStep**
思考步驟。 **type**: required `object` 值:`thought` --- **signature**: `string` 供後端驗證的簽章雜湊。 --- **summary**: [`Content`](/api-reference/interactions-api/get-interaction-by-id/#Resource:Content) `array` 思考的摘要。 **範例** **ThoughtStep**{
"type": "thought",
"signature": "thought_sig_abcd1234",
"summary": [
{
"type": "text",
"text": "The model is searching Google for the capital of France."
}
]
}
**UrlContextCallStep**
URL 上下文呼叫步驟。**arguments**: required `UrlContextCallArguments` 要傳遞給 URL 上下文的引數。
**urls**: `string array` 要擷取的 URL。{
"type": "url_context_call",
"arguments": {
"urls": [
"https://www.example.com"
]
},
"id": "url_call_10219"
}
**UrlContextResultStep**
URL 上下文結果步驟。**result**: required `UrlContextResult array` URL 上下文的結果。
**url**: `string` 被擷取的 URL。**status**: `string enum` URL 擷取的狀態。
可能值: - `success`: URL 擷取成功。 - `error`: URL 擷取因錯誤而失敗。 - `paywall`: URL 擷取失敗,因為內容位於付費牆後方。 - `unsafe`: URL 擷取失敗,因為內容不安全。{
"type": "url_context_result",
"call_id": "url_call_10219",
"result": [
{
"title": "Example Domain",
"url": "https://www.example.com",
"snippet": "This domain is for use in illustrative examples in documents."
}
]
}
**UserInputStep**
使用者提供的輸入。 **type**: required `object` 值:`user_input` --- **content**: [`Content`](/api-reference/interactions-api/get-interaction-by-id/#Resource:Content) `array` **範例** **UserInputStep**{
"type": "user_input",
"content": [
{
"type": "text",
"text": "What is the capital of France?"
}
]
}
EnvironmentConfig¶
自訂環境的設定。
屬性:
type: required object
值:remote
**sources**: `Source array`
**type**: `string enum`
可能值: - `gcs`: Cloud Storage 值區。 - `inline`: 行內內容。 - `repository`: 一般儲存庫。來源 URL 中的通訊協定前綴可識別提供者(例如 github://、gcs://)。**network**: [`EnvironmentNetworkEgressAllowlist`](/api-reference/interactions-api/get-interaction-by-id/#Resource:EnvironmentNetworkEgressAllowlist) or `string enum` 環境的網路設定。
**可能類型**:**[EnvironmentNetworkEgressAllowlist](/api-reference/interactions-api/get-interaction-by-id/#Resource:EnvironmentNetworkEgressAllowlist)**
環境的網路輸出流量設定。**allowlist**: `EgressRule array` or `string enum` 允許的網域及其設定清單。設為 `"disabled"` 可封鎖所有網路輸出流量。
**可能類型**:**EgressRule array**
單一網域允許清單規則,可選擇性注入標頭。 **domain**: required `string` 允許對外請求的網域。支援萬用字元(例如 '*.googleapis.com')。使用 '*' 可允許所有網域。 **transform**: `object` 要注入至符合此規則之請求的標頭。鍵:標頭名稱(例如「Authorization」)。值:標頭值(例如「Bearer your-token」)。 **credential**: `string` 可選。以 ID 參照伺服器管理的 Credential 資源。**string enum**
可能值: - `disabled`: 所有網路輸出流量皆被封鎖。**string enum**
可能值: - `disabled`: 所有網路輸出流量皆被封鎖。environment_id: string
可選。互動的環境 ID。若指定,請求將更新現有環境,而非建立新環境。
**env**: `object` or `string` 要在沙箱環境中設定的環境變數。
**可能類型**:**string**
直接的字串值。**mode**: `string enum` 此環境的運算生命週期模式。
可能值: - `on_demand`: 此環境的運算生命週期模式。 - `self_hosted`: 此環境的運算生命週期模式。custom_config: object
可選。任意的客戶自訂 JSON 設定,會直接傳遞給自行託管環境的輪詢器。僅在 mode 為 SELF_HOSTED 時支援。
範例
{
"type": "remote",
"sources": [
{
"type": "inline",
"content": "You are a data analyst. Always include visualizations and export results as PDF.",
"target": ".agents/AGENTS.md"
},
{
"type": "inline",
"content": "---\nname: slide-maker\ndescription: Create HTML slide decks\n---\n# Slide Maker\n\nWhen asked to create a presentation:\n1. Analyze the input data\n2. Create an HTML slide deck with reveal.js\n3. Save to /workspace/output/slides.html",
"target": ".agents/skills/slide-maker/SKILL.md"
}
]
}
{
"type": "remote",
"sources": [
{
"type": "repository",
"source": "https://github.com/my-org/my-skills.git",
"target": ".agents/skills"
},
{
"type": "gcs",
"source": "gs://my-bucket/my-folder",
"target": "/workspace/data"
}
]
}
{
"type": "remote",
"network": {
"allowlist": [
{
"domain": "pypi.org"
},
{
"domain": "*.github.com"
}
]
}
}
{
"type": "remote",
"network": {
"allowlist": [
{
"domain": "api.github.com",
"transform": {
"Authorization": "Bearer YOUR_GITHUB_TOKEN"
}
}
]
}
}
EnvironmentNetworkEgressAllowlist¶
環境的網路輸出流量設定。
屬性:
**allowlist**: `EgressRule array` or `string enum` 允許的網域及其設定清單。設為 `"disabled"` 可封鎖所有網路輸出流量。
**可能類型**:**EgressRule array**
單一網域允許清單規則,可選擇性注入標頭。 **domain**: required `string` 允許對外請求的網域。支援萬用字元(例如 '*.googleapis.com')。使用 '*' 可允許所有網域。 **transform**: `object` 要注入至符合此規則之請求的標頭。鍵:標頭名稱(例如「Authorization」)。值:標頭值(例如「Bearer your-token」)。 **credential**: `string` 可選。以 ID 參照伺服器管理的 Credential 資源。**string enum**
可能值: - `disabled`: 所有網路輸出流量皆被封鎖。範例
網路允許清單
{
"allowlist": [
{
"domain": "github.com",
"transform": [
{
"Authorization": "Bearer your-token"
}
]
},
{
"domain": "*.googleapis.com"
}
]
}
ToolChoiceConfig¶
包含允許工具的工具選擇設定。
屬性:
**allowed_tools**: `AllowedTools` 允許的工具。
**mode**: `string enum` 工具選擇的模式。
可能值: - `auto`: 自動工具選擇。 - `any`: 任意工具選擇。 - `none`: 不使用工具選擇。 - `validated`: 已驗證的工具選擇。範例
{
"allowed_tools": {
"mode": "any",
"tools": [
"my_tool"
]
}
}
ImageContent¶
圖片內容區塊。
屬性:
type: required object
值:image
data: string
圖片內容。
uri: string
圖片的 URI。
**resolution**: `MediaResolution` 媒體的解析度。
可能值: - `low`: 低解析度。 - `medium`: 中解析度。 - `high`: 高解析度。 - `ultra_high`: 超高解析度。**mime_type**: `string enum` 圖片的 MIME 類型。
可能值: - `image/png`: PNG 圖片格式 - `image/jpeg`: JPEG 圖片格式 - `image/webp`: WebP 圖片格式 - `image/heic`: HEIC 圖片格式 - `image/heif`: HEIF 圖片格式 - `image/gif`: GIF 圖片格式 - `image/bmp`: BMP 圖片格式 - `image/tiff`: TIFF 圖片格式範例
圖片
{
"type": "image",
"data": "BASE64_ENCODED_IMAGE",
"mime_type": "image/png"
}
TextContent¶
文字內容區塊。
屬性:
text: required string
文字內容。
type: required object
值:text
**annotations**: `Annotation array` 模型生成內容的引用資訊。
**可能類型**:**FileCitation**
檔案引用註記。 **type**: required `object` 值:`file_citation` **document_uri**: `string` 檔案的 URI。 **file_name**: `string` 檔案名稱。 **source**: `string` 文字某部分的出處來源。 **custom_metadata**: `object` 使用者提供的、關於所擷取上下文的中繼資料。 **page_number**: `integer` 所引用文件的頁碼(如適用)。 **media_id**: `string` 圖片引用時的媒體 ID(如適用)。 **start_index**: `integer` 回應中歸屬於此來源之片段的起始位置。索引表示片段的起點,以位元組為單位。 **end_index**: `integer` 歸屬片段的結束位置(不含該位置)。**PlaceCitation**
地點引用註記。 **type**: required `object` 值:`place_citation` **place_id**: `string` 地點的 ID,格式為 `places/{place_id}`。 **name**: `string` 地點的標題。 **url**: `string` 地點的 URI 參照。**review_snippets**: `ReviewSnippet array` 用於生成 Google 地圖中特定地點特色回答的評論片段。
**title**: `string` 評論的標題。 **url**: `string` 對應至 Google 地圖上使用者評論的連結。 **review_id**: `string` 評論片段的 ID。**SpeechAnnotation**
文字內容的語音註記。 **type**: required `object` 值:`speech_metadata` **speaker**: `string` 要與本輪對話關聯的講者。 **style**: `string` 語音合成的風格指令。 **start_index**: `integer` 回應中歸屬於此來源之片段的起始位置。索引表示片段的起點,以位元組為單位。 **end_index**: `integer` 歸屬片段的結束位置(不含該位置)。**UrlCitation**
URL 引用註記。 **type**: required `object` 值:`url_citation` **url**: `string` URL。 **title**: `string` URL 的標題。 **start_index**: `integer` 回應中歸屬於此來源之片段的起始位置。索引表示片段的起點,以位元組為單位。 **end_index**: `integer` 歸屬片段的結束位置(不含該位置)。**WordInfo**
轉錄輸出的單字級 ASR 註記。包含單字文字、可選的時間資訊,以及可選的講者歸屬。 **type**: required `object` 值:`word_info` **text**: `string` 轉錄出的單字。 **start_offset**: `string` 單字相對於音訊開頭的起始時間偏移。當 timestamp_granularities 包含「word」時才會出現。 **end_offset**: `string` 單字相對於音訊開頭的結束時間偏移。當 timestamp_granularities 包含「word」時才會出現。 **speaker**: `string` 可選。此單字的講者標籤(例如「spk_1」、「spk_2」)。當 TranscriptionConfig 中設定了 diarization_mode 時才會出現。 **start_index**: `integer` 回應中歸屬於此來源之片段的起始位置。索引表示片段的起點,以位元組為單位。 **end_index**: `integer` 歸屬片段的結束位置(不含該位置)。範例
文字
{
"type": "text",
"text": "Hello, how are you?"
}