o
    pkj)                    @   s  d Z ddlmZmZ ddlmZmZmZmZ ddl	m
Z
mZmZ ddlmZmZmZmZ ddlmZmZ ddlmZmZ ddlmZ d	d
lZd	dlmZmZmZmZmZmZm Z m!Z!m"Z" G dd deZ#G dd dZ$G dd dZ%G dd deZ&G dd dZ'G dd dZ(d
S )zACode generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.   )AsyncBaseSDKBaseSDK)errorsmodelstypesutils)AfterParseErrorContextHookContextResponseContext)	BaseModelOptionalNullableUNSETinteractions)get_security_from_envresponse_helpers)AsyncStreamStream)unmarshal_json_response    N)	AnyDictListLiteralMappingOptionalUnioncastoverloadc                1   @   ~  e Zd Zedd Zedd Zeddddddeej	ej
f deeeef  d	eeeef  d
eeeef  deeeejf  deejeej f fddZeddddddddddddddddddddddee dedejdejdejdeeef dejdedejdedeej deej  dej!dedee"d  df d!ed"eej# d#ej$deeeef  d	eeeef  d
eeeef  deeeejf  dejf.d$dZedddddddddddddddddddd%dee dedejdejdejdeeef dejdedejdedeej deej  dej!dede"d& d!ed"eej# d#ej$deeeef  d	eeeef  d
eeeef  deeeejf  deej f.d'dZeddddddddddddddddddddd(dee d)ej%d*ej&dedej'dejdeeef dedej(dedeej deej  dej!dedee"d  df d!ed"eej# d#ej$deeeef  d	eeeef  d
eeeef  deeeejf  dejf.d+dZedddddddddddddddddddd,dee d)ej%d*ej&dedej'dejdeeef dedej(dedeej deej  dej!dede"d& d!ed"eej# d#ej$deeeef  d	eeeef  d
eeeef  deeeejf  deej f.d-dZee)e)ddddd.de*eej	ej
f  de*e deeeef  d	eeeef  d
eeeef  deeeejf  d/edeejeej f fd0dZe)e)ddddd.de*eej	ej
f  de*e deeeef  d	eeeef  d
eeeef  deeeejf  d/edeejeej f fd1dZddddd2d3edee deeeef  d	eeeef  deeeejf  f
d4d5Z+edd dddddd6d3edee d7ee d8ee dee"d  df deeeef  d	eeeef  deeeejf  dejfd9d:Z,edd ddddd;d3edee d7ee d8ee de"d& deeeef  d	eeeef  deeeejf  deej fd<d:Z,edd ddddd;d3edee d7ee d8ee dedeeeef  d	eeeef  deeeejf  deejeej f fd=d:Z,dd dd dddd6d3edee d7ee d8ee dee deeeef  d	eeeef  deeeejf  deejeej f fd>d:Z,ddddd2d3edee deeeef  d	eeeef  deeeejf  dejfd?d@Z-dS )AInteractionsc                 C      t | S N)InteractionsWithRawResponseself r%   ]/home/djax/ivt_ai_plugin/venv/lib/python3.10/site-packages/google/genai/_gaos/interactions.pywith_raw_response      zInteractions.with_raw_responsec                 C   r    r!   )!InteractionsWithStreamingResponser#   r%   r%   r&   with_streaming_response#   r(   z$Interactions.with_streaming_responseNextra_headersextra_query
extra_bodytimeoutrequestr,   r-   r.   r/   returnc                C      dS a  Creating an interaction

        Creates a new interaction.

        :param body: The request body.
        :param api_version: Which version of the API to use.
        :param extra_headers: Additional headers to set or replace on requests.
        :param extra_query: Additional query parameters to append to requests.
        :param extra_body: Additional JSON object fields to merge into request bodies.
        :param timeout: Override the default request timeout configuration for this method in seconds
        Nr%   r$   r0   r,   r-   r.   r/   r%   r%   r&   create'       zInteractions.create.api_version
backgroundenvironmentgeneration_configlabelsprevious_interaction_idresponse_formatresponse_mime_typeresponse_modalitiessafety_settingsservice_tierstorestreamsystem_instructiontoolswebhook_configr,   r-   r.   r/   r8   r9   r:   r;   inputr<   modelr=   r>   r?   r@   rA   rB   rC   rD   FrE   rF   rG   c                C   r2   a#  Creating an interaction

        Creates a new interaction.

        :param api_version: Which version of the API to use.
        :param background: Input only. Whether to run the model interaction in the background.
        :param environment: The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID.
        :param generation_config: Configuration parameters for model interactions.
        :param input: The input for the interaction.
        :param labels: The labels with user-defined metadata for the request.
        :param model: The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details.
        :param previous_interaction_id: The ID of the previous interaction, if any.
        :param response_format: Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field.
        :param response_mime_type: The mime type of the response. This is required if response_format is set.
        :param response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO).
        :param safety_settings: Safety settings for the interaction.
        :param service_tier:
        :param store: Input only. Whether to store the response and request for later retrieval.
        :param stream: Input only. Whether the interaction will be streamed.
        :param system_instruction: System instruction for the interaction.
        :param tools: A list of tool declarations the model may call during interaction.
        :param webhook_config: Message for configuring webhook events for a request.
        :param extra_headers: Additional headers to set or replace on requests.
        :param extra_query: Additional query parameters to append to requests.
        :param extra_body: Additional JSON object fields to merge into request bodies.
        :param timeout: Override the default request timeout configuration for this method in seconds
        Nr%   r$   r8   r9   r:   r;   rH   r<   rI   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   r,   r-   r.   r/   r%   r%   r&   r5   ?   r6   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rE   rF   rG   r,   r-   r.   r/   Tc                C   r2   rJ   r%   rK   r%   r%   r&   r5   v   r6   r8   agent_configr9   r:   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   r,   r-   r.   r/   agentrN   c                C   r2   a  Creating an interaction

        Creates a new interaction.

        :param api_version: Which version of the API to use.
        :param agent: The agent to interact with.
        :param agent_config: Configuration parameters for the agent interaction.
        :param background: Input only. Whether to run the model interaction in the background.
        :param environment: The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID.
        :param input: The input for the interaction.
        :param labels: The labels with user-defined metadata for the request.
        :param previous_interaction_id: The ID of the previous interaction, if any.
        :param response_format: Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field.
        :param response_mime_type: The mime type of the response. This is required if response_format is set.
        :param response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO).
        :param safety_settings: Safety settings for the interaction.
        :param service_tier:
        :param store: Input only. Whether to store the response and request for later retrieval.
        :param stream: Input only. Whether the interaction will be streamed.
        :param system_instruction: System instruction for the interaction.
        :param tools: A list of tool declarations the model may call during interaction.
        :param webhook_config: Message for configuring webhook events for a request.
        :param extra_headers: Additional headers to set or replace on requests.
        :param extra_query: Additional query parameters to append to requests.
        :param extra_body: Additional JSON object fields to merge into request bodies.
        :param timeout: Override the default request timeout configuration for this method in seconds
        Nr%   r$   r8   rO   rN   r9   r:   rH   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   r,   r-   r.   r/   r%   r%   r&   r5      r6   r8   rN   r9   r:   r<   r=   r>   r?   r@   rA   rB   rC   rE   rF   rG   r,   r-   r.   r/   c                C   r2   rP   r%   rQ   r%   r%   r&   r5      r6   r0   r8   r,   r-   r.   r/   body_kwargsc                K   r2     Creating an interaction

        Creates a new interaction.

        :param api_version: Which version of the API to use.
        :param background: Input only. Whether to run the model interaction in the background.
        :param environment: The environment configuration for the interaction. Can be an object specifying remote environment sources or a string referencing an existing environment ID.
        :param generation_config: Configuration parameters for model interactions.
        :param input: The input for the interaction.
        :param labels: The labels with user-defined metadata for the request.
        :param model: The model that will complete your prompt.\n\nSee [models](https://ai.google.dev/gemini-api/docs/models) for additional details.
        :param previous_interaction_id: The ID of the previous interaction, if any.
        :param response_format: Enforces that the generated response is a JSON object that complies with the JSON schema specified in this field.
        :param response_mime_type: The mime type of the response. This is required if response_format is set.
        :param response_modalities: The requested modalities of the response (TEXT, IMAGE, AUDIO).
        :param safety_settings: Safety settings for the interaction.
        :param service_tier:
        :param store: Input only. Whether to store the response and request for later retrieval.
        :param stream: Input only. Whether the interaction will be streamed.
        :param system_instruction: System instruction for the interaction.
        :param tools: A list of tool declarations the model may call during interaction.
        :param webhook_config: Message for configuring webhook events for a request.
        :param agent: The agent to interact with.
        :param agent_config: Configuration parameters for the agent interaction.
        :param extra_headers: Additional headers to set or replace on requests.
        :param extra_query: Additional query parameters to append to requests.
        :param extra_body: Additional JSON object fields to merge into request bodies.
        :param timeout: Override the default request timeout configuration for this method in seconds
        Nr%   r$   r0   r8   r,   r-   r.   r/   rT   r%   r%   r&   r5     r6   c                   s  d|v rd|v rt dd|v rd|v rt dd|v r$d|v r$t dd|v r0d|v r0t dd	}d	}	t}
