The Agentopia SDK provides a comprehensive set of tools and libraries for integrating AI agents into your applications. Available for multiple programming languages, our SDKs make it easy to create, deploy, and manage intelligent agents within your software ecosystem.
Overview
The Agentopia SDK is designed to provide developers with a powerful yet intuitive interface for building AI-powered applications. Our SDKs are available for multiple programming languages, ensuring you can integrate Agentopia's capabilities into your preferred tech stack.
Available SDKs
JavaScript
Perfect for web applications, Node.js backends, and browser-based agents.
Key Features
Agent Management
Create, configure, and deploy AI agents with just a few lines of code. Manage agent lifecycle, state, and interactions.
Tool Integration
Connect your agents to external tools, APIs, and data sources with built-in adapters and custom tool definitions.
Memory & Knowledge
Implement persistent memory for your agents with vector storage, knowledge retrieval, and context management.
Multi-Agent Orchestration
Build complex systems with multiple cooperating agents, message passing, and workflow coordination.
Installation
Choose your preferred programming language and follow the installation instructions below:
JavaScript / Node.js
NPM
npm install @agentopia/sdk
Yarn
yarn add @agentopia/sdk
Browser
<script src="https://cdn.agentopia.ai/sdk/latest/agentopia.min.js"></script>
Python
pip
pip install agentopia
Poetry
poetry add agentopia
Java
Maven
<dependency>
<groupId>ai.agentopia</groupId>
<artifactId>agentopia-sdk</artifactId>
<version>1.0.0</version>
</dependency>
Gradle
implementation 'ai.agentopia:agentopia-sdk:1.0.0'
Go
go get github.com/agentopia/sdk-go
C#
dotnet add package Agentopia.SDK
Ruby
gem install agentopia
API Key Setup
After installation, you'll need to configure your API key:
JavaScript
const agentopia = require('@agentopia/sdk');
agentopia.configure({
apiKey: 'your-api-key'
});
Python
import agentopia
agentopia.api_key = "your-api-key"
Environment Variables (All SDKs)
AGENTOPIA_API_KEY=your-api-key
You can obtain an API key from the Agentopia Dashboard after creating an account.
Quick Start
Get started with Agentopia SDK in minutes. This quick start guide will help you create your first AI agent.
JavaScript Example
// Import the SDK
const { Agent, Tool } = require('@agentopia/sdk');
// Configure API key
const agentopia = require('@agentopia/sdk');
agentopia.configure({
apiKey: 'your-api-key'
});
// Define a custom tool
const weatherTool = new Tool({
name: 'get_weather',
description: 'Get the current weather for a location',
parameters: {
location: {
type: 'string',
description: 'The city and state, e.g. San Francisco, CA'
}
},
execute: async ({ location }) => {
// In a real app, you would call a weather API here
return `It's currently sunny and 72°F in ${location}`;
}
});
// Create an agent
const assistant = new Agent({
name: 'Weather Assistant',
description: 'I help users check the weather',
tools: [weatherTool],
model: 'gpt-4'
});
// Start a conversation
async function main() {
const response = await assistant.chat({
messages: [
{ role: 'user', content: 'What\'s the weather like in Seattle?' }
]
});
console.log(response.content);
}
main();
Python Example
import agentopia
from agentopia import Agent, Tool
# Configure API key
agentopia.api_key = "your-api-key"
# Define a custom tool
def get_weather(location: str) -> str:
"""Get the current weather for a location"""
# In a real app, you would call a weather API here
return f"It's currently sunny and 72°F in {location}"
weather_tool = Tool(
name="get_weather",
description="Get the current weather for a location",
function=get_weather
)
# Create an agent
assistant = Agent(
name="Weather Assistant",
description="I help users check the weather",
tools=[weather_tool],
model="gpt-4"
)
# Start a conversation
response = assistant.chat(
messages=[
{"role": "user", "content": "What's the weather like in Seattle?"}
]
)
print(response.content)
Next Steps
After getting your first agent running, you can:
- Add more sophisticated tools to enhance your agent's capabilities
- Implement memory to give your agent context awareness
- Create multi-agent systems for complex tasks
- Deploy your agent to production environments
Explore the Core Concepts section to learn more about these features.
Core Concepts
Understanding these core concepts will help you build more powerful and flexible agent-based applications.
Agents
Agents are the central building blocks in Agentopia. An agent is an AI-powered entity that can:
- Process natural language inputs
- Use tools to interact with external systems
- Maintain context through memory
- Make decisions based on goals and constraints
Creating an Agent
// JavaScript
const agent = new Agent({
name: 'Customer Support',
description: 'I help users with product questions',
model: 'gpt-4',
tools: [searchKnowledgeBase, createTicket],
memory: new VectorMemory()
});
Tools
Tools enable agents to perform actions in the real world or access external information. A tool consists of:
- A name and description
- Parameter definitions
- An execution function
Creating a Tool
# Python
search_tool = Tool(
name="search_database",
description="Search the product database for information",
parameters={
"query": {
"type": "string",
"description": "The search query"
},
"limit": {
"type": "integer",
"description": "Maximum number of results",
"default": 5
}
},
function=search_database_function
)
Memory
Memory systems allow agents to retain information across interactions. Agentopia supports several memory types:
Conversation Memory
Stores the history of interactions with users
Vector Memory
Semantic storage for knowledge retrieval
Structured Memory
Stores information in defined schemas
Episodic Memory
Records sequences of events and experiences
Implementing Memory
// JavaScript
const memory = new VectorMemory({
collection: 'customer-support',
embedModel: 'text-embedding-ada-002'
});
// Add information to memory
await memory.add({
content: 'Our return policy allows returns within 30 days of purchase.',
metadata: { category: 'policy', topic: 'returns' }
});
// Query memory
const results = await memory.search('How long do I have to return items?');
Multi-Agent Systems
Complex problems often require multiple specialized agents working together. Agentopia provides:
- Agent orchestration for coordinating multiple agents
- Message passing between agents
- Role-based agent definitions
- Workflow management for complex processes
Creating a Multi-Agent System
# Python
from agentopia import AgentTeam, Agent
# Create specialized agents
researcher = Agent(name="Researcher", ...)
writer = Agent(name="Writer", ...)
editor = Agent(name="Editor", ...)
# Create a team
content_team = AgentTeam(
name="Content Creation Team",
agents=[researcher, writer, editor],
workflow={
"start": "researcher",
"transitions": {
"researcher": {"next": "writer", "condition": "research_complete"},
"writer": {"next": "editor", "condition": "draft_complete"},
"editor": {"next": "end", "condition": "editing_complete"}
}
}
)
# Run the team on a task
result = content_team.execute("Create an article about AI agents")
API Reference
This section provides a reference for the main classes and methods in the Agentopia SDK. For complete documentation, visit our API Documentation.
Agent Class
The core class for creating and managing AI agents.
Constructor
new Agent({
name: string, // Agent name
description: string, // Agent description
model: string, // LLM model to use (e.g., 'gpt-4')
tools?: Tool[], // Array of tools
memory?: Memory, // Memory system
systemPrompt?: string, // Custom system prompt
temperature?: number, // Temperature for generation (0-1)
maxTokens?: number, // Maximum tokens in response
options?: object // Additional options
})
Methods
chat(options)
Send a message to the agent and get a response.
agent.chat({
messages: [{ role: 'user', content: string }],
stream?: boolean,
tools?: Tool[],
toolChoice?: string | object
})
addTool(tool)
Add a tool to the agent.
agent.addTool(new Tool({...}))
removeTool(toolName)
Remove a tool from the agent.
agent.removeTool('tool_name')
setMemory(memory)
Set or replace the agent's memory system.
agent.setMemory(new VectorMemory({...}))
Tool Class
Define tools that agents can use to perform actions or retrieve information.
Constructor
new Tool({
name: string, // Tool name (must be unique)
description: string, // Tool description
parameters: object, // JSON Schema for parameters
execute: function, // Function to execute
required?: boolean, // Whether tool is required
options?: object // Additional options
})
Methods
execute(params)
Execute the tool with the given parameters.
const result = await tool.execute({ param1: 'value1' })
validate(params)
Validate parameters against the tool's schema.
const isValid = tool.validate({ param1: 'value1' })
Memory Classes
Classes for implementing different types of memory systems.
ConversationMemory
new ConversationMemory({
maxMessages?: number, // Maximum messages to store
summarizeThreshold?: number, // When to summarize history
options?: object // Additional options
})
VectorMemory
new VectorMemory({
collection: string, // Collection name
embedModel?: string, // Embedding model to use
dimensions?: number, // Vector dimensions
similarity?: string, // Similarity metric
options?: object // Additional options
})
StructuredMemory
new StructuredMemory({
schema: object, // JSON Schema for data
storage?: string, // Storage backend
options?: object // Additional options
})
AgentTeam Class
Create and manage multi-agent systems.
Constructor
new AgentTeam({
name: string, // Team name
agents: Agent[], // Array of agents
workflow?: object, // Workflow definition
supervisor?: Agent, // Supervisor agent
options?: object // Additional options
})
Methods
execute(task)
Execute a task using the agent team.
const result = await team.execute('Analyze this data and create a report')
addAgent(agent, role)
Add an agent to the team with a specific role.
team.addAgent(new Agent({...}), 'researcher')
Examples
Explore these examples to learn how to implement common agent patterns and use cases.
Customer Support Agent
Create a customer support agent that can answer questions and create support tickets.
// JavaScript
const { Agent, Tool, VectorMemory } = require('@agentopia/sdk');
// Create knowledge base tool
const knowledgeBaseTool = new Tool({
name: 'search_knowledge_base',
description: 'Search the knowledge base for information',
parameters: {
query: {
type: 'string',
description: 'The search query'
}
},
execute: async ({ query }) => {
// In a real app, search your knowledge base
return 'Information about: ' + query;
}
});
// Create ticket creation tool
const createTicketTool = new Tool({
name: 'create_support_ticket',
description: 'Create a support ticket for issues that cannot be resolved',
parameters: {
issue: {
type: 'string',
description: 'Description of the issue'
},
priority: {
type: 'string',
enum: ['low', 'medium', 'high'],
description: 'Ticket priority'
}
},
execute: async ({ issue, priority }) => {
// In a real app, create a ticket in your system
return `Ticket created with issue: ${issue} and priority: ${priority}`;
}
});
// Create memory system
const memory = new VectorMemory({
collection: 'support-knowledge',
embedModel: 'text-embedding-ada-002'
});
// Add knowledge to memory
await memory.add({
content: 'Our return policy allows returns within 30 days of purchase with receipt.',
metadata: { category: 'policy', topic: 'returns' }
});
await memory.add({
content: 'Premium support is available 24/7 for enterprise customers.',
metadata: { category: 'support', topic: 'premium' }
});
// Create the support agent
const supportAgent = new Agent({
name: 'Support Assistant',
description: 'I help customers with product questions and issues',
model: 'gpt-4',
tools: [knowledgeBaseTool, createTicketTool],
memory: memory,
systemPrompt: `You are a helpful customer support agent.
Always be polite and professional.
Search the knowledge base before answering.
Create a support ticket only if you cannot resolve the issue.`
});
// Start a conversation
const response = await supportAgent.chat({
messages: [
{ role: 'user', content: 'What is your return policy?' }
]
});
Data Analysis Team
Create a multi-agent system for analyzing data and generating reports.
# Python
from agentopia import Agent, Tool, AgentTeam
# Create specialized agents
data_processor = Agent(
name="Data Processor",
description="I clean and prepare data for analysis",
model="gpt-4",
tools=[
Tool(name="load_data", function=load_data_function),
Tool(name="clean_data", function=clean_data_function)
]
)
analyst = Agent(
name="Data Analyst",
description="I analyze data and identify patterns",
model="gpt-4",
tools=[
Tool(name="analyze_data", function=analyze_data_function),
Tool(name="create_visualization", function=create_visualization_function)
]
)
report_writer = Agent(
name="Report Writer",
description="I create comprehensive reports based on analysis",
model="gpt-4",
tools=[
Tool(name="generate_report", function=generate_report_function)
]
)
# Create the team
analysis_team = AgentTeam(
name="Data Analysis Team",
agents=[data_processor, analyst, report_writer],
workflow={
"start": "data_processor",
"transitions": {
"data_processor": {"next": "analyst", "condition": "data_prepared"},
"analyst": {"next": "report_writer", "condition": "analysis_complete"},
"report_writer": {"next": "end", "condition": "report_generated"}
}
}
)
# Execute a data analysis task
result = analysis_team.execute(
"Analyze the sales data for Q2 2025 and create a comprehensive report"
)
Web Research Agent
Create an agent that can search the web and summarize information.
// JavaScript
const { Agent, Tool } = require('@agentopia/sdk');
// Create web search tool
const searchTool = new Tool({
name: 'web_search',
description: 'Search the web for information',
parameters: {
query: {
type: 'string',
description: 'The search query'
},
num_results: {
type: 'integer',
description: 'Number of results to return',
default: 5
}
},
execute: async ({ query, num_results }) => {
// In a real app, use a search API
return `Search results for: ${query} (${num_results} results)`;
}
});
// Create webpage reader tool
const readPageTool = new Tool({
name: 'read_webpage',
description: 'Read the content of a webpage',
parameters: {
url: {
type: 'string',
description: 'The URL of the webpage to read'
}
},
execute: async ({ url }) => {
// In a real app, fetch and parse the webpage
return `Content from: ${url}`;
}
});
// Create the research agent
const researchAgent = new Agent({
name: 'Research Assistant',
description: 'I help with web research and summarization',
model: 'gpt-4',
tools: [searchTool, readPageTool],
systemPrompt: `You are a research assistant.
When asked to research a topic:
1. Search the web for relevant information
2. Read the most promising webpages
3. Synthesize the information into a comprehensive summary
4. Cite your sources`
});
// Start a research task
const response = await researchAgent.chat({
messages: [
{ role: 'user', content: 'Research the latest developments in quantum computing' }
]
});
More Examples
Explore our GitHub repository for more examples:
Troubleshooting
Common issues and their solutions when working with the Agentopia SDK.
Authentication Issues
Problem: API key not recognized
Solution: Verify that you're using a valid API key and that it's properly configured:
// Check if your API key is properly set
console.log(agentopia.getConfig().apiKey.substring(0, 5) + '...');
// Ensure you're using the latest SDK version
npm list @agentopia/sdk
Problem: Rate limit exceeded
Solution: Implement retry logic with exponential backoff:
const { retryWithBackoff } = require('@agentopia/sdk/utils');
const response = await retryWithBackoff(
() => agent.chat({ messages: [...] }),
{
maxRetries: 5,
initialDelay: 1000,
maxDelay: 10000
}
);
Tool Execution Issues
Problem: Tool not being used by agent
Solution: Improve tool description and ensure it's properly registered:
// Make tool descriptions more specific
const tool = new Tool({
name: 'search_database',
description: 'Search the product database for specific product information including price, availability, and specifications',
// Rest of tool definition
});
// Explicitly tell the agent to use the tool
const response = await agent.chat({
messages: [...],
toolChoice: 'search_database' // Or 'auto' to let the agent decide
});
Problem: Tool execution errors
Solution: Implement proper error handling in your tool functions:
const tool = new Tool({
// Tool definition
execute: async (params) => {
try {
// Tool implementation
return result;
} catch (error) {
// Return a user-friendly error message
return `Unable to complete operation: ${error.message}`;
}
}
});
Memory Issues
Problem: Agent not remembering context
Solution: Verify memory configuration and check for token limits:
// Check if memory is properly configured
console.log(agent.memory.getStats());
// Implement conversation summarization for long interactions
const memory = new ConversationMemory({
maxMessages: 20,
summarizeThreshold: 15,
summarizeFunction: async (messages) => {
// Create a summary of the conversation
return summary;
}
});
Problem: Vector memory retrieval issues
Solution: Adjust similarity settings and check embedding quality:
// Adjust vector memory settings
const memory = new VectorMemory({
collection: 'knowledge-base',
embedModel: 'text-embedding-ada-002',
similarity: 'cosine',
minSimilarity: 0.75, // Increase threshold for better matches
maxResults: 5
});
Getting Help
If you're still experiencing issues, you can:
- Check our comprehensive documentation
- Join our community Discord for real-time support
- Open an issue on GitHub
- Contact our support team for enterprise customers
Diagnostic Tool
Use our diagnostic tool to identify common issues:
// JavaScript
const { diagnose } = require('@agentopia/sdk/utils');
// Run diagnostics
const report = await diagnose({
checkAuth: true,
checkConnectivity: true,
checkModels: true,
verbose: true
});
console.log(report);