invoke_code_interpreter¶
Operation¶
Async only
This operation uses an event stream, so only the asynchronous client supports it.
invoke_code_interpreter
async
¶
invoke_code_interpreter(request: InvokeCodeInterpreterInput | InvokeCodeInterpreterInputDict | None = None, /, *, plugins: list[Plugin] | None = None, **kwargs: Unpack[InvokeCodeInterpreterInputDict]) -> AsyncOutputEventStream[CodeInterpreterStreamOutput, InvokeCodeInterpreterOutput]
Executes code within an active code interpreter session in Amazon Bedrock AgentCore. This operation processes the provided code, runs it in a secure environment, and returns the execution results including output, errors, and generated visualizations.
To execute code, you must specify the code interpreter identifier, session ID, and the code to run in the arguments parameter. The operation returns a stream containing the execution results, which can include text output, error messages, and data visualizations.
This operation is subject to request rate limiting based on your account's service quotas.
The following operations are related to InvokeCodeInterpreter:
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
InvokeCodeInterpreterInput | InvokeCodeInterpreterInputDict | None
|
The input as a model or dictionary. Pass this or keyword arguments, not both. |
None
|
plugins
|
list[Plugin] | None
|
A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations. |
None
|
**kwargs
|
Unpack[InvokeCodeInterpreterInputDict]
|
The input fields as keyword arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
AsyncOutputEventStream[CodeInterpreterStreamOutput, InvokeCodeInterpreterOutput]
|
An |
Input¶
Pass the input as keyword arguments, a positional dictionary, or a positional model object. Pass plugins separately as a keyword argument.
InvokeCodeInterpreterInputDict
¶
Bases: TypedDict
Dictionary form of InvokeCodeInterpreterInput.
Attributes¶
arguments
instance-attribute
¶
arguments: ToolArguments | ToolArgumentsDict | None
The arguments for the code interpreter. This includes the code to execute and any additional parameters such as the programming language, whether to clear the execution context, and other execution options. The structure of this parameter depends on the specific code interpreter being used.
code_interpreter_identifier
instance-attribute
¶
The unique identifier of the code interpreter associated with the
session. This must match the identifier used when creating the session
with StartCodeInterpreterSession.
InvokeCodeInterpreterInput
dataclass
¶
Bases: _SerdeShape
Dataclass for InvokeCodeInterpreterInput structure.
Attributes¶
arguments
class-attribute
instance-attribute
¶
arguments: ToolArguments | None = ...
The arguments for the code interpreter. This includes the code to execute and any additional parameters such as the programming language, whether to clear the execution context, and other execution options. The structure of this parameter depends on the specific code interpreter being used.
code_interpreter_identifier
class-attribute
instance-attribute
¶
code_interpreter_identifier: str | None = ...
The unique identifier of the code interpreter associated with the
session. This must match the identifier used when creating the session
with StartCodeInterpreterSession.
name
class-attribute
instance-attribute
¶
name: str | None = ...
The name of the code interpreter to invoke.
session_id
class-attribute
instance-attribute
¶
session_id: str | None = ...
The unique identifier of the code interpreter session to use. This must
be an active session created with StartCodeInterpreterSession. If the
session has expired or been stopped, the request will fail.
Output¶
This operation returns an AsyncOutputEventStream for server-to-client streaming.
Event Stream Structure¶
Output Event Type¶
Initial Response Structure¶
InvokeCodeInterpreterOutput
dataclass
¶
Bases: _SerdeShape
Dataclass for InvokeCodeInterpreterOutput structure.