d	}|}|}|d	u rGjj}|d	urN|}n||	}turnttjt	t
rbn	ttttjn)t|}d
d | D }d|i}dd | D }||d< ttjt|tjt|\}}jdwi ddddd|d|	ddddddddddttdd	dddu rdnd d!|d"|d#tjjjjd$d%jjd& fd'd(d)d	d*|}|
tkrjjturjj}
ntjd+td,d-d.d/dd0d1}
d	}t	|
tjr"|
g d2f}fd3d4}tj|p/d5d6d	tjjtjd	d7g d8d9d:d;d8d<d=d;d8d>d?d;d8d@dAd;dBd9dCd;dBd<dDd;dBd>dEd;dBd@dFd;dGd9dHd;dGd<dId;dGd>dJd;dGd@dKd;dLd9dMd;dLd<dNd;dLd>dOd;dLd@dPd;dQd9dRd;dQd<dSd;dQd>dTd;dQd@dUd;dVd9dWd;dVd<dXd;dVd>dYd;dVd@dZd;d[d9d\d;d[d<d]d;d[d>d^d;d[d@d_d;d`d9dad;d`d<dbd;d`d>dcd;d`d@ddd;ded9dfd;ded<dgd;ded>dhd;ded@did;it|djdkdl}j ||dmd( ttdd	dddu p3|dnk|do}|dpkrt!dqdrg|j"rr|#  z|| W n! t$yq } zt%jj&ds t'||| W Y d	}~nd	}~ww |dnkrztj(ntj)}tt|||ttdd	dddu rdtndut'|jj&*dsdvS z||W S  t$y } zt%jj&ds t'||| W Y d	}~d	S d	}~ww )xrV   r;   rO   3Cannot supply both 'generation_config' and 'agent'.rN   :Cannot supply both 'generation_config' and 'agent_config'.rI   'Cannot supply both 'model' and 'agent'..Cannot supply both 'model' and 'agent_config'.Nc                 S      i | ]\}}|t ur||qS r%   r   .0kvr%   r%   r&   
<dictcomp>      z'Interactions.create.<locals>.<dictcomp>r8   c                 S   r\   r%   r]   r^   r%   r%   r&   rb         bodymethodPOSTpath/{api_version}/interactionsbase_urlurl_variablesr0   request_body_requiredTrequest_has_path_paramsrequest_has_query_paramsuser_agent_header
user-agentaccept_header_valuerD   Ftext/event-streamapplication/jsonhttp_headersextra_query_params_globalsr8   securityget_serialized_bodyc                         t jjdddtj dS NFjson)r.   r   serialize_request_bodyre   r   CreateInteractionRequestBodyr%   r.   r0   r%   r&   <lambda>      z%Interactions.create.<locals>.<lambda>allow_empty_value
timeout_msattempt-count-backoff  @     0u     max_retries4084094295XXc              
      ,  d }t  ddrt  }ttj |ddS t  ddr*t  fdddd	S t  d
drZt  }zttj |}t	| | tj
yY } ztd ||d }~ww t  ddrt  }zttj |}t| | tj
y } ztd ||d }~ww t  }td |)N200rs   Fvalidaterr   c                       t tj | ddjS NFr   r   r   InteractionSSEStreamEventdatarawhttp_resr%   r&   r         zHInteractions.create.<locals>._speakeasy_parse_response.<locals>.<lambda>[DONE]sentinel
client_ref4XX1Error response body did not match expected schemar   Unexpected response received)r   match_responsestream_to_textr   r   Interactionr   r    CreateInteractionClientErrorDataCreateInteractionClientErrorResponseValidationErrorGenAiDefaultError CreateInteractionServerErrorDataCreateInteractionServerErrorr   response_datahttp_res_texter#   r   r&   _speakeasy_parse_response  sn   





z6Interactions.create.<locals>._speakeasy_parse_response CreateInteractionx-codeSamplessimpleshcurl -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.6-flash",
    "input": "Hello, how are you?"
  }'
labellangsourcepythonfrom google import genai

client = genai.Client()
interaction = client.interactions.create(
    model="gemini-3.6-flash",
    input="Hello, how are you?",
)
print(interaction.output_text)

javascriptimport {GoogleGenAI} from '@google/genai';

const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
    model: 'gemini-3.6-flash',
    input: 'Hello, how are you?',
});
console.log(interaction.output_text);
javaw  import com.google.genai.Client;
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.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;

Client client = new Client();
CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model("gemini-3.6-flash")
        .input(InteractionsInput.of("Hello, how are you?"))
        .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(""));

multi_turn  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.6-flash",
    "input": [
      { "type": "user_input", "content": [{ "type": "text", "text": "Hello!" }] },
      { "type": "model_output", "content": [{ "type": "text", "text": "Hi there! How can I help you today?" }] },
      { "type": "user_input", "content": [{ "type": "text", "text": "What is the capital of France?" }] }
    ]
  }'
  from google import genai

client = genai.Client()
response = client.interactions.create(
    model="gemini-3.6-flash",
    input=[
        { "type": "user_input", "content": [{ "type": "text", "text": "Hello!" }] },
        { "type": "model_output", "content": [{ "type": "text", "text": "Hi there! How can I help you today?" }] },
        { "type": "user_input", "content": [{ "type": "text", "text": "What is the capital of France?" }] }
    ]
)
print(response.output_text)
  import {GoogleGenAI} from '@google/genai';

