AiModel
Defines an AI model endpoint for LLM-based features.
This object is only available with an Enterprise license.
This object can be configured from the WebUI under Settings › AI
Fields
name
Type:
String· requiredShort name for the AI Model
allowInvalidCerts
Type:
Boolean· default:falseWhether Stalwart should connect to an endpoint that has an invalid TLS certificate
temperature
Type:
Float· default:0.7· max: 1 · min: 0The temperature of the AI model, which controls the randomness of the output. A higher temperature will produce more random output.
model
Type:
String· requiredThe name of the AI model to use.
timeout
Type:
Duration· default:"2m"Maximum amount of time that Stalwart will wait for a response from this endpoint
modelType
Type:
AiModelType· default:"Chat"API type
url
Type:
Uri· requiredURL of the OpenAI compatible endpoint
httpAuth
Type:
HttpAuth· requiredThe type of HTTP authentication to use
httpHeaders
Type:
Map<String, String>Additional headers to include in HTTP requests
JMAP API
The AiModel object is available via the urn:stalwart:jmap capability.
x:AiModel/get
This is a standard Foo/get method as defined in RFC 8620, Section 5.1.
This method requires the sysAiModelGet permission.
curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:AiModel/get",
{
"ids": [
"id1"
]
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'
x:AiModel/set
This is a standard Foo/set method as defined in RFC 8620, Section 5.3.
Supports create, update, and destroy operations in a single call.
Create
This operation requires the sysAiModelCreate permission.
curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:AiModel/set",
{
"create": {
"new1": {
"allowInvalidCerts": false,
"httpAuth": {
"@type": "Unauthenticated"
},
"httpHeaders": {},
"model": "Example",
"modelType": "Chat",
"name": "Example",
"temperature": 0.7,
"timeout": "2m",
"url": "https://example.com"
}
}
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'
Update
This operation requires the sysAiModelUpdate permission.
curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:AiModel/set",
{
"update": {
"id1": {
"name": "updated value"
}
}
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'
Destroy
This operation requires the sysAiModelDestroy permission.
curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:AiModel/set",
{
"destroy": [
"id1"
]
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'
x:AiModel/query
This is a standard Foo/query method as defined in RFC 8620, Section 5.5.
This method requires the sysAiModelQuery permission.
curl -X POST https://mail.example.com/api \
-H 'Authorization: Bearer $TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"methodCalls": [
[
"x:AiModel/query",
{
"filter": {}
},
"c1"
]
],
"using": [
"urn:ietf:params:jmap:core",
"urn:stalwart:jmap"
]
}'
CLI
stalwart-cli wraps the same JMAP calls. See the CLI reference for installation, authentication, and general usage.
Fetch
stalwart-cli get ai-model id1
Create
stalwart-cli create ai-model \
--field name=Example \
--field allowInvalidCerts=false \
--field temperature=0.7 \
--field model=Example \
--field timeout=2m \
--field modelType=Chat \
--field url=https://example.com \
--field 'httpAuth={"@type":"Unauthenticated"}' \
--field 'httpHeaders={}'
Query
stalwart-cli query ai-model
Update
stalwart-cli update ai-model id1 --field description='Updated'
Delete
stalwart-cli delete ai-model --ids id1
Nested types
HttpAuth
Defines the HTTP authentication method to use for HTTP requests.
Unauthenticated: Anonymous. No additional fields.Basic: Basic Authentication. Carries the fields ofHttpAuthBasic.Bearer: Bearer Token. Carries the fields ofHttpAuthBearer.
HttpAuthBasic
HTTP Basic authentication credentials.
username
Type:
String· requiredUsername for HTTP Basic Authentication
secret
Type:
SecretKey· requiredPassword for HTTP Basic Authentication
SecretKey
A secret value provided directly, from an environment variable, or from a file.
Value: Secret value. Carries the fields ofSecretKeyValue.EnvironmentVariable: Secret read from environment variable. Carries the fields ofSecretKeyEnvironmentVariable.File: Secret read from file. Carries the fields ofSecretKeyFile.
SecretKeyValue
A secret value provided directly.
secret
Type:
String· required · secretPassword or secret value
SecretKeyEnvironmentVariable
A secret value read from an environment variable.
variableName
Type:
String· requiredEnvironment variable name to read the secret from
SecretKeyFile
A secret value read from a file.
filePath
Type:
String· requiredFile path to read the secret from
HttpAuthBearer
HTTP Bearer token authentication.
bearerToken
Type:
SecretKey· requiredBearer token for HTTP Bearer Authentication
Enums
AiModelType
| Value | Label |
|---|---|
Chat | Chat Completion |
Text | Text Generation |