Skip to Content

API Documentation

The ElementsConfig object accepts the following configuration options:

Configuration options

Top-Level Configuration

Property
Type
Required
No
Default
Description
The system prompt to use for the Elements library
Type
Required
Yes
Default
Description
The project slug to use for the Elements library
Type
Required
Yes
Default
Description
The Gram Server URL. Can be retrieved from
Type
Required
No
Default
Description
The path of your backend's chat endpoint
Type
Required
No
Default
Description
Custom environment variable overrides for the MCP server. See Gram documentation  for pass-through authentication
Type
Required
No
Default
Description
The layout variant for the chat interface.
is a popup modal,
is a side panel,
is a full-page experience
Type
Required
No
Default
Description
Array of plugins to extend rendering capabilities. See Plugins for details
Type
Required
No
Default
Description
Override default UI components with custom implementations. See Component Overrides section for details
Type
Required
No
Default
Description
Visual appearance configuration options
Type
Required
Yes
Default
Description
Configuration for the welcome message and initial suggestions
Type
Required
No
Default
Description
Configuration for the composer input
Type
Required
No
Default
Description
Configuration for the modal window (does not apply if variant is
)
Type
Required
No
Default
Description
Configuration for the sidecar panel (only applies if variant is
)
Type
Required
No
Default
Description
LLM model configuration
Type
Required
No
Default
Description
Configuration for custom tool components

Welcome Configuration (WelcomeConfig)

Property
Type
Required
Yes
Default
Description
The welcome message title to display when the thread is empty
Type
Required
Yes
Default
Description
The subtitle to display when the thread is empty
Type
Required
No
Default
Description
Array of suggestion prompts to display when the thread is empty

Suggestion Object

Property
Type
Required
Yes
Description
The title of the suggestion
Type
Required
Yes
Description
The label text for the suggestion
Type
Required
Yes
Description
The prompt text that will be sent when clicked

Composer Configuration (ComposerConfig)

Property
Type
Required
No
Default
Description
The placeholder text for the composer input
Type
Required
No
Default
Description
Configuration for file attachments. Set to
to disable,
for defaults, or provide an object for fine-grained control

Attachments Configuration (AttachmentsConfig)

Property
Type
Required
No
Default
Description
Accepted file types (MIME types or extensions), e.g.,
Type
Required
No
Default
Description
Maximum number of files that can be attached at once
Type
Required
No
Default
Description
Maximum file size in bytes (default: 100MB)
Property
Type
Required
No
Default
Description
Whether to open the modal window by default
Type
Required
No
Default
Description
The title displayed in the modal header
Type
Required
No
Default
Description
The position of the modal trigger button
Type
Required
No
Default
Description
Custom icon component function that receives the modal state
Type
Required
No
Default
Description
Whether the modal can be expanded to full screen
Type
Required
No
Default
Description
The dimensions for default and expanded states of the modal

Dimensions Object

Property
Type
Description
The dimensions for the default state of the modal
Type
Description
The dimensions for the expanded state of the modal

Dimension Object

Property
Type
Description
Width of the modal
Type
Description
Height of the modal
Type
Description
Maximum height of the modal (optional)
Property
Type
Description
Width of the modal
Type
Description
Height of the modal
Type
Description
Maximum height of the modal (optional)

Sidecar Configuration (SidecarConfig)

Property
Type
Required
No
Default
Description
Whether the sidecar can be expanded to full screen
Type
Required
No
Default
Description
The dimensions for default and expanded states of the sidecar

Theme Configuration (ThemeConfig)

Property
Type
Required
No
Default
Description
The color scheme to use for the UI
Type
Required
No
Default
Description
Determines the overall spacing.
reduces padding,
increases padding
Type
Required
No
Default
Description
Determines the overall roundness.
is large radius,
is minimal radius

Model Configuration (ModelConfig)

Property
Type
Required
No
Default
Description
Whether to show the model picker in the composer
Type
Required
No
Default
Description
The default model to use

Available Models

The following models are currently supported:

  • anthropic/claude-sonnet-4.5
  • anthropic/claude-haiku-4.5
  • anthropic/claude-sonnet-4
  • anthropic/claude-opus-4.5
  • openai/gpt-4o
  • openai/gpt-4o-mini
  • openai/gpt-5.1-codex
  • openai/gpt-5
  • openai/gpt-5.1
  • openai/gpt-4.1
  • anthropic/claude-3.7-sonnet
  • anthropic/claude-opus-4
  • google/gemini-2.5-pro-preview
  • google/gemini-3-pro-preview
  • moonshotai/kimi-k2
  • mistralai/mistral-medium-3
  • mistralai/mistral-medium-3.1
  • mistralai/codestral-2501

Tools Configuration (ToolsConfig)

You can override the default React components for specific tool results with the components property. Tool names must match exactly.

Property
Type
Required
No
Default
Description
Override default React components for specific tool results. Tool names must match exactly

Component Overrides

The components property in ElementsConfig allows you to override default UI components with your own custom implementations. This provides fine-grained control over the appearance and behavior of different parts of the chat interface.

Available Component Overrides

Component
Type
Description
The composer input area where users type messages
Type
Description
The entire user message bubble/container
Type
Description
The composer shown when editing a user message
Type
Description
The entire assistant message bubble/container
Type
Description
The welcome screen shown when the thread is empty
Type
Description
Text content within messages (supports Markdown by default)
Type
Description
Image attachments within messages
Type
Description
Default component for tool results without custom components
Type
Description
Individual reasoning steps shown in assistant messages
Type
Description
Container for grouped reasoning steps
Type
Description
Container for grouped tool calls

Component Override Examples

Basic Text Override

Override how text is rendered in assistant messages:

import { ElementsConfig } from '@gram-ai/elements' import { useAssistantState } from '@assistant-ui/react' const config: ElementsConfig = { projectSlug: 'my-project', mcp: 'https://app.getgram.ai/mcp/my-mcp-slug', welcome: { title: 'Hello!', subtitle: 'How can I help you today?', }, components: { Text: () => { const message = useAssistantState(({ message }) => message) const text = message.parts .map((part) => (part.type === 'text' ? part.text : '')) .join('') return ( <div className="custom-text"> {text} </div> ) }, }, }

Custom Welcome Screen

Override the welcome screen with your own design:

import { ElementsConfig } from '@gram-ai/elements' const CustomWelcome = () => { return ( <div className="flex flex-col items-center justify-center h-full"> <h1 className="text-4xl font-bold mb-4">Welcome to My AI Assistant!</h1> <p className="text-gray-600">Start chatting below</p> </div> ) } const config: ElementsConfig = { projectSlug: 'my-project', mcp: 'https://app.getgram.ai/mcp/my-mcp-slug', welcome: { title: 'Hello!', subtitle: 'How can I help you today?', }, components: { ThreadWelcome: CustomWelcome, }, }

Custom Message Containers

Override the entire message container for more control:

import { ElementsConfig } from '@gram-ai/elements' import { MessagePrimitive } from '@assistant-ui/react' const CustomUserMessage = () => { return ( <MessagePrimitive.Root> <div className="my-custom-user-message"> <div className="message-avatar">👤</div> <div className="message-content"> <MessagePrimitive.Parts /> </div> </div> </MessagePrimitive.Root> ) } const config: ElementsConfig = { projectSlug: 'my-project', mcp: 'https://app.getgram.ai/mcp/my-mcp-slug', welcome: { title: 'Hello!', subtitle: 'How can I help you today?', }, components: { UserMessage: CustomUserMessage, }, }

Combining Multiple Overrides

You can override multiple components at once:

import { ElementsConfig } from '@gram-ai/elements' import { CustomComposer, CustomUserMessage, CustomAssistantMessage, CustomText, } from './components' const config: ElementsConfig = { projectSlug: 'my-project', mcp: 'https://app.getgram.ai/mcp/my-mcp-slug', welcome: { title: 'Hello!', subtitle: 'How can I help you today?', }, components: { Composer: CustomComposer, UserMessage: CustomUserMessage, AssistantMessage: CustomAssistantMessage, Text: CustomText, }, }

Notes on Component Overrides

  • Component overrides give you full control over rendering, but you’re responsible for maintaining the expected behavior
  • When overriding message containers (UserMessage, AssistantMessage), make sure to include MessagePrimitive.Root and MessagePrimitive.Parts to maintain compatibility with the assistant-ui runtime
  • For text content overrides, the default Text component supports Markdown rendering. If you override it, you’ll need to implement your own Markdown support if needed
  • Component overrides are applied globally across your chat interface
  • For building custom components from scratch, refer to the assistant-ui Context API documentation  which provides detailed information about the state management system, available actions, and hooks like useAssistantState, useAssistantApi, and useAssistantEvent

Configuration Examples

Minimal Configuration

import { ElementsConfig } from '@gram-ai/elements' const config: ElementsConfig = { projectSlug: 'my-project', mcp: 'https://app.getgram.ai/mcp/my-mcp-slug', welcome: { title: 'Welcome!', subtitle: 'How can I assist you today?', }, }

Full Configuration with All Options

import { ElementsConfig } from '@gram-ai/elements' import { recommended } from '@gram-ai/elements/plugins' import { WeatherComponent } from './components/WeatherComponent' import { CustomText } from './components/CustomText' const config: ElementsConfig = { systemPrompt: 'You are a helpful AI assistant.', projectSlug: 'my-project', mcp: 'https://app.getgram.ai/mcp/my-mcp-slug', chatEndpoint: '/api/chat', variant: 'widget', plugins: recommended, components: { Text: CustomText, }, theme: { colorScheme: 'system', density: 'normal', radius: 'soft', }, environment: { API_KEY: 'your-api-key', BASE_URL: 'https://api.example.com', }, welcome: { title: 'Hello!', subtitle: 'How can I help you today?', suggestions: [ { title: 'Get Weather', label: 'Check current weather', action: 'What is the weather like today?', }, { title: 'Summarize', label: 'Summarize a document', action: 'Can you summarize this document for me?', }, ], }, composer: { placeholder: 'Type your message...', }, modal: { defaultOpen: false, title: 'AI Assistant', position: 'bottom-right', expandable: true, dimensions: { default: { width: 400, height: 600, maxHeight: '90%', }, expanded: { width: '90%', height: '90%', }, }, }, model: { showModelPicker: true, defaultModel: 'anthropic/claude-sonnet-4.5', }, tools: { components: { get_current_weather: WeatherComponent, }, }, }

Contributing

We welcome pull requests to Elements. Please read the contributing guide.

Last updated on