API Documentation
Integrate AI assisters into your website or application using our JavaScript SDK and REST API.
Quick Start
1. Get your API Key
Generate an API key from your dashboard. API keys start with ask_.
2. Add the SDK to your website
<script src="https://assisters.io/sdk/assisters.js"></script>
<script>
Assisters.init({
apiKey: 'ask_your_api_key',
assisterId: 'your-assister-uuid'
});
</script>3. That's it!
A chat button will appear in the bottom-right corner of your page.
SDK Configuration
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | required | Your API key from the dashboard |
assisterId | string | required | The UUID of the assister to embed |
position | string | "bottom-right" | Button position: "bottom-right" or "bottom-left" |
theme | string | "auto" | Theme: "auto", "light", or "dark" |
primaryColor | string | "#3b82f6" | Brand color for the button and accents |
buttonSize | number | 56 | Button diameter in pixels |
buttonIcon | string | "chat" | "chat", "sparkle", or custom image URL |
greeting | string | null | Custom greeting message override |
placeholder | string | "Type a message..." | Placeholder text for the message input |
hideWatermark | boolean | false | Hide "Powered by Assisters" watermark (requires $50+ wallet) |
autoOpen | boolean | false | Auto-open chat on page load |
zIndex | number | 9999 | Z-index for the widget |
SDK Methods
Assisters.open()
Opens the chat widget programmatically.
Assisters.close()
Closes the chat widget.
Assisters.toggle()
Toggles the chat widget open/closed.
Assisters.sendMessage(message)
Sends a message programmatically.
Assisters.sendMessage("Hello, I need help with my order");Assisters.isOpen()
Returns true if the chat widget is currently open.
Assisters.destroy()
Removes the widget from the page completely.
Event Callbacks
Assisters.init({
apiKey: 'ask_xxx',
assisterId: 'uuid',
// Called when the widget finishes loading
onLoad: function() {
console.log('Widget loaded');
},
// Called when the chat opens
onOpen: function() {
console.log('Chat opened');
},
// Called when the chat closes
onClose: function() {
console.log('Chat closed');
},
// Called when a message is sent or received
onMessage: function(data) {
console.log('Message:', data);
}
});REST API
For server-side integrations, you can use our REST API directly.
/api/embed/chatSend a message and receive a streaming response.
Headers
X-Assisters-Key: ask_your_api_key Content-Type: application/json
Request Body
{
"assisterId": "uuid",
"message": "Hello, I need help",
"sessionId": "optional-session-id"
}Response
Returns a Server-Sent Events (SSE) stream with chunks of the response.
SSE Stream Format
// Each chunk arrives as a JSON event:
data: {"type":"chunk","content":"Hello"}
data: {"type":"chunk","content":", how"}
data: {"type":"chunk","content":" can I"}
data: {"type":"chunk","content":" help you today?"}
// Final event with metadata:
data: {"type":"done","tokens_used":142,"hideWatermark":false}JavaScript Example
const response = await fetch('https://assisters.io/api/embed/chat', {
method: 'POST',
headers: {
'X-Assisters-Key': 'ask_your_api_key',
'Content-Type': 'application/json'
},
body: JSON.stringify({
assisterId: 'your-assister-uuid',
message: 'Hello!'
})
});
const reader = response.body.getReader();
const decoder = new TextDecoder();
let fullText = '';
while (true) {
const { done, value } = await reader.read();
if (done) break;
const text = decoder.decode(value);
const lines = text.split('\n');
for (const line of lines) {
if (line.startsWith('data: ')) {
const data = JSON.parse(line.slice(6));
if (data.type === 'chunk') {
fullText += data.content;
console.log(data.content); // Stream to UI
} else if (data.type === 'done') {
console.log('Complete! Tokens:', data.tokens_used);
}
}
}
}Rate Limits
API requests are rate-limited based on your subscription tier:
- • Free: 10 requests per minute
- • Plus: 60 requests per minute
- • Pro: 300 requests per minute
- • Max: 1000 requests per minute
Billing
Embed API usage is charged from your wallet balance based on token consumption. Each assister has its own price per million tokens set by the creator.
Monitor your usage and top up your wallet from the wallet page.
Ready to integrate?
Get your API key and start embedding AI assisters today.