const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
    model: 'gemini-3.6-flash',
    input: [
        { type: 'user_input', content: [{ type: 'text', text: 'Hello' }] },
        { type: 'model_output', content: [{ type: 'text', text: 'Hi there! How can I help you today?' }] },
        { type: 'user_input', content: [{ type: 'text', text: 'What is the capital of France?' }] }
    ]
});
console.log(interaction.output_text);
>  import com.google.genai.Client;
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.ModelOutputStep;
import com.google.genai.gaos.models.interactions.Step;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.interactions.UserInputStep;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;
import java.util.List;

Client client = new Client();
List<Step> conversation = List.of(
    UserInputStep.builder()
        .content(List.of(TextContent.builder().text("Hello!").build()))
        .build(),
    ModelOutputStep.builder()
        .content(List.of(TextContent.builder().text("Hi there! How can I help you today?").build()))
        .build(),
    UserInputStep.builder()
        .content(List.of(TextContent.builder().text("What is the capital of France?").build()))
        .build()
);
CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model("gemini-3.6-flash")
        .input(InteractionsInput.ofStep(conversation))
        .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(""));
multimodal_image  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.6-flash",
    "input": [
      {
        "type": "text",
        "text": "What is in this picture?"
      },
      {
        "type": "image",
        "data": "BASE64_ENCODED_IMAGE",
        "mime_type": "image/png"
      }
    ]
  }'
9  from google import genai

client = genai.Client()
response = client.interactions.create(
    model="gemini-3.6-flash",
    input=[
      { "type": "text", "text": "What is in this picture?" },
      { "type": "image", "data": "BASE64_ENCODED_IMAGE", "mime_type": "image/png" }
    ]
)
print(response.output_text)
c  import {GoogleGenAI} from '@google/genai';

const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
    model: 'gemini-3.6-flash',
    input: [
      { type: 'text', text: 'What is in this picture?' },
      { type: 'image', data: 'BASE64_ENCODED_IMAGE', mime_type: 'image/png' }
    ]
});
console.log(interaction.output_text);
q  import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.Content;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.ImageContent;
import com.google.genai.gaos.models.interactions.ImageContentMimeType;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;
import java.util.List;

Client client = new Client();
List<Content> content = List.of(
    TextContent.builder().text("What is in this picture?").build(),
    ImageContent.builder()
        .data("BASE64_ENCODED_IMAGE")
        .mimeType(ImageContentMimeType.IMAGE_PNG)
        .build()
);
CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model("gemini-3.6-flash")
        .input(InteractionsInput.ofContent(content))
        .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(""));
function_calling  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.6-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.6-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?"
)
print(response.steps[-1])
  import {GoogleGenAI} from '@google/genai';

const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
    model: 'gemini-3.6-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?'
});
console.log(interaction.steps.at(-1));
_  import com.google.genai.Client;
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;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;
import java.util.List;
import java.util.Map;

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.6-flash")
        .tools(List.of(functionTool))
        .input(InteractionsInput.of("What is the weather like in Boston, MA?"))
        .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));
}
deep_research  curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent": "deep-research-pro-preview-12-2025",
    "input": "Find a cure to cancer",
    "background": true
  }'
from google import genai

client = genai.Client()
interaction = client.interactions.create(
    agent="deep-research-pro-preview-12-2025",
    input="find a cure to cancer",
    background=True,
)
print(interaction.status)
  import {GoogleGenAI} from '@google/genai';

const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
    agent: 'deep-research-pro-preview-12-2025',
    input: 'find a cure to cancer',
    background: true,
});
console.log(interaction.status);
P  import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionStatus;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;

Client client = new Client();
CreateAgentInteraction params =
    CreateAgentInteraction.builder()
        .agent(AgentOption.of("deep-research-pro-preview-12-2025"))
        .input(InteractionsInput.of("find a cure to cancer"))
        .background(true)
        .build();
CreateInteractionResponse response =
    client.interactions.create(CreateInteractionRequestBody.of(params));
Interaction interaction =
    response.interaction().orElseThrow(() -> new RuntimeException("No interaction returned"));
System.out.println(interaction.status().map(InteractionStatus::value).orElse(""));
antigravityW  curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent": "antigravity-preview-05-2026",
    "input": "Read Hacker News, summarize the top 5 stories, and save results as a markdown file.",
    "environment": "remote"
  }'
!  from google import genai

client = genai.Client()
interaction = client.interactions.create(
    agent="antigravity-preview-05-2026",
    input="Read Hacker News, summarize the top 5 stories, and save results as a markdown file.",
    environment="remote",
)
print(interaction.output_text)
P  import {GoogleGenAI} from '@google/genai';

const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
    agent: 'antigravity-preview-05-2026',
    input: 'Read Hacker News, summarize the top 5 stories, and save results as a markdown file.',
    environment: 'remote',
});
console.log(interaction.output_text);
  import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;

Client client = new Client();
CreateAgentInteraction params =
    CreateAgentInteraction.builder()
        .agent(AgentOption.of("antigravity-preview-05-2026"))
        .input(InteractionsInput.of("Read Hacker News, summarize the top 5 stories, and save results as a markdown file."))
        .environment(CreateAgentInteractionEnvironment.of("remote"))
        .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(""));
	reuse_env:  # Step 1: Create an interaction with a fresh remote environment.
RESPONSE=$(curl -s -X POST https://generativelanguage.googleapis.com/v1beta/interactions \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Api-Revision: 2026-05-20" \
  -d '{
    "agent": "antigravity-preview-05-2026",
    "input": "Write a hello world script at /workspace/hello.py.",
    "environment": "remote"
  }')
INTERACTION_ID=$(echo $RESPONSE | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
ENV_ID=$(echo $RESPONSE | python3 -c "import sys,json; print(json.load(sys.stdin)['environment_id'])")

# Step 2: Reuse the same environment in a follow-up interaction.
curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d "{
    \"agent\": \"antigravity-preview-05-2026\",
    \"input\": \"Modify the script to accept a name argument and greet the user.\",
    \"environment\": \"$ENV_ID\",
    \"previous_interaction_id\": \"$INTERACTION_ID\"
  }"
  from google import genai

client = genai.Client()

# Step 1: Create an interaction with a fresh remote environment.
interaction = client.interactions.create(
    agent="antigravity-preview-05-2026",
    input="Write a hello world script at /workspace/hello.py.",
    environment="remote",
)
print(f"Environment ID: {interaction.environment_id}")

# Step 2: Reuse the same environment in a follow-up interaction.
interaction_2 = client.interactions.create(
    agent="antigravity-preview-05-2026",
    input="Modify the script to accept a name argument and greet the user.",
    environment=interaction.environment_id,
    previous_interaction_id=interaction.id,
)
print(interaction_2.output_text)
  import {GoogleGenAI} from '@google/genai';

const ai = new GoogleGenAI({});

// Step 1: Create an interaction with a fresh remote environment.
const interaction = await ai.interactions.create({
    agent: 'antigravity-preview-05-2026',
    input: 'Write a hello world script at /workspace/hello.py.',
    environment: 'remote',
});
console.log(`Environment ID: ${interaction.environment_id}`);

