Skip to main content

AI Chat Plugin

Backend and frontend plugins powering the embedded AI Agent Chat β€” a provider-pluggable AI assistant that answers questions about tenant data and operates the platform UI with user approval.

Overview​

PropertyValue
Package@gauzy/plugin-ai-chat
Sourcepackages/plugins/ai-chat
UI Package@gauzy/plugin-ai-chat-react-ui
UI Sourcepackages/plugins/ai-chat-react-ui
API EndpointsSee API Endpoints below

API Endpoints​

EndpointPurpose
POST /api/ai-chatOne chat turn as a streaming UI message response
GET /api/ai-chat/configFeature/provider availability for the current tenant (no secrets)
POST /api/ai-chat/transcribeSpeech-to-text for the chat's voice dictation (25 MB limit)
POST /api/ai-chat/attachmentsFallback chat-local file storage when the Documents feature is unavailable (uploads normally go straight to the Documents upload endpoint with source CHAT)
GET /api/ai-chat/providers/:id/modelsA provider's model catalogue, for the settings model picker
GET/POST/PUT/DELETE /api/ai-chat/credentialsPer-tenant BYOK credential management (keys masked on read)
POST /api/ai-chat/credentials/connectCompletes a provider "Connect" flow (OpenRouter PKCE) server-side
GET/DELETE /api/ai-chat/conversationsPer-user chat history

Providers​

Each AI provider is its own plugin implementing IAiChatProviderDefinition, registered in the AiProviderRegistry:

ProviderStatusDefault Model
AnthropicDefaultclaude-sonnet-5
OpenAISupported (also powers voice dictation)gpt-5.5
OpenRouterSupported (Connect flow + optional shared free tier)anthropic/claude-sonnet-5
Google GeminiSupportedgemini-3.5-flash
xAI GrokSupportedgrok-4.3
Vercel AI GatewaySupportedanthropic/claude-sonnet-5
Gauzy AIPlaceholderβ€”
note

The Gauzy AI provider is currently a placeholder β€” chat traffic is not yet routed through the Gauzy AI server. Use one of the other providers.

Configuration​

There are two ways to configure provider credentials. Per-tenant keys take precedence over server environment variables.

Users with the AI_CHAT_SETTINGS permission can add provider API keys under Settings β†’ AI Providers. Keys are stored encrypted at rest using the server's ENCRYPTION_KEY.

Option 2: Server environment variables​

# Enable the AI chat feature
GAUZY_AI_CHAT_ENABLED=true

# Default provider and model
GAUZY_AI_CHAT_DEFAULT_PROVIDER=anthropic
GAUZY_AI_CHAT_DEFAULT_MODEL=claude-sonnet-5

# Provider API keys (set the ones you use)
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
OPENROUTER_API_KEY=sk-or-...
GEMINI_API_KEY=... # or GOOGLE_GENERATIVE_AI_API_KEY
XAI_API_KEY=... # or GROK_API_KEY
AI_GATEWAY_API_KEY=...

# Optional: custom base URLs per provider
# ANTHROPIC_BASE_URL=...
# OPENAI_BASE_URL=...
# OPENROUTER_BASE_URL=...

Option 3: Shared free tier (operator-provided)​

# A platform-supplied OpenRouter key shared by all tenants that have no key of
# their own. Restricted to the provider's FREE models β€” enforced server-side.
OPENROUTER_PLATFORM_API_KEY=sk-or-...

The platform key is resolved last β€” after the tenant's own key and after the operator's OPENROUTER_API_KEY β€” so it never downgrades anyone who brought a paid key. When a shared free-tier request is rate-limited, the chat tells the user and suggests adding their own key.

Advanced options​

VariableDescription
GAUZY_AI_CHAT_MCP_URLConnect the agent to an external MCP server for extra tools. Off by default.
GAUZY_AI_CHAT_SELF_API_URLOverride the base URL the agent uses to call the Gauzy API itself
caution

GAUZY_AI_CHAT_MCP_URL is an advanced option. Any MCP server you connect gains tool-level access within the agent loop β€” only point it at servers you control and trust.

Security Model​

  • User-scoped API access β€” the agent calls the Gauzy REST API with the requesting user's own JWT. Role-based access control and tenant isolation always apply; the agent can never read or write more than the user could via the UI.
  • Human-in-the-loop mutations β€” tools that modify data (form submission, create/update/delete) require explicit user approval in the chat before executing.
  • Encrypted credentials β€” per-tenant BYOK keys are encrypted with ENCRYPTION_KEY and never sent to the browser.

Architecture​

  • Frontend β€” @gauzy/plugin-ai-chat-react-ui renders the chat sidebar using the Vercel AI SDK 7 and its streaming UI message protocol.
  • Backend β€” @gauzy/plugin-ai-chat exposes the routes listed under API Endpoints: the chat stream, runtime config, voice transcription, per-provider model catalogues, BYOK credential management (including the Connect exchange), and per-user conversation history.
  • Providers β€” one plugin per provider, each implementing IAiChatProviderDefinition and registering itself in the AiProviderRegistry.

For implementation details, see the package READMEs on GitHub: