SDK Reference
Complete TypeScript SDK documentation with Vercel AI SDK v5 integration, MCP tools, business platform, and advanced analytics.
Installation
npm install @rodger-ai/sdk
# For admin features
npm install @rodger-ai/admin-sdk
# For business applications with team management
npm install ai # Vercel AI SDK v5 for streamingClient Configuration
import { RodgerClient, createClient } from '@rodger-ai/sdk';
// Method 1: Direct instantiation
const client = new RodgerClient({
apiKey: 'your-api-key', // Required: Your API key
apiUrl: 'https://api.rodger.ai', // Optional: API base URL
debug: false, // Optional: Enable debug logging
timeout: 30000, // Optional: Request timeout in ms
retries: 3, // Optional: Max retry attempts
enableStreaming: true // Optional: Enable streaming responses
});
// Method 2: Factory function
const client = createClient({
apiKey: 'your-api-key'
});
// Access specialized managers
const aiSDK = client.aiSDK; // Vercel AI SDK integration
const mcp = client.mcp; // MCP tool management
const business = client.business; // Business platform features
const analytics = client.analytics; // Advanced analyticsThe client provides access to 30+ specialized managers for different platform capabilities.
Core API Methods
Agent Management
agents.create(data)Core APICreate a new AI agent with advanced configuration and MCP tools.
const agent = await client.agents.create({
name: 'Support Agent',
instructions: 'You are a helpful assistant with access to tools.',
traits: ['helpful', 'professional'],
guardrails: {
contentPolicy: 'strict',
allowedTools: ['slack', 'github']
},
mcpTools: ['slack-notifications', 'github-issues'],
model: 'gpt-4-turbo',
temperature: 0.3
});agents.list(options?)Core APIList all agents with advanced filtering, pagination, and analytics.
const { data, pagination } = await client.agents.list({
page: 1,
limit: 10,
search: 'support',
category: 'customer-service',
mcpToolsEnabled: true,
sortBy: 'usage',
includeAnalytics: true
});agents.update(id, data)Core APIUpdate agent configuration with versioning and rollback support.
await client.agents.update(agent.id, {
instructions: 'Updated instructions with tool integration...',
mcpTools: ['slack', 'github', 'linear'],
guardrails: {
contentPolicy: 'moderate',
rateLimits: { maxQueriesPerHour: 100 }
},
createBackup: true // Auto-backup previous version
});Knowledge Management
knowledge.addSource(data)Core APIAdd knowledge sources with advanced processing and Sentence Window retrieval.
const source = await client.knowledge.addSource({
agentId: agent.id,
type: 'url',
source: 'https://help.example.com',
metadata: {
title: 'Help Documentation',
category: 'support'
},
processingOptions: {
enableSentenceWindow: true,
windowSize: 3,
chunkOverlap: 150,
extractTables: true,
enableOCR: true // For images/PDFs
}
});knowledge.search(query, options)Core APIHybrid semantic and keyword search with context windows.
const results = await client.knowledge.search('password reset', {
agentId: agent.id,
limit: 5,
hybridSearch: true, // Combine semantic + keyword
includeContext: true, // Return sentence windows
filters: { category: 'support' },
rankingBoosts: { recency: 0.2, relevance: 0.8 }
});Query Processing & AI SDK Integration
aiSDK.streamChat(agentId, options)Vercel AI SDK v5Stream AI responses with tool calling using Vercel AI SDK v5.
import { useChat } from 'ai/react';
// React hook integration
const { messages, input, handleInputChange, handleSubmit, isLoading } = useChat({
api: '/api/ai-sdk/agents/' + agentId + '/chat',
headers: {
'Authorization': 'Bearer ' + apiKey
},
onToolCall: ({ toolCall }) => {
console.log('Tool called:', toolCall.toolName);
}
});
// Direct SDK usage
const stream = await client.aiSDK.streamChat(agentId, {
messages: [{ role: 'user', content: 'Reset my password using Slack' }],
enableMCPTools: true,
temperature: 0.3
});query.mcpQuery(agentId, options)MCP ToolsExecute queries with MCP tool integration and real-time monitoring.
const response = await client.query.mcpQuery(agentId, {
message: 'Create a GitHub issue for this bug',
sessionId: 'user-123',
mcpOptions: {
enabledTools: ['github', 'slack'],
maxToolCalls: 5,
timeoutMs: 30000,
monitorExecution: true
},
guardrails: {
requireApproval: ['github-write', 'slack-channel-create']
}
});Business Platform
Business Account Management
business.settings.get()Get business account settings and branding
business.agents.list(options)List business-specific agents
business.knowledge.addSource(data)Add business-scoped knowledge
business.guardrails.create(policy)Create custom content policies
Team Management & Routing
teamAvailability.create(config)Set up team availability and routing
teamAvailability.route(request)Route conversations to available agents
teamAvailability.analytics()Get team performance analytics
Advanced Business Features
analytics.dashboard(options)Comprehensive business metrics
abTesting.create(experiment)A/B test agent performance
business.conversations.list()Access all business conversations
MCP Tools Integration
Model Context Protocol (MCP) integration for connecting to external services and APIs.
// List available MCP tools
const tools = await client.mcp.listTools();
// Configure a tool (e.g., Slack)
await client.mcp.configureTool('slack', {
credentials: {
botToken: 'xoxb-your-token',
permissions: ['channels:write', 'chat:write']
}
});
// Execute tool with monitoring
const result = await client.mcp.executeTool('slack', 'send-message', {
channel: '#support',
text: 'Customer issue escalated',
monitorExecution: true
});
// Get tool analytics
const analytics = await client.mcp.getToolAnalytics('slack', {
timeRange: '7d',
includeErrorRates: true
});Full TypeScript Support
Complete type safety with 30+ specialized managers, comprehensive interfaces, and auto-completion for all platform features.
import {
RodgerClient,
CreateAgentData,
MCPQueryOptions,
BusinessKnowledgeSource,
TeamAvailabilityConfig,
ABTestExperiment
} from '@rodger-ai/sdk';
const client = new RodgerClient({
apiKey: 'your-key',
enableStreaming: true
});
// Fully typed agent creation
const agentConfig: CreateAgentData = {
name: 'Support Assistant',
instructions: 'Professional support with tool access',
traits: ['helpful', 'analytical'],
guardrails: {
contentPolicy: 'strict',
allowedTools: ['slack', 'github']
},
mcpTools: ['slack-notifications']
};
// MCP query with full type safety
const mcpOptions: MCPQueryOptions = {
enabledTools: ['slack'],
maxToolCalls: 3,
monitorExecution: true
};
// Business platform features
const knowledgeSource: BusinessKnowledgeSource = {
type: 'url',
source: 'https://docs.example.com',
processingOptions: {
enableSentenceWindow: true,
windowSize: 3
}
};Streaming & Real-time Features
Built-in support for Server-Sent Events, WebSockets, and real-time monitoring.
// Server-Sent Events streaming
const stream = await client.aiSDK.streamChat(agentId, {
messages: [{ role: 'user', content: 'Help me with deployment' }],
enableMCPTools: true
});
for await (const chunk of stream) {
if (chunk.type === 'text') {
console.log('AI Response:', chunk.content);
} else if (chunk.type === 'tool_call') {
console.log('Tool Called:', chunk.toolCall.name);
} else if (chunk.type === 'tool_result') {
console.log('Tool Result:', chunk.result);
}
}
// Real-time monitoring
client.analytics.onEvent('tool_execution', (event) => {
console.log('Tool executed:', event.toolName, 'Duration:', event.duration);
});
// WebSocket connection for live updates
const wsConnection = client.realtime.connect();
wsConnection.on('agent_update', (update) => {
console.log('Agent status changed:', update);
});