AgentsforBedrockRuntime / Client / create_session

create_session#

AgentsforBedrockRuntime.Client.create_session(**kwargs)#

Creates a session to temporarily store conversations for generative AI (GenAI) applications built with open-source frameworks such as LangGraph and LlamaIndex. Sessions enable you to save the state of conversations at checkpoints, with the added security and infrastructure of Amazon Web Services. For more information, see Store and retrieve conversation history and context with Amazon Bedrock sessions.

By default, Amazon Bedrock uses Amazon Web Services-managed keys for session encryption, including session metadata, or you can use your own KMS key. For more information, see Amazon Bedrock session encryption.

Note

You use a session to store state and conversation history for generative AI applications built with open-source frameworks. For Amazon Bedrock Agents, the service automatically manages conversation context and associates them with the agent-specific sessionId you specify in the InvokeAgent API operation.

Related APIs:

See also: AWS API Documentation

Request Syntax

response = client.create_session(
    encryptionKeyArn='string',
    sessionMetadata={
        'string': 'string'
    },
    tags={
        'string': 'string'
    }
)
Parameters:
  • encryptionKeyArn (string) – The Amazon Resource Name (ARN) of the KMS key to use to encrypt the session data. The user or role creating the session must have permission to use the key. For more information, see Amazon Bedrock session encryption.

  • sessionMetadata (dict) –

    A map of key-value pairs containing attributes to be persisted across the session. For example, the user’s ID, their language preference, and the type of device they are using.

    • (string) –

      • (string) –

  • tags (dict) –

    Specify the key-value pairs for the tags that you want to attach to the session.

    • (string) –

      Key of a tag

      • (string) –

        Value of a tag

Return type:

dict

Returns:

Response Syntax

{
    'createdAt': datetime(2015, 1, 1),
    'sessionArn': 'string',
    'sessionId': 'string',
    'sessionStatus': 'ACTIVE'|'EXPIRED'|'ENDED'
}

Response Structure

  • (dict) –

    • createdAt (datetime) –

      The timestamp for when the session was created.

    • sessionArn (string) –

      The Amazon Resource Name (ARN) of the created session.

    • sessionId (string) –

      The unique identifier for the session.

    • sessionStatus (string) –

      The current status of the session.

Exceptions