AI Settings¶
Methods for managing per-user AI provider settings (/api/ai-settings).
API keys are stored as encrypted blobs — the caller encrypts with AES-256-GCM before sending; the Clann server never sees the plaintext key.
pyclann.client.AiSettingsClient
¶
Methods for user AI settings (/api/ai-settings).
get
¶
Fetch AI settings for the authenticated user.
Returns:
| Type | Description |
|---|---|
UserAiSettings
|
class: |
Raises:
| Type | Description |
|---|---|
ClannNotFoundError
|
If no settings have been configured. |
ClannAuthError
|
If not authenticated. |
upsert
¶
upsert(provider: str, model: str, *, ollama_url: str | None = None, encrypted_key: str | None = None, iv: str | None = None, auth_tag: str | None = None) -> UserAiSettings
Create or replace AI settings for the authenticated user.
API keys must be encrypted by the caller (AES-256-GCM) before being sent. The server stores only the opaque encrypted blob.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
provider
|
str
|
AI provider name, e.g. |
required |
model
|
str
|
Model identifier, e.g. |
required |
ollama_url
|
str | None
|
Base URL for Ollama, e.g. |
None
|
encrypted_key
|
str | None
|
AES-256-GCM encrypted API key (base64). |
None
|
iv
|
str | None
|
Initialisation vector (base64). |
None
|
auth_tag
|
str | None
|
GCM authentication tag (base64). |
None
|
Returns:
| Type | Description |
|---|---|
UserAiSettings
|
The upserted :class: |
Raises:
| Type | Description |
|---|---|
ClannAuthError
|
If not authenticated. |
delete
¶
Delete AI settings for the authenticated user.
Raises:
| Type | Description |
|---|---|
ClannNotFoundError
|
If no settings exist. |
ClannAuthError
|
If not authenticated. |