Guides
Grok & X Integration
Build commerce experiences for X (Twitter) using Grok
Better Data provides first-class support for integration with xAI’s Grok model, allowing you to bring conversational commerce directly to millions of users on X.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Build commerce experiences for X (Twitter) using Grok
import { GrokAdapter } from '@commercegateway/commerce-gateway/grok';
const adapter = new GrokAdapter({
apiKey: process.env.XAI_API_KEY,
backends: { products: myBackend },
tools: ['search_products', 'check_inventory'],
});
const response = await fetch('https://api.x.ai/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.XAI_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'grok-1',
messages: [...],
tools: adapter.getGrokTools(),
}),
});