---
name: kimaai_admin_assistant_ai_payload
type: filter
since: 1.5.0
tier: free
feature: admin-assistant
area: admin-assistant
summary: Changes the request the admin assistant sends to the AI provider.
parameters:
  - name: ai_payload
    type: array
    description: The request to the provider, with prompt, postId, postSection, sessionId, lang, aiProvider, aiModel, maxOutputTokens, chatbot_settings, assistantSurface, assistantAllowedRenderables and assistantUserId; temperature or reasoning and text as the model supports them; tools, toolChoice, parallelToolCalls and toolConfig when tools are offered; previousResponseId when an OpenAI session continues.
  - name: payload
    type: array
    description: The normalised request payload, with prompt, postId, lang, chatbot_settings, sessionId, assistantSurface (admin_assistant), assistantAllowedRenderables, assistantUserId and selectedTools.
  - name: settings
    type: array
    description: The admin assistant's runtime settings, with chatAiProvider, chatAiModel, instructions, maxOutputTokens, temperature, reasoning, verbosity, streaming, maxMessages, maxInputLength, allowedTools and allowedRenderables.
returns:
  type: array
  description: The request to send.
surfaces: [admin_assistant]
---

# kimaai_admin_assistant_ai_payload

## When it fires

Once per admin assistant request, when the gate, the daily limit and the maximum message length have passed and the assistant's tools are resolved, right before `kimaai_admin_assistant_before_request`. The same request goes to the provider whether the answer streams or not. It also fires for the buttons of the setup workflows and the quick actions, whose callbacks often answer without the provider. It does not fire when the same message arrives again in the same session within 15 seconds: KimaAI returns the stored answer then.

The keys are KimaAI's own, not the provider's: they are turned into the provider's request later, together with the instructions and the session's history. `aiProvider` is the id of an AI environment of the settings; by default the admin assistant uses the chatbot's environment and model. During a setup workflow `prompt` can differ from what `kimaai_admin_assistant_prompt` returned, because KimaAI keeps a pasted API key out of the request. When an OpenAI session continues, `previousResponseId` names the last answer and only the new message is sent.

The admin assistant is not released yet: its panel and its routes are switched off in this release, so these requests are not sent.

## Example

```php
add_filter(
  'kimaai_admin_assistant_ai_payload',
  function (array $ai_payload, array $payload, array $settings): array {
    // Shorter answers cost less; the assistant allows 12,000 output tokens by default.
    $ai_payload['maxOutputTokens'] = min((int) $ai_payload['maxOutputTokens'], 4000);

    return $ai_payload;
  },
  10,
  3
);
```

## Related

- `kimaai_admin_assistant_before_request`: fires with the filtered request.
- `kimaai_admin_assistant_instructions`: changes the instructions the provider gets.
- `kimaai_chatbot_ai_payload`: the same filter for the chatbot.
- `kimaai_chatbot_after_response` and `kimaai_chatbot_error`: fire for the admin assistant's answers and errors too, with `assistantSurface` `admin_assistant`.
