create_session¶
Operation¶
create_session
async
¶
create_session(input: CreateSessionInput, plugins: list[Plugin] | None = None) -> 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 |
|---|---|---|---|
input
|
CreateSessionInput
|
An instance of |
required |
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
|
Returns:
| Type | Description |
|---|---|
CreateSessionOutput
|
An instance of |
Input¶
CreateSessionInput
dataclass
¶
Dataclass for CreateSessionInput structure.
Attributes¶
encryption_key_arn
class-attribute
instance-attribute
¶
encryption_key_arn: str | None = 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
¶
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.
Output¶
CreateSessionOutput
dataclass
¶
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 = field(default=EMPTY_RESPONSE_METADATA, repr=False, compare=False)
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.