Skip to content

AI request: before provider call

Plugin ID: ai_eca_interceptor:ai_request

Available since: 2.0.0

Provided tokens

Token Description
[user] The current user.
Alias: current_user
[htmx] Information about the current HTMX request.
[htmx:is_request] Whether the current request was sent by HTMX ("1" or "0").
[htmx:boosted] Whether the current request was boosted by HTMX ("1" or "0").
[htmx:history_restore] Whether the current request is for HTMX history restoration ("1" or "0").
[htmx:target] The identifier of the element the response is targeted at.
[htmx:trigger] The identifier of the element that triggered the request. On Drupal 11 this is the element id, on Drupal 12 and later it is the CSS selector that htmx 4 sends. Prefer "trigger_name", which means the same thing on both.
[htmx:trigger_name] The name attribute of the element that triggered the request, or empty if it has none. This has the same meaning on all supported Drupal versions.
[htmx:source] The CSS selector of the element that triggered the request, for example button[name="first_item"]. Empty on Drupal 11, which does not send this information.
[htmx:request_type] Whether the request targets a full page or a fragment: "full" or "partial". Empty on Drupal 11, which does not send this information.
[htmx:current_url] The URL of the page the request was sent from.
[event] The AI event.
[event:machine_name] Machine name of the triggered ECA event (e.g. ai.pre_generate_response).
[event:request_thread_id] Unique id of the AI request thread.
[event:request_parent_id] Parent request id if this request was initiated from another AI request.
[event:provider_id] The AI provider id that will execute (or did execute) the call.
[event:model_id] The AI model id.
[event:operation_type] Operation type: chat, embeddings, moderation, speech_to_text, text_to_speech, etc.
[event:tags] Tags attached to the request (array).
[event:tag_count] Number of tags attached to the request.
[event:configuration] Provider configuration array (temperature, max_tokens, …).
[event:debug_data] Debug data attached to the request.
[event:metadata] All metadata on the event, including reroute directives.
[event:is_chat] 1 when the operation type is "chat", 0 otherwise.
[event:input] The raw input DTO flattened to an array (input->toArray()).
[event:input_class] Fully qualified class name of the input DTO.
[event:input_text] Best-effort textual representation of the input (chat prompts joined, summarization/translation/moderation text, etc.).
[event:chat_tools] Chat only. The declared tools rendered to an array.
[event:chat_tool_names] Chat only. The names of the declared tool functions (array).
[event:chat_tool_count] Chat only. Number of declared tool functions.
[event:chat_has_tools] Chat only. 1 when the request declares any tools, 0 otherwise.
[event:chat_has_schema] Chat only. 1 when the request declares a structured JSON schema, 0 otherwise.
[event:chat_streamed] Chat only. 1 when the request asked for streamed output, 0 otherwise.
[event] The event.
[event:machine_name] The machine name of the ECA event.
[session_user] The user account that dispatched the event, regardless if ECA is processing models under a different account. This is only available if ECA is configured to always run under a specific account.

Fields

Operation type filter — config key: operation_type

Limit to a specific AI operation type (e.g. "chat", "embeddings"). Leave empty for any.

Type: textfield · Required: no · Default: empty string

Provider id filter — config key: provider_id

Limit to a specific provider id. Leave empty for any.

Type: textfield · Required: no · Default: empty string

Model id filter — config key: model_id

Limit to a specific model id. Leave empty for any.

Type: textfield · Required: no · Default: empty string