// Step 2: Reuse the same environment in a follow-up interaction.
const interaction2 = await ai.interactions.create({
    agent: 'antigravity-preview-05-2026',
    input: 'Modify the script to accept a name argument and greet the user.',
    environment: interaction.environment_id,
    previous_interaction_id: interaction.id,
});
console.log(interaction2.output_text);
  import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;

Client client = new Client();

// Step 1: Create an interaction with a fresh remote environment.
CreateAgentInteraction params1 =
    CreateAgentInteraction.builder()
        .agent(AgentOption.of("antigravity-preview-05-2026"))
        .input(InteractionsInput.of("Write a hello world script at /workspace/hello.py."))
        .environment(CreateAgentInteractionEnvironment.of("remote"))
        .build();
CreateInteractionResponse response1 =
    client.interactions.create(CreateInteractionRequestBody.of(params1));
Interaction interaction1 =
    response1.interaction().orElseThrow(() -> new RuntimeException("No interaction returned"));
System.out.println("Environment ID: " + interaction1.environmentId().orElse(""));

// Step 2: Reuse the same environment in a follow-up interaction.
CreateAgentInteraction params2 =
    CreateAgentInteraction.builder()
        .agent(AgentOption.of("antigravity-preview-05-2026"))
        .input(InteractionsInput.of("Modify the script to accept a name argument and greet the user."))
        .environment(CreateAgentInteractionEnvironment.of(interaction1.environmentId().orElse("")))
        .previousInteractionId(interaction1.id().orElse(null))
        .build();
CreateInteractionResponse response2 =
    client.interactions.create(CreateInteractionRequestBody.of(params2));
Interaction interaction2 =
    response2.interaction().orElseThrow(() -> new RuntimeException("No interaction returned"));
System.out.println(interaction2.outputText().orElse(""));
with_sources  curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent": "antigravity-preview-05-2026",
    "input": "List all files under /workspace and summarize what you find.",
    "environment": {
      "type": "remote",
      "sources": [
        {
          "type": "repository",
          "source": "https://github.com/octocat/Spoon-Knife",
          "target": "/workspace/repo"
        },
        {
          "type": "inline",
          "content": "Focus on Python files only.",
          "target": "/workspace/notes.txt"
        }
      ]
    }
  }'
  from google import genai

client = genai.Client()
interaction = client.interactions.create(
    agent="antigravity-preview-05-2026",
    input="List all files under /workspace and summarize what you find.",
    environment={
        "type": "remote",
        "sources": [
            {
                "type": "repository",
                "source": "https://github.com/octocat/Spoon-Knife",
                "target": "/workspace/repo",
            },
            {
                "type": "inline",
                "content": "Focus on Python files only.",
                "target": "/workspace/notes.txt",
            },
        ],
    },
)
print(interaction.output_text)
  import {GoogleGenAI} from '@google/genai';

const ai = new GoogleGenAI({});
const interaction = await ai.interactions.create({
    agent: 'antigravity-preview-05-2026',
    input: 'List all files under /workspace and summarize what you find.',
    environment: {
        type: 'remote',
        sources: [
            {
                type: 'repository',
                source: 'https://github.com/octocat/Spoon-Knife',
                target: '/workspace/repo',
            },
            {
                type: 'inline',
                content: 'Focus on Python files only.',
                target: '/workspace/notes.txt',
            },
        ],
    },
});
console.log(interaction.output_text);
  import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Environment;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Source;
import com.google.genai.gaos.models.interactions.SourceType;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;
import java.util.List;

Client client = new Client();
Environment env = Environment.builder()
    .sources(List.of(
        Source.builder()
            .type(SourceType.REPOSITORY)
            .source("https://github.com/octocat/Spoon-Knife")
            .target("/workspace/repo")
            .build(),
        Source.builder()
            .type(SourceType.INLINE)
            .content("Focus on Python files only.")
            .target("/workspace/notes.txt")
            .build()
    ))
    .build();
CreateAgentInteraction params =
    CreateAgentInteraction.builder()
        .agent(AgentOption.of("antigravity-preview-05-2026"))
        .input(InteractionsInput.of("List all files under /workspace and summarize what you find."))
        .environment(CreateAgentInteractionEnvironment.of(env))
        .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(""));
custom_agent  # Step 1: Create a custom agent.
curl -X POST https://generativelanguage.googleapis.com/v1beta/agents \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "id": "code-reviewer",
    "base_agent": "antigravity-preview-05-2026",
    "system_instruction": "You are a senior code reviewer. Check every file for bugs, style issues, and security vulnerabilities.",
    "base_environment": {
      "type": "remote",
      "sources": [{
        "type": "repository",
        "source": "https://github.com/octocat/Spoon-Knife",
        "target": "/workspace/repo"
      }]
    }
  }'

# Step 2: Use the custom agent.
curl -X POST https://generativelanguage.googleapis.com/v1beta/interactions \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "agent": "code-reviewer",
    "input": "Review the latest changes in /workspace/repo/src and file a summary.",
    "environment": "remote"
  }'
k  import uuid
from google import genai

client = genai.Client()

# Step 1: Create a custom agent.
agent_id = f"code-reviewer-{uuid.uuid4().hex[:8]}"
client.agents.create(
    id=agent_id,
    base_agent="antigravity-preview-05-2026",
    system_instruction="You are a senior code reviewer. Check every file for bugs, style issues, and security vulnerabilities.",
    base_environment={
        "type": "remote",
        "sources": [{
            "type": "repository",
            "source": "https://github.com/octocat/Spoon-Knife",
            "target": "/workspace/repo",
        }],
    },
)

# Step 2: Use the custom agent.
result = client.interactions.create(
    agent=agent_id,
    input="Review the latest changes in /workspace/repo/src and file a summary.",
    environment="remote",
)
print(result.output_text)

# [cleanup]
client.agents.delete(agent_id)
# [/cleanup]
  import {GoogleGenAI} from '@google/genai';

const ai = new GoogleGenAI({});

// Step 1: Create a custom agent.
const agentId = `code-reviewer-${crypto.randomUUID().slice(0, 8)}`;
await ai.agents.create({
    id: agentId,
    base_agent: 'antigravity-preview-05-2026',
    system_instruction: 'You are a senior code reviewer. Check every file for bugs, style issues, and security vulnerabilities.',
    base_environment: {
        type: 'remote',
        sources: [{
            type: 'repository',
            source: 'https://github.com/octocat/Spoon-Knife',
            target: '/workspace/repo',
        }],
    },
});

// Step 2: Use the custom agent.
const result = await ai.interactions.create({
    agent: agentId,
    input: 'Review the latest changes in /workspace/repo/src and file a summary.',
    environment: 'remote',
});
console.log(result.output_text);

// [cleanup]
await ai.agents.delete(agentId);
// [/cleanup]
 	  import com.google.genai.Client;
