X Enterprises
Composables

useXAdminAI

Manages AI chat sessions and agent configuration, providing methods to select agents, send messages, stream responses, and create new agents.

useXAdminAI

AI and agent management composable. Wraps /api/admin/ai/* endpoints with methods for selecting agents, sending messages (standard and streamed), and creating or editing agent configurations. Pairs with XAdminAIChat, XAdminAIAgents, and XAdminAIAgentEditor.

Usage

const ai = useXAdminAI()

await ai.selectAgent(agentId)
await ai.sendMessage("Hello!")
await ai.streamMessage("Generate a report", (chunk) => console.log(chunk))
await ai.createAgent({ name: "Support Bot", systemPrompt: "..." })

Returns

KeyTypeDescription
selectAgent(agentId: string) => Promise<void>Sets the active agent for subsequent chat interactions.
sendMessage(message: string) => Promise<void>Sends a message to the active agent and awaits the full response.
streamMessage(message: string, onChunk: (chunk: string) => void) => Promise<void>Streams an agent response, invoking the callback for each chunk.
createAgent(config: { name: string; systemPrompt: string; [key: string]: unknown }) => Promise<void>Creates a new AI agent with the provided configuration.

AI Context

composable: useXAdminAI
package: "@xenterprises/nuxt-x-app-admin"
use-when: >
  Operating the AI assistant panel in the admin portal — selecting agents,
  running chat sessions, streaming responses in real time, or creating and
  configuring new AI agents.
pairs-with: XAdminAIChat, XAdminAIAgents, XAdminAIAgentEditor
Copyright © 2026