Skip to content

create_session

Operation

create_session

create_session(request: CreateSessionInput | CreateSessionInputDict | None = None, /, *, plugins: list[Plugin] | None = None, **kwargs: Unpack[CreateSessionInputDict]) -> CreateSessionOutput

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:

Parameters:

Name Type Description Default
request CreateSessionInput | CreateSessionInputDict | 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[CreateSessionInputDict]

The input fields as keyword arguments.

{}

Returns:

Type Description
CreateSessionOutput

An instance of CreateSessionOutput.

create_session async

create_session(request: CreateSessionInput | CreateSessionInputDict | None = None, /, *, plugins: list[Plugin] | None = None, **kwargs: Unpack[CreateSessionInputDict]) -> CreateSessionOutput

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:

Parameters:

Name Type Description Default
request CreateSessionInput | CreateSessionInputDict | 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[CreateSessionInputDict]

The input fields as keyword arguments.

{}

Returns:

Type Description
CreateSessionOutput

An instance of CreateSessionOutput.

Input

Pass the input as keyword arguments, a positional dictionary, or a positional model object. Pass plugins separately as a keyword argument.

CreateSessionInputDict

Bases: TypedDict

Dictionary form of CreateSessionInput.

Attributes

encryption_key_arn instance-attribute
encryption_key_arn: str | None

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.

session_metadata instance-attribute
session_metadata: Mapping[str, str] | None

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.

tags instance-attribute
tags: Mapping[str, str] | None

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

CreateSessionInput dataclass

Bases: _SerdeShape

Dataclass for CreateSessionInput structure.

Attributes

encryption_key_arn class-attribute instance-attribute
encryption_key_arn: str | None = ...

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.

session_metadata class-attribute instance-attribute
session_metadata: dict[str, str] | None = ...

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.

tags class-attribute instance-attribute
tags: dict[str, str] | None = ...

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

Output

CreateSessionOutput dataclass

Bases: _SerdeShape

Dataclass for CreateSessionOutput structure.

Attributes

created_at instance-attribute
created_at: datetime

The timestamp for when the session was created.

response_metadata class-attribute instance-attribute
response_metadata: ResponseMetadata = ...

Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.

session_arn instance-attribute
session_arn: str

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

session_id instance-attribute
session_id: str

The unique identifier for the session.

session_status instance-attribute
session_status: str

The current status of the session.