import com.google.genai.gaos.models.agents.Agent;
import com.google.genai.gaos.models.agents.BaseEnvironment;
import com.google.genai.gaos.models.interactions.AgentOption;
import com.google.genai.gaos.models.interactions.CreateAgentInteraction;
import com.google.genai.gaos.models.interactions.CreateAgentInteractionEnvironment;
import com.google.genai.gaos.models.interactions.Environment;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Source;
import com.google.genai.gaos.models.interactions.SourceType;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;
import java.util.List;
import java.util.UUID;

Client client = new Client();

// Step 1: Create a custom agent.
String agentId = "code-reviewer-" + UUID.randomUUID().toString().substring(0, 8);
Environment baseEnv = Environment.builder()
    .sources(List.of(
        Source.builder()
            .type(SourceType.REPOSITORY)
            .source("https://github.com/octocat/Spoon-Knife")
            .target("/workspace/repo")
            .build()
    ))
    .build();
Agent customAgent = Agent.builder()
    .id(agentId)
    .baseAgent("antigravity-preview-05-2026")
    .systemInstruction("You are a senior code reviewer. Check every file for bugs, style issues, and security vulnerabilities.")
    .baseEnvironment(BaseEnvironment.of(baseEnv))
    .build();
client.agents.create(customAgent);

// Step 2: Use the custom agent.
CreateAgentInteraction params =
    CreateAgentInteraction.builder()
        .agent(AgentOption.of(agentId))
        .input(InteractionsInput.of("Review the latest changes in /workspace/repo/src and file a summary."))
        .environment(CreateAgentInteractionEnvironment.of("remote"))
        .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(""));

// [cleanup]
client.agents.delete(agentId);
// [/cleanup]
syncmode	executionconfigrj   operation_idoauth2_scopessecurity_sourcetags
extensionsresponsec                 S      t ddg| S Nr   r   r   match_status_codescr%   r%   r&   r         	streaminghook_ctxr0   is_error_status_coderD   retry_configparsedr   r   _hooksevent_streambufferedr   parserr   r   r  hooksr%   )+
ValueErrorr   _coerce_timeout_mssdk_configurationr   _get_urlr   r   CreateInteractionRequest
isinstancer   r   	unmarshalr   dictitemsr   consume_response_mode_build_requestgetattrCreateInteractionGlobalsglobalsr8   rx   r  RetryConfigBackoffStrategyr	   r   r   Securityr
   
do_requestr   status_coderead	Exceptionraise_parse_error__dict__r   StreamedAPIResponseAPIResponsegetr$   r0   r8   r,   r-   r.   r/   rT   rj   rk   retries
server_urlrt   r   _body_kwargs_request_kwargs_speakeasy_response_modereqr  r   _speakeasy_hook_ctxr   
parse_exc__speakeasy_response_clsr%   r.   r0   r$   r&   r5   G  s  *
	
	

7
 %*/49>CHMRW\afkpuz   
          #  (  -  2  
9  D


	

r8   r,   r-   r/   idc                C     d}d}t }d}	|}
| |}|du r| jj}|	dur|	}n| ||}tj||d}t|
\}}
| j	d>i ddddd|d|d	|d
dddddddddd|
d|dtj
| jjjdd| jjddd|}|t kr| jjt ur| jj}ntjdtddddddd }d}t|tjr|g d!f}d"d# }t| j|pd$d%dt| jjtjdd&d'd(d)d*d'd+d,d*d'd-d.d*d'd/d0d*git|d1d2d3}| j||d4d5 |d6k|d7}|d8kr8td9d:g|jr|  z|| W n! ty } zt| jjd; t||| W Y d}~nd}~ww |d6kr!tj ntj!}t"t#|||d<| t|| jj$d;d=S z||W S  ty_ } zt| jjd; t||| W Y d}~dS d}~ww )?  Deleting an interaction

        Deletes the interaction by id.

        :param id: The unique identifier of the interaction to delete.
        :param api_version: Which version of the API to use.
        :param extra_headers: Additional headers to set or replace on requests.
        :param extra_query: Additional query parameters to append to requests.
        :param timeout: Override the default request timeout configuration for this method in seconds
        Nr8   r2  rf   DELETErh    /{api_version}/interactions/{id}rj   rk   r0   rl   Frm   Trn   ro   rp   rq   rs   rt   ru   rv   rw   rx   r   r   r   r   r   r   r   r   r   r   c              
   S   s   d }t | ddrd S t | ddr5zttj| }t||  tjy4 } z	td| | j|d }~ww t | ddr_zttj	| }t
||  tjy^ } z	td| | j|d }~ww td| Nr   *r   rs   r   r   r   r   r   r   r    DeleteInteractionClientErrorDataDeleteInteractionClientErrorr   r   text DeleteInteractionServerErrorDataDeleteInteractionServerErrorr   r   r   r%   r%   r&   r   J  sH   z6Interactions.delete.<locals>._speakeasy_parse_responser   deleteInteractionr   deleter     # [setup]
INTERACTION_ID=$(curl -s -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.6-flash", "input": "Hello"}' \
  | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
# [/setup]

curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/interactions/$INTERACTION_ID" \
  -H "x-goog-api-key: $GEMINI_API_KEY"
r   r   from google import genai

client = genai.Client()

# [setup]
created = client.interactions.create(
    model="gemini-3.6-flash",
    input="Hello",
)
# [/setup]

client.interactions.delete(id=created.id)
print("Interaction deleted successfully.")
r   '  import {GoogleGenAI} from '@google/genai';

const ai = new GoogleGenAI({});

// [setup]
const created = await ai.interactions.create({
    model: 'gemini-3.6-flash',
    input: 'Hello',
});
// [/setup]

await ai.interactions.delete(created.id);
console.log('Interaction deleted successfully.');
r     import com.google.genai.Client;
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.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;

Client client = new Client();

// [setup]
CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model("gemini-3.6-flash")
        .input(InteractionsInput.of("Hello"))
        .build();
CreateInteractionResponse created =
    client.interactions.create(CreateInteractionRequestBody.of(params));
String interactionId = created.interaction().flatMap(Interaction::id).orElseThrow();
// [/setup]

client.interactions.delete(interactionId);
System.out.println("Interaction deleted successfully.");
r   r   r   c                 S   r   r   r   r   r%   r%   r&   r     r   z%Interactions.delete.<locals>.<lambda>r   r  r  r   r   r  r  r	  r%   )%r   r  r  r   r  r   DeleteInteractionRequestr   r  r  DeleteInteractionGlobalsr  r8   rx   r  r   r  r  r  r	   r   r   r  r
   r  r   r  r  r   r!  r"  r   r#  r$  r   r   r%  r$   r2  r8   r,   r-   r/   rj   rk   r'  r(  rt   r   r0   r+  r,  r  r   r-  r   r.  r/  r%   r%   r&   rB    s  

	



#


	

zInteractions.deleter8   include_inputlast_event_idrD   r,   r-   r/   rK  rL  c          	      C   r2   i  Retrieving an interaction

        Retrieves the full details of a single interaction based on its `Interaction.id`.

        :param id: The unique identifier of the interaction to retrieve.
        :param api_version: Which version of the API to use.
        :param include_input: If set to true, includes the input in the response.
        :param last_event_id: Optional. If set, resumes the interaction stream from the next chunk after the event marked by the event id. Can only be used if `stream` is true.
        :param stream: If set to true, the generated content will be streamed incrementally.
        :param extra_headers: Additional headers to set or replace on requests.
        :param extra_query: Additional query parameters to append to requests.
        :param timeout: Override the default request timeout configuration for this method in seconds
        Nr%   	r$   r2  r8   rK  rL  rD   r,   r-   r/   r%   r%   r&   r%    r6   zInteractions.getr8   rK  rL  r,   r-   r/   c          	      C   r2   rM  r%   rO  r%   r%   r&   r%    r6   c          	      C   r2   rM  r%   rO  r%   r%   r&   r%    r6   c                   s  d}	d}
t }d}|} |}|du r jj}|dur|}	n |	|
}	tj|||||d}t|\}} j	d@i ddddd|	d|
d	|d
dddddddd|du r[dndd|d|dtj
 jjjdd jjddd|}|t kr jjt ur jj}ntjdtdddddd d!}d}t|tjr|g d"f} fd#d$}t j|	pd%d&dt jjtjdd'd(d)d*d+d(d,d-d+d(d.d/d+d(d0d1d+git|d2d3d4} j||d5d6 |du p|d7k|d8}|d9krNtd:d;g|jr(|  z|| W n! ty' } zt jjd< t||| W Y d}~nd}~ww |d7kr0tj ntj!}t"t#||||du r?d=nd> t| jj$d<d?S z||W S  tyu } zt jjd< t||| W Y d}~dS d}~ww )ArN  Nr8   r2  rK  rL  rD   rf   GETrh   r7  rj   rk   r0   rl   Frm   Trn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   r   r   r   r   r   r   r   r   r   r   c              
      r   )Nr   rs   Fr   rr   c                    r   r   r   r   r   r%   r&   r   l  r   zEInteractions.get.<locals>._speakeasy_parse_response.<locals>.<lambda>r   r   r   r   r   r   )r   r   r   r   r   r   r   r   !GetInteractionByIDClientErrorDataGetInteractionByIDClientErrorr   r   !GetInteractionByIDServerErrorDataGetInteractionByIDServerErrorr   r#   r   r&   r   b  sv   





z3Interactions.get.<locals>._speakeasy_parse_responser   getInteractionByIdr   r%  r     # [setup]
INTERACTION_ID=$(curl -s -X POST https://generativelanguage.googleapis.com/v1beta/interactions \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Api-Revision: 2026-05-20" \
  -d '{"model": "gemini-3.6-flash", "input": "Say hello."}' \
  | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
# [/setup]

curl -X GET "https://generativelanguage.googleapis.com/v1beta/interactions/$INTERACTION_ID" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Api-Revision: 2026-05-20"
r   r   from google import genai

client = genai.Client()

# [setup]
created = client.interactions.create(
    model="gemini-3.6-flash",
    input="Say hello."
)
# [/setup]

interaction = client.interactions.get(id=created.id)
print(interaction.status)
r   +  import {GoogleGenAI} from '@google/genai';

const ai = new GoogleGenAI({});

// [setup]
const created = await ai.interactions.create({
    model: 'gemini-3.6-flash',
    input: 'Say hello.'
});
// [/setup]

const interaction = await ai.interactions.get(created.id);
console.log(interaction.status);
r   E  import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionStatus;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;
import com.google.genai.gaos.models.operations.GetInteractionByIdRequest;
import com.google.genai.gaos.models.operations.GetInteractionByIdResponse;

Client client = new Client();

// [setup]
CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model("gemini-3.6-flash")
        .input(InteractionsInput.of("Say hello."))
        .build();
CreateInteractionResponse created =
    client.interactions.create(CreateInteractionRequestBody.of(params));
String interactionId = created.interaction().flatMap(Interaction::id).orElseThrow();
// [/setup]

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(""));
r   r   r   c                 S   r   r   r   r   r%   r%   r&   r     r   z"Interactions.get.<locals>.<lambda>r   r  r  r   r   r  r  r  r	  r%   )%r   r  r  r   r  r   GetInteractionByIDRequestr   r  r  GetInteractionByIDGlobalsr  r8   rx   r  r   r  r  r  r	   r   r   r  r
   r  r   r  r  r   r!  r"  r   r#  r$  r   r   r%  r$   r2  r8   rK  rL  rD   r,   r-   r/   rj   rk   r'  r(  rt   r   r0   r+  r,  r  r   r-  r   r.  r/  r%   r#   r&   r%  
  s*  

	
;

#


	

c                C   r3  )?  Canceling an interaction

        Cancels an interaction by id. This only applies to background interactions that are still running.

        :param id: The unique identifier of the interaction to cancel.
        :param api_version: Which version of the API to use.
        :param extra_headers: Additional headers to set or replace on requests.
        :param extra_query: Additional query parameters to append to requests.
        :param timeout: Override the default request timeout configuration for this method in seconds
        Nr5  rf   rg   rh   '/{api_version}/interactions/{id}/cancelrj   rk   r0   rl   Frm   Trn   ro   rp   rq   rs   rt   ru   rv   rw   rx   r   r   r   r   r   r   r   r   r   r   c              
   S   s   d }t | ddrttj| ddS t | ddr;zttj| }t||  tjy: } z	t	d| | j
|d }~ww t | ddrezttj| }t||  tjyd } z	t	d| | j
|d }~ww t	d| 	Nr   rs   Fr   r   r   r   r   r   r   r   r   r   r   $CancelInteractionByIDClientErrorData CancelInteractionByIDClientErrorr   r   r=  $CancelInteractionByIDServerErrorData CancelInteractionByIDServerErrorr@  r%   r%   r&   r   :  sT   z6Interactions.cancel.<locals>._speakeasy_parse_responser   cancelInteractionByIdr   cancelr     # [setup]
INTERACTION_ID=$(curl -s -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.6-flash", "input": "Write a long essay about the history of computing.", "background": true}' \
  | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
# [/setup]

curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions/$INTERACTION_ID/cancel" \
  -H "x-goog-api-key: $GEMINI_API_KEY"
r   r     from google import genai

client = genai.Client()

# Start a background interaction so it stays in-progress.
created = client.interactions.create(
    model="gemini-3.6-flash",
    input="Write a long essay about the history of computing.",
    tools=[{"type": "computer_use"}],
    background=True,
)

# Cancel the in-progress interaction.
interaction = client.interactions.cancel(id=created.id)
print(interaction.status)
r     import {GoogleGenAI} from '@google/genai';

const ai = new GoogleGenAI({});

// Start a background interaction so it stays in-progress.
const created = await ai.interactions.create({
    model: 'gemini-3.6-flash',
    input: 'Write a long essay about the history of computing.',
    tools: [{ type: 'computer_use' }],
    background: true,
});

// Cancel the in-progress interaction.
const interaction = await ai.interactions.cancel(created.id);
console.log(interaction.status);
r     import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.ComputerUse;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionStatus;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.operations.CancelInteractionByIdResponse;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.gaos.models.operations.CreateInteractionResponse;
import java.util.List;

Client client = new Client();

// Start a background interaction so it stays in-progress.
CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model("gemini-3.6-flash")
        .input(InteractionsInput.of("Write a long essay about the history of computing."))
        .tools(List.of(new ComputerUse()))
        .background(true)
        .build();
CreateInteractionResponse created =
    client.interactions.create(CreateInteractionRequestBody.of(params));
String interactionId = created.interaction().flatMap(Interaction::id).orElseThrow();

// Cancel the in-progress interaction.
CancelInteractionByIdResponse cancelResponse = client.interactions.cancel(interactionId);
Interaction interaction =
    cancelResponse.interaction().orElseThrow(() -> new RuntimeException("No interaction returned"));
System.out.println(interaction.status().map(InteractionStatus::value).orElse(""));
r   r   r   c                 S   r   r   r   r   r%   r%   r&   r     r   z%Interactions.cancel.<locals>.<lambda>r   r  r  r   r   r  r  r	  r%   )%r   r  r  r   r  r   CancelInteractionByIDRequestr   r  r  CancelInteractionByIDGlobalsr  r8   rx   r  r   r  r  r  r	   r   r   r  r
   r  r   r  r  r   r!  r"  r   r#  r$  r   r   r%  rI  r%   r%   r&   rh    s  

	

%

#


	

zInteractions.cancel).__name__
__module____qualname__propertyr'   r*   r   r   r   r  CreateInteractionRequestParamr   r   strr   floathttpxTimeoutr   r   r   InteractionSSEEventr5   bool&CreateModelInteractionEnvironmentParamGenerationConfigParamInteractionsInputParamr   Model)CreateModelInteractionResponseFormatParamr   ResponseModalitySafetySettingParamServiceTierr   	ToolParamWebhookConfigParamAgentOption&CreateAgentInteractionAgentConfigParam&CreateAgentInteractionEnvironmentParam)CreateAgentInteractionResponseFormatParamr   r   rB  r%  rh  r%   r%   r%   r&   r      s   


	

	
6
	
6
	
6
	
6	
0	

   =
 =	
	
	
	

 hr   c                   @      e Zd ZdeddfddZdS )r"   sdkr1   Nc                 C   J   || _ t|jd| _t|jd| _t|jd| _t|jd| _d S Nr,   )_sdkr   to_raw_response_wrapperr5   rB  r%  rh  r$   r  r%   r%   r&   __init__  s   
z$InteractionsWithRawResponse.__init__ro  rp  rq  r   r  r%   r%   r%   r&   r"         r"   c                   @   r  )r)   r  r1   Nc                 C   r  r  )r  r   to_streamed_response_wrapperr5   rB  r%  rh  r  r%   r%   r&   r       
z*InteractionsWithStreamingResponse.__init__r  r%   r%   r%   r&   r)     r  r)   c                1   @   r   )AAsyncInteractionsc                 C   r    r!   ) AsyncInteractionsWithRawResponser#   r%   r%   r&   r'     r(   z#AsyncInteractions.with_raw_responsec                 C   r    r!   )&AsyncInteractionsWithStreamingResponser#   r%   r%   r&   r*     r(   z)AsyncInteractions.with_streaming_responseNr+   r0   r,   r-   r.   r/   r1   c                      dS r3   r%   r4   r%   r%   r&   r5         zAsyncInteractions.create.r7   r8   r9   r:   r;   rH   r<   rI   r=   r>   r?   r@   rA   rB   rC   rD   FrE   rF   rG   c                   r  rJ   r%   rK   r%   r%   r&   r5     r  rL   Tc                   r  rJ   r%   rK   r%   r%   r&   r5   (  r  rM   rO   rN   c                   r  rP   r%   rQ   r%   r%   r&   r5   _  r  rR   c                   r  rP   r%   rQ   r%   r%   r&   r5     r  rS   rT   c                   r  rU   r%   rW   r%   r%   r&   r5     r  c                   s  d|v rd|v rt dd|v rd|v rt dd|v r%d|v r%t dd|v r1d|v r1t dd	}d	}	t}
d	}|}|}|d	u rHjj}|d	urO|}n||	}turottjt	t
rcn	ttttjn)t|}d
d | D }d|i}dd | D }||d< ttjt|tjt|\}}jdxi ddddd|d|	ddddddddddttdd	dddu rdnd d!|d"|d#tjjjjd$d%jjd& fd'd(d)d	d*|}|
tkrjjturjj}
ntjd+td,d-d.d/dd0d1}
d	}t	|
tjr#|
g d2f}fd3d4}tj|p0d5d6d	tjjtjd	d7g d8d9d:d;d8d<d=d;d8d>d?d;d8d@dAd;dBd9dCd;dBd<dDd;dBd>dEd;dBd@dFd;dGd9dHd;dGd<dId;dGd>dJd;dGd@dKd;dLd9dMd;dLd<dNd;dLd>dOd;dLd@dPd;dQd9dRd;dQd<dSd;dQd>dTd;dQd@dUd;dVd9dWd;dVd<dXd;dVd>dYd;dVd@dZd;d[d9d\d;d[d<d]d;d[d>d^d;d[d@d_d;d`d9dad;d`d<dbd;d`d>dcd;d`d@ddd;ded9dfd;ded<dgd;ded>dhd;ded@did;it|djdkdl}j ||dmd( ttdd	dddu p4|dnk|doI d	H }|dpkrt!dqdrg|j"r|# I d	H  z	||I d	H  W n+ t$y } zt%jj&'dsjj&'dtt(|||I d	H  W Y d	}~nd	}~ww |dnkrtj)ntj*}tt|||ttdd	dddu rdundvt(|jj&'dtjj&'dsdwS z||I d	H W S  t$y } zt%jj&'dsjj&'dtt(|||I d	H  W Y d	}~d	S d	}~ww )yrV   r;   rO   rX   rN   rY   rI   rZ   r[   Nc                 S   r\   r%   r]   r^   r%   r%   r&   rb   F  rc   z,AsyncInteractions.create.<locals>.<dictcomp>r8   c                 S   r\   r%   r]   r^   r%   r%   r&   rb   H  rd   re   rf   rg   rh   ri   rj   rk   r0   rl   Trm   rn   ro   rp   rq   rD   Frr   rs   rt   ru   rv   rw   rx   ry   c                      rz   r{   r}   r%   r   r%   r&   r   g  r   z*AsyncInteractions.create.<locals>.<lambda>r   r   r   r   r   r   r   r   r   r   c              
      F  d }t  ddrt  I d H }ttj |ddS t  ddr.t  fdddd	S t  d
drat  I d H }zttj |}t	| | tj
y` } ztd ||d }~ww t  ddrt  I d H }zttj |}t| | tj
y } ztd ||d }~ww t  I d H }td |)Nr   rs   Fr   rr   c                    r   r   r   r   r   r%   r&   r     r   zMAsyncInteractions.create.<locals>._speakeasy_parse_response.<locals>.<lambda>r   r   r   r   r   r   )r   r   stream_to_text_asyncr   r   r   r   r   r   r   r   r   r   r   r   r#   r   r&   r     sp   

z;AsyncInteractions.create.<locals>._speakeasy_parse_responser   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   asyncr   r   c                 S   r   r   r   r   r%   r%   r&   r     r   r   r  r  r   r   _async_hooksr  r  r  r   r
  r   r   r  r  async_hooksr%   )+r  r   r  r  r   r  r   r   r  r  r   r   r  r   r  r  r   r  _build_request_asyncr  r  r  r8   rx   r  r  r  r	   r   r   r  r
   do_request_asyncr   r  areadr   raise_parse_error_asyncr"  r%  r   AsyncStreamedAPIResponseAsyncAPIResponser&  r%   r0  r&   r5     s  *
	
	

7
 %*/49>CHMRW\afkpuz   
          #  (  -  2  
9  D


r1  r2  c                     d}d}t }d}	|}
| |}|du r| jj}|	dur|	}n| ||}tj||d}t|
\}}
| j	d?i ddddd|d|d	|d
dddddddddd|
d|dtj
| jjjdd| jjddd|}|t kr| jjt ur| jj}ntjdtddddddd }d}t|tjr|g d!f}d"d# }t| j|pd$d%dt| jjtjdd&d'd(d)d*d'd+d,d*d'd-d.d*d'd/d0d*git|d1d2d3}| j||d4d5 |d6k|d7I dH }|d8krRtd9d:g|jr-| I dH  z	||I dH  W n+ ty, } zt| jjd;| jjd<t |||I dH  W Y d}~nd}~ww |d6kr5tj!ntj"}t#t$|||d=| t || jjd<| jjd;d>S z||I dH W S  ty } zt| jjd;| jjd<t |||I dH  W Y d}~dS d}~ww )@r4  Nr5  rf   r6  rh   r7  rj   rk   r0   rl   Frm   Trn   ro   rp   rq   rs   rt   ru   rv   rw   rx   r   r   r   r   r   r   r   r   r   r   c              
      s   d }t | ddrd S t | ddr6zttj| }t||  tjy5 } z	td| | j|d }~ww t | ddr`zttj	| }t
||  tjy_ } z	td| | j|d }~ww td| r8  r:  r@  r%   r%   r&   r     sJ   z;AsyncInteractions.delete.<locals>._speakeasy_parse_responser   rA  r   rB  r   rC  r   r   rD  r   rE  r   rF  r  r   r   c                 S   r   r   r   r   r%   r%   r&   r   D	  r   z*AsyncInteractions.delete.<locals>.<lambda>r   r  r  r   r   r  r  r  r  r%   )%r   r  r  r   r  r   rG  r   r  r  rH  r  r8   rx   r  r   r  r  r  r	   r   r   r  r
   r  r   r  r  r   r  r"  r%  r   r  r  r   r   rI  r%   r%   r&   rB    s&  

	



#


zAsyncInteractions.deleterJ  rK  rL  c          	         r  rM  r%   rO  r%   r%   r&   r%  q	  r  zAsyncInteractions.getrP  c          	         r  rM  r%   rO  r%   r%   r&   r%  	  r  c          	         r  rM  r%   rO  r%   r%   r&   r%  	  r  c                   s:  d}	d}
t }d}|} |}|du r jj}|dur|}	n |	|
}	tj|||||d}t|\}} j	dAi ddddd|	d|
d	|d
dddddddd|du r\dndd|d|dtj
 jjjdd jjddd|}|t kr jjt ur jj}ntjdtdddddd d!}d}t|tjr|g d"f} fd#d$}t j|	pd%d&dt jjtjdd'd(d)d*d+d(d,d-d+d(d.d/d+d(d0d1d+git|d2d3d4} j||d5d6 |du p|d7k|d8I dH }|d9krhtd:d;g|jr<| I dH  z	||I dH  W n+ ty; } zt jjd< jjd=t |||I dH  W Y d}~nd}~ww |d7krDtj!ntj"}t#t$||||du rSd>nd? t | jjd= jjd<d@S z||I dH W S  ty } zt jjd< jjd=t |||I dH  W Y d}~dS d}~ww )BrN  NrQ  rf   rR  rh   r7  rj   rk   r0   rl   Frm   Trn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   r   r   r   r   r   r   r   r   r   r   c              
      r  )Nr   rs   Fr   rr   c                    r   r   r   r   r   r%   r&   r   $
  r   zJAsyncInteractions.get.<locals>._speakeasy_parse_response.<locals>.<lambda>r   r   r   r   r   r   )r   r   r  r   r   r   r   r   rS  rT  r   r   rU  rV  r   r#   r   r&   r   
  sx   

z8AsyncInteractions.get.<locals>._speakeasy_parse_responser   rW  r   r%  r   rX  r   r   rY  r   rZ  r   r[  r  r   r   c                 S   r   r   r   r   r%   r%   r&   r   {
  r   z'AsyncInteractions.get.<locals>.<lambda>r   r  r  r   r   r  r  r  r  r  r%   )%r   r  r  r   r  r   r\  r   r  r  r]  r  r8   rx   r  r   r  r  r  r	   r   r   r  r
   r  r   r  r  r   r  r"  r%  r   r  r  r   r   r^  r%   r#   r&   r%  	  s2  

	
;

#


c                   r  )@r_  Nr5  rf   rg   rh   r`  rj   rk   r0   rl   Frm   Trn   ro   rp   rq   rs   rt   ru   rv   rw   rx   r   r   r   r   r   r   r   r   r   r   c              
      s   d }t | ddrttj| ddS t | ddr<zttj| }t||  tjy; } z	t	d| | j
|d }~ww t | ddrfzttj| }t||  tjye } z	t	d| | j
|d }~ww t	d| ra  rb  r@  r%   r%   r&   r   
  sV   z;AsyncInteractions.cancel.<locals>._speakeasy_parse_responser   rg  r   rh  r   ri  r   r   rj  r   rk  r   rl  r  r   r   c                 S   r   r   r   r   r%   r%   r&   r   @  r   z*AsyncInteractions.cancel.<locals>.<lambda>r   r  r  r   r   r  r  r  r  r%   )%r   r  r  r   r  r   rm  r   r  r  rn  r  r8   rx   r  r   r  r  r  r	   r   r   r  r
   r  r   r  r  r   r  r"  r%  r   r  r  r   r   rI  r%   r%   r&   rh  
  s&  

	

%

#


zAsyncInteractions.cancel).ro  rp  rq  rr  r'   r*   r   r   r   r  rs  r   r   rt  r   ru  rv  rw  r   r   r   rx  r5   ry  rz  r{  r|  r   r}  r~  r   r  r  r  r   r  r  r  r  r  r  r   r   rB  r%  rh  r%   r%   r%   r&   r    s   


	

	
6
	
6
	
6
	
6	
0	

   @
 @	
	
	
	

 kr  c                   @   r  )r  r  r1   Nc                 C   r  r  )r  r   async_to_raw_response_wrapperr5   rB  r%  rh  r  r%   r%   r&   r  o  r  z)AsyncInteractionsWithRawResponse.__init__ro  rp  rq  r  r  r%   r%   r%   r&   r  n  r  r  c                   @   r  )r  r  r1   Nc                 C   r  r  )r  r   "async_to_streamed_response_wrapperr5   rB  r%  rh  r  r%   r%   r&   r    r  z/AsyncInteractionsWithStreamingResponse.__init__r  r%   r%   r%   r&   r    r  r  ))__doc__basesdkr   r   r   r   r   r   r   r  r   r	   r
   r   r   r   r   r   r   utils.eventstreamingr   r   utils.unmarshal_json_responser   rv  typingr   r   r   r   r   r   r   r   r   r   r"   r)   r  r  r  r%   r%   r%   r&   <module>   sL   ,                      )