API Documentation
The ElementsConfig object accepts the following configuration options:
Configuration options
Top-Level Configuration
Welcome Configuration (WelcomeConfig)
Suggestion Object
Composer Configuration (ComposerConfig)
Attachments Configuration (AttachmentsConfig)
Attachments are on the roadmap for a future release.
Modal Configuration (ModalConfig)
Dimensions Object
Dimension Object
Modal Dimension Object
Sidecar Configuration (SidecarConfig)
Theme Configuration (ThemeConfig)
Model Configuration (ModelConfig)
Available Models
The following models are currently supported:
anthropic/claude-sonnet-4.5anthropic/claude-haiku-4.5anthropic/claude-sonnet-4anthropic/claude-opus-4.5openai/gpt-4oopenai/gpt-4o-miniopenai/gpt-5.1-codexopenai/gpt-5openai/gpt-5.1openai/gpt-4.1anthropic/claude-3.7-sonnetanthropic/claude-opus-4google/gemini-2.5-pro-previewgoogle/gemini-3-pro-previewmoonshotai/kimi-k2mistralai/mistral-medium-3mistralai/mistral-medium-3.1mistralai/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.
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 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 includeMessagePrimitive.RootandMessagePrimitive.Partsto maintain compatibility with the assistant-ui runtime - For text content overrides, the default
Textcomponent 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, anduseAssistantEvent
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