Restores an AI session from a serialized JSON string or struct. This function recreates an AI session with:
- Original configuration settings (temperature, limits, timeouts)
- Complete conversation history
- System message prompt
The function supports loading sessions by:
- AI engine name
- Engine ID (using `id:` prefix)
- Default engine (using `default:` prefix)
This function pairs with `SerializeAISession()` to provide persistence for AI conversations across requests or application restarts.
Lucee Function Reference
loadaisession()
Example
loadaisession(string name,any data):any
Arguments
The arguments for this function are set. You can not use other arguments except the following ones.
| Name | Type | Required | Description |
|---|---|---|---|
| name | string | Yes |
Specifies which AI endpoint configuration to use. Can be provided in two formats: 1. Direct endpoint name: The name of an endpoint as defined in the Lucee Administrator (similar to how datasource names work) 2. Default reference: Using the format "default:category" to use the endpoint configured as the default for that specific category in the Lucee Administrator. Currently supported default categories: The endpoint configurations and their default category assignments are managed in the Lucee Administrator. |
| data | any | Yes |
The serialized AI session data, which can be provided as either: 1. A JSON string previously generated by `SerializeAISession()` 2. A struct containing session configuration and conversation history Must contain the following keys: Incomplete or improperly formatted data may cause initialization errors. |