@umbtechnologies/antimatter-sdk
v0.2.1
Published
The official REST client library for the Antimatter backend API.
Readme
@umbtechnologies/antimatter-sdk
The official REST client library for the Antimatter backend API.
Installation
npm install @umbtechnologies/antimatter-sdkSetup
Initialize the client with your Antimatter API key. You can also provide an optional baseUrl and maxRetries.
import { AntimatterSDK } from '@umbtechnologies/antimatter-sdk';
const client = new AntimatterSDK({
apiKey: 'UMB_YOUR_API_KEY', // Required
});Usage Examples
1. Chat with an Agent
Send messages directly to an LLM provider managed by your backend quota.
const response = await client.chat({
providerId: 'openai',
model: 'gpt-4o',
messages: [
{ role: 'user', content: 'Hello, Antimatter!' }
]
});
console.log(response);2. Execute a Headless Agent Task
Queue an agent task on the backend.
const execution = await client.executeAgent({
prompt: 'Analyze my codebase and generate a report.',
executionMode: 'cloud'
});
console.log('Execution ID:', execution.data.executionId);3. Check Task Status
Check the status of a queued or running agent task.
const status = await client.getAgentStatus({
taskId: 'TASK_ID_HERE'
});
console.log('Status:', status.data.status);4. Fetch Conversation History
Retrieve past chat history for the authenticated user.
const history = await client.getConversationHistory({
limit: 10,
offset: 0
});
console.log(history.data.conversations);Full Browser Demo
You can easily integrate the SDK into a frontend application. Below is a complete, single-file HTML/JS example of a chat interface powered by the Antimatter SDK:
<!DOCTYPE html>
<html>
<head>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: Arial, sans-serif;
background: #0f172a;
color: white;
}
.container {
width: 100%;
max-width: 900px;
margin: 20px auto;
height: 90vh;
background: #111827;
border-radius: 16px;
display: flex;
flex-direction: column;
overflow: hidden;
border: 1px solid #1f2937;
}
.header {
padding: 20px;
font-size: 20px;
font-weight: bold;
border-bottom: 1px solid #1f2937;
}
.chat {
flex: 1;
overflow-y: auto;
padding: 20px;
}
.message {
padding: 12px 16px;
border-radius: 12px;
margin-bottom: 12px;
max-width: 80%;
line-height: 1.5;
white-space: pre-wrap;
}
.user {
background: #2563eb;
margin-left: auto;
}
.assistant {
background: #1f2937;
}
.footer {
display: flex;
gap: 10px;
padding: 20px;
border-top: 1px solid #1f2937;
}
.input {
flex: 1;
padding: 14px;
border: none;
border-radius: 10px;
background: #1f2937;
color: white;
outline: none;
}
.button {
padding: 14px 20px;
border: none;
border-radius: 10px;
background: #2563eb;
color: white;
cursor: pointer;
}
.status {
padding: 10px 20px;
font-size: 12px;
color: #94a3b8;
}
</style>
</head>
<body>
<div class="container">
<div class="header">
Antimatter SDK Demo
</div>
<div id="chat" class="chat"></div>
<div id="status" class="status">Ready</div>
<div class="footer">
<input id="messageInput" class="input" placeholder="Type a message..." />
<button id="sendBtn" class="button">Send</button>
</div>
</div>
<!-- Note: When using ES modules in browser, import from CDN or use a bundler like Vite -->
<script type="module">
import { AntimatterSDK } from 'https://esm.sh/@umbtechnologies/[email protected]';
const client = new AntimatterSDK({
apiKey: 'UMB_YOUR_API_KEY'
});
const chat = document.getElementById('chat');
const input = document.getElementById('messageInput');
const sendBtn = document.getElementById('sendBtn');
const status = document.getElementById('status');
function addMessage(role, text) {
const div = document.createElement('div');
div.className = `message ${role}`;
div.textContent = text;
chat.appendChild(div);
chat.scrollTop = chat.scrollHeight;
}
async function sendMessage() {
const message = input.value.trim();
if (!message) return;
addMessage('user', message);
input.value = '';
status.textContent = 'Thinking...';
try {
const response = await client.chat({
providerId: 'groq',
model: 'openai/gpt-oss-120b',
messages: [
{
role: 'user',
content: message
}
]
});
const reply = response?.choices?.[0]?.message?.content || 'No response returned';
addMessage('assistant', reply);
status.textContent = `Prompt: ${response?.usage?.prompt_tokens || 0} | Completion: ${response?.usage?.completion_tokens || 0}`;
} catch (error) {
console.error(error);
addMessage('assistant', `Error: ${error.message}`);
status.textContent = 'Request failed';
}
}
sendBtn.addEventListener('click', sendMessage);
input.addEventListener('keydown', (e) => {
if (e.key === 'Enter') {
sendMessage();
}
});
</script>
</body>
</html>