RunAgent Rust SDK
What is RunAgent?
RunAgent is a comprehensive Rust SDK for deploying and managing AI agents with support for multiple frameworks including LangChain, LangGraph, LlamaIndex, and more. Whether you're building chatbots, autonomous agents, or complex AI workflows, RunAgent provides the tools you need to deploy, test, and scale your AI applications.
Features
- Multi-Framework Support: LangChain, LangGraph, LlamaIndex, Letta, CrewAI, AutoGen
- Local & Remote Deployment: Deploy agents locally or to remote servers
- Real-time Streaming: WebSocket-based streaming for real-time interactions
- Database Management: SQLite-based agent metadata and history
- Template System: Pre-built templates for rapid setup
- Type Safety: Full Rust type safety with error handling
- Async/Await: Powered by Tokio for async operations
Installation
Or add manually to Cargo.toml:
[]
= "0.1.0"
= { = "1.35", = ["full"] }
= "1.0"
= "0.3"
Quick Start
RunAgent Cloud is the recommended way to get started. Deploy and interact with agents hosted on RunAgent's infrastructure without managing your own servers.
RunAgent Cloud
RunAgent Cloud allows you to deploy and interact with agents hosted on RunAgent's infrastructure. This is the recommended way to get started quickly.
Key Benefits:
- No server setup required
- Automatic scaling
- Managed infrastructure
- Simple authentication via API key
Step 1: Set Up Authentication
Important: You must export your API key before running your application:
You can get your API key from the RunAgent Dashboard.
Step 2: Connect to Your Agent
When connecting to RunAgent Cloud, set local = false:
use RunAgentClient;
let client = new.await?;
Step 3: Run Your Agent
Non-Streaming Example:
use RunAgentClient;
use json;
async
Streaming Example:
use RunAgentClient;
use json;
use StreamExt;
async
Complete Workflow:
# 1. Export your API key
# 2. Run your application
Local Development
For local development, you can run agents on your own machine. Set local = true when creating the client.
Basic Agent Interaction (Local)
use RunAgentClient;
use json;
async
Connecting to Local Agent with Explicit Address
use RunAgentClient;
use json;
async
Configuration
RunAgent Cloud Setup
Required: Set your API key as an environment variable before running your application:
Optional: Customize the base URL (defaults to https://api.runagent.ai):
Local Development Setup
For local development, you can configure cache and logging:
Quick Reference
| Setting | RunAgent Cloud | Local Development |
|---|---|---|
| API Key | Required (RUNAGENT_API_KEY) |
Not needed |
| Base URL | Optional (defaults to https://api.runagent.ai) |
Not needed |
| Client Parameter | local = false |
local = true |
| Agent Location | RunAgent infrastructure | Your local machine |
Configuration Builder
You can also configure the SDK programmatically:
use RunAgentConfig;
let config = new
.with_api_key
.with_base_url
.with_logging
.build;
Architecture
Core Components
- Client: High-level client for agent interaction
- REST Client: HTTP-based client for non-streaming requests
- Socket Client: WebSocket-based client for streaming interactions
- Database: SQLite-based agent history store (optional)
- Serialization: Safe messaging via WebSocket
Optional Features
Enable or disable features in Cargo.toml:
[]
= { = "0.1.0", = ["db"] }
Available features:
db(default): Enable database support for local agent management
API Reference
RunAgentClient
Main client for interacting with RunAgent deployments.
Methods
-
new(agent_id, entrypoint_tag, local)- Create a new clientagent_id: The agent identifierentrypoint_tag: The entrypoint function tag (e.g., "agno_print_response")local:truefor local agents,falsefor cloud agents
-
with_address(agent_id, entrypoint_tag, local, host, port)- Create client with explicit address -
run(input_kwargs)- Run agent with keyword arguments only- Returns:
RunAgentResult<Value>
- Returns:
-
run_with_args(input_args, input_kwargs)- Run agent with both positional and keyword argumentsinput_args: Slice of positional arguments asValueinput_kwargs: Slice of tuples(&str, Value)for keyword arguments
-
run_stream(input_kwargs)- Run agent with streaming response- Returns:
RunAgentResult<Pin<Box<dyn Stream<Item = RunAgentResult<Value>> + Send>>>
- Returns:
-
run_stream_with_args(input_args, input_kwargs)- Run agent with streaming and both argument types -
health_check()- Check if the agent is available -
get_agent_architecture()- Get the agent's architecture information
DatabaseService
Database service for managing local agent metadata (requires db feature).
new(db_path)- Create a new database serviceadd_agent(agent)- Add an agent to the databaselist_agents()- List all agents in the databaseget_agent(agent_id)- Get agent information by ID
Error Handling
use ;
Testing
Examples
See the examples/ folder for complete examples:
- Basic usage with cloud agents
- Streaming interactions
- Local agent connections
- Framework integrations
Contributing
We welcome contributions! See CONTRIBUTING.md for guidelines.
Development Setup
Roadmap
- Python interop via PyO3
- Additional framework support
- Enhanced streaming capabilities
- Production deployment tools
- Monitoring & observability
- CLI tool integration
Links
License
This project is licensed under the MIT License - see the LICENSE file.
Acknowledgments
- Built with Tokio
- Uses Axum
- SQL powered by SQLx
- WebSocket support via tokio-tungstenite
Need help? Join our Discord or check the documentation!