Skip to content
ClickHouse Docs
ClickHouse DocsClickHouse Docs

ai_function_* session settings

These settings are available in system.settings and are autogenerated from source.

ai_function_allow_insecure_endpoint

Beta feature
Type
Bool
Default
0
Version history
VersionDefault valueComment
26.80AI functions now reject insecure (http) endpoints to remote hosts by default.

If false (default), AI functions refuse to use a named-collection endpoint that would send prompts and API keys over an unencrypted connection to a remote host: any non-HTTPS endpoint whose host is not loopback is rejected with an exception. Loopback endpoints (e.g. a local http://localhost model server) are always allowed. Set to true to permit plaintext http:// endpoints on remote hosts.

ai_function_embedding_default_credentials

Beta feature
Version history
VersionDefault valueComment
26.8New setting

Name of the named collection used by the embedding functions (aiEmbed, aiSimilarity) when the call does not pass credentials in its parameter map. Empty means no default: such calls must pass credentials explicitly. These functions take model as a required positional argument, not from the named collection. Kept separate from ai_function_text_default_credentials because an embeddings endpoint differs from a chat one.

ai_function_embedding_max_batch_size

Beta feature
Type
NonZeroUInt64
Default
100
Version history
VersionDefault valueComment
26.6100New setting

Maximum number of texts to include in a single HTTP request made by the embedding functions (aiEmbed, aiSimilarity). Texts are grouped into batches of this size to reduce API call overhead. For example, 500 unique texts with a batch size of 100 result in 5 HTTP requests.

ai_function_max_api_calls_per_query

Beta feature
Type
UInt64
Default
1000
Version history
VersionDefault valueComment
26.81000Bound outbound AI function HTTP calls per query by default (previously 0 - unlimited).
26.40New setting

Maximum number of HTTP requests that AI functions may dispatch per query. Enforced independently by each server and query fragment: within one execution context it is an exact cap shared by every AI function, block, and thread there, but a distributed query (across shards or parallel-replica fragments) may dispatch up to this many requests per shard/fragment. It must be set in the top-level query - a sub-query SETTINGS override is ignored. Set to 0 to disable.

ai_function_max_input_tokens_per_query

Beta feature
Type
UInt64
Default
1000000
Version history
VersionDefault valueComment
26.41000000New setting

Maximum total input (prompt) tokens across all AI function API calls in a single query. Tracked cumulatively from provider responses. Note that this limit may be exceeded by up to one call’s worth of input tokens per in-flight request, since a call’s input tokens are not known until its response arrives. Like the other AI quotas, it is enforced per server / query fragment, not summed across a distributed query, and must be set in the top-level query - a sub-query SETTINGS override is ignored. Set to 0 to disable.

This limit is only enforced for providers that report a usage object in their response (OpenAI, Anthropic, vLLM). Providers that omit token usage (notably HuggingFace TEI) cause the counter to stay at 0 — use ai_function_max_api_calls_per_query instead to bound such calls.

ai_function_max_output_tokens_per_query

Beta feature
Type
UInt64
Default
500000
Version history
VersionDefault valueComment
26.4500000New setting

Maximum total output (completion) tokens across all AI function API calls in a single query. Tracked cumulatively from provider responses. Note that this limit may be exceeded by up to one call’s worth of output tokens per in-flight request, since a call’s output tokens are not known until its response arrives. Like the other AI quotas, it is enforced per server / query fragment, not summed across a distributed query, and must be set in the top-level query - a sub-query SETTINGS override is ignored. Set to 0 to disable.

This limit is only enforced for providers that report a usage object in their response (OpenAI, Anthropic, vLLM). It does not apply to the embedding functions (aiEmbed, aiSimilarity), which never produce output tokens.

ai_function_max_retries

Beta feature
Type
UInt64
Default
1
Version history
VersionDefault valueComment
26.91Retry a transient API error once by default, so a single 429 or 5xx from the provider does not fail the query.
26.40New setting

Maximum number of retry attempts for transient errors per individual API request. Each retry uses exponential backoff starting from ai_function_retry_initial_delay_ms.

ai_function_request_timeout_sec

Beta feature
Type
UInt64
Default
60
Version history
VersionDefault valueComment
26.460New setting

Timeout in seconds for individual HTTP requests made by AI functions (AI chat completions and embedding API calls). If a request does not complete within this time, it is considered failed and may be retried according to ai_function_max_retries.

ai_function_retry_initial_delay_ms

Beta feature
Type
UInt64
Default
1000
Version history
VersionDefault valueComment
26.41000New setting

Initial delay in milliseconds before the first retry of a failed AI function API request. The delay doubles on each subsequent attempt (exponential backoff). For example, with default settings: 1000ms, 2000ms, 4000ms.

ai_function_text_default_credentials

Beta feature
Version history
VersionDefault valueComment
26.8New setting

Name of the named collection used by the text AI functions (aiGenerate, aiClassify, aiFilter, aiExtract, aiTranslate, aiRedact) when the call does not pass credentials in its parameter map. Empty means no default: such calls must pass credentials explicitly. A chat-completions endpoint differs from an embeddings one, so this is separate from ai_function_embedding_default_credentials.

ai_function_throw_on_error

Beta feature
Type
Bool
Default
1
Version history
VersionDefault valueComment
26.41New setting

If true (default), an AI function call that fails permanently after exhausting all retries aborts the query with an exception. If false, the failed row receives the default value for the column type (empty string for String) and processing continues.

ai_function_throw_on_quota_exceeded

Beta feature
Type
Bool
Default
1
Version history
VersionDefault valueComment
26.41New setting

If true (default), exceeding an AI function quota limit (ai_function_max_input_tokens_per_query, ai_function_max_output_tokens_per_query, or ai_function_max_api_calls_per_query) aborts the query with an exception. If false, remaining rows receive the default value for the column type (empty string for String). Like the quota limits, this must be set in the top-level query - a sub-query SETTINGS override is ignored.

Navigation