Deploy Your First Agent
Create, deploy, and monitor your first NeuAIs agent in under 10 minutes.
Prerequisites
- NeuAIs CLI installed
- Authenticated account
- Basic knowledge of YAML or TOML
Step 1: Create Agent Definition
Create my-agent.toml:
[agent]
name = "my-first-agent"
version = "1.0.0"
runtime = "rust"
[resources]
cpu = "0.5"
memory = "512Mi"
replicas = 1
[health]
endpoint = "/health"
interval = "30s"
timeout = "5s"
[environment]
LOG_LEVEL = "info"
METRICS_PORT = "9090"
Step 2: Write Agent Code
Create src/main.rs:
use neuais_sdk::prelude::*;
#[agent(name = "my-first-agent")]
pub struct MyAgent {
counter: u64,
}
#[async_trait]
impl Agent for MyAgent {
async fn run(&mut self, ctx: &Context) -> Result<()> {
loop {
self.counter += 1;
ctx.log(format!("Tick {}", self.counter)).await?;
tokio::time::sleep(Duration::from_secs(5)).await;
}
}
async fn health(&self) -> HealthStatus {
HealthStatus::Healthy
}
}
#[tokio::main]
async fn main() -> Result<()> {
let agent = MyAgent { counter: 0 };
agent.start().await
}
Step 3: Build
cargo build --release
Step 4: Deploy
neuais agent deploy \
--config my-agent.toml \
--binary target/release/my-first-agent
Output:
Uploading binary... 100%
Creating agent... done
Starting replicas... 1/1
Agent deployed: my-first-agent
ID: agt_1a2b3c4d5e6f
Status: Running
Endpoint: https://my-first-agent.neuais.app
Step 5: Verify
Check status:
neuais agent status my-first-agent
View logs:
neuais logs my-first-agent --tail 20 --follow
Expected output:
[2024-01-15 10:00:00] Tick 1
[2024-01-15 10:00:05] Tick 2
[2024-01-15 10:00:10] Tick 3
Step 6: Test Health Endpoint
curl https://my-first-agent.neuais.app/health
Response:
{
"status": "healthy",
"uptime": "5m 32s",
"version": "1.0.0"
}
Step 7: Scale
Scale to 3 replicas:
neuais agent scale my-first-agent --replicas 3
Step 8: Update
Update agent code and redeploy:
cargo build --release
neuais agent update my-first-agent \
--binary target/release/my-first-agent \
--strategy rolling
Step 9: Monitor
View metrics:
neuais agent metrics my-first-agent
Open Observatory:
neuais observatory --agent my-first-agent
Step 10: Clean Up
Delete agent:
neuais agent delete my-first-agent
Next Steps
Agent Development
Learn advanced agent patterns
Scaling Agents
Auto-scaling and load balancing
Observatory
3D visualization and monitoring
Monitoring Guide
Metrics, logs, and traces
Troubleshooting
Build fails
Ensure Rust toolchain is installed:
rustup --version
cargo --version
Deploy fails
Check authentication:
neuais auth whoami
Agent crashes
View crash logs:
neuais logs my-first-agent --since 1h --level error
Health check fails
Verify health endpoint returns 200:
neuais agent exec my-first-agent -- curl localhost:8080/health