Skip to main content
Embed an AI agent conversation directly into your web app. Choose the level of control that fits your needs — drop-in component, headless state manager, or a single API call.

Drop-in component

One HTML tag, everything handled — input, streaming, scrolling.
With context and a custom placeholder:

Attributes

Events

The component dispatches DOM events you can listen to:
The same events also fire on Gleap.on(...) without the gleap- prefix:

Headless with Gleap.createAgentChat()

Manage state and streaming yourself, render any UI you want.
Options
  • agentId – the agent to talk to (defaults to "kai").
  • context – arbitrary object passed to the agent.
  • conversationId – resume an existing conversation.
  • onChange({ messages, isExecuting, error, conversationId }) – called whenever state changes.
  • onToken, onReplyReceived, onError, onConversationCreated – optional lifecycle callbacks.
Returned instance
  • sendMessage(content) – send a user message (streams the reply).
  • setContext(context) – update the context for future messages.
  • clearMessages() – clear messages and start a new conversation.
  • cancelStream() – abort the in-flight stream.
  • getState(){ messages, isExecuting, error, conversationId }.
  • destroy() – tear down listeners. Always call when unmounting.
Each message is { id, role, content, createdAt, isStreaming? }. isStreaming is true while tokens are still arriving. To clear cached conversation state across the page (e.g. on logout):

Raw API

One call, you handle everything else.
Returns a Promise that resolves to { runId, status, response, conversationId }.

Custom styling

The drop-in component renders inside an iframe and accepts agentColor / dark for basic theming. For full control over the UI, use the headless createAgentChat() API and render your own components.