View a markdown version of this page

停止 AgentCore Code Interpreter 工作階段 - Amazon Bedrock AgentCore

停止 AgentCore Code Interpreter 工作階段

使用 Code Interpreter 工作階段完成後,您應該停止它以釋出資源並避免不必要的費用。

範例
AWS CLI
  1. 若要使用 CLI AWS 停止程式碼解譯器工作階段,請使用 stop-code-interpreter-session命令:

    aws bedrock-agentcore stop-code-interpreter-session \ --region <Region> \ --code-interpreter-id "<your-code-interpreter-id>" \ --session-id "<your-session-id>"
Boto3
  1. 若要使用適用於 Python 的 AWS SDK 停止程式碼解譯器工作階段,請使用 stop_code_interpreter_session方法:

    import boto3 # Initialize the boto3 client dp_client = boto3.client( 'bedrock-agentcore', region_name="<Region>", endpoint_url="https://bedrock-agentcore.<Region>.amazonaws.com" ) # Stop the Code Interpreter session response = dp_client.stop_code_interpreter_session( codeInterpreterIdentifier="aws.codeinterpreter.v1", sessionId="<your-session-id>" ) print("Session stopped successfully")
API
  1. 若要使用 API 停止程式碼解譯器工作階段,請使用下列呼叫:

    # Using awscurl awscurl -X PUT \ "https://bedrock-agentcore.<Region>.amazonaws.com/code-interpreters/aws.codeinterpreter.v1/sessions/stop?sessionId=<your-session-id>" \ -H "Content-Type: application/json" \ -H "Accept: application/json" \ --service bedrock-agentcore \ --region <Region>