Skip to main content

Production-Ready Agent Deployment

Agentbase makes deploying AI agents to production simple and reliable. No infrastructure to manage, no scaling concerns, and no maintenance overhead.

Instant Production

Same API you tested locally works in production - no code changes needed

Auto-Scaling

Automatically scales from 1 to 1000s of concurrent agents based on demand

99.9% Uptime SLA

Enterprise-grade reliability with built-in redundancy and failover

Simple Pricing

Pay per action, not per token - predictable costs that scale with usage

Deployment Options

Direct API Integration

The simplest way to deploy agents - call the API directly from any language or platform.
curl -X POST https://api.agentbase.sh/run-agent \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "message": "Analyze this data and create a report",
    "mode": "base"
  }'
Best for:
  • Simple integrations
  • Any programming language
  • Webhook-based workflows
  • Serverless functions

API Reference

See complete API documentation and examples

Production Checklist

1

Get Production API Key

Sign up at base.agentbase.sh and get your API key from the dashboard.
Use work email to get free credits automatically!
2

Secure Your Keys

Store API keys in environment variables, never in code:
# .env file
AGENTBASE_API_KEY=your_api_key_here
// Use environment variables
const agentbase = new Agentbase({
  apiKey: process.env.AGENTBASE_API_KEY
});
3

Implement Error Handling

Handle errors gracefully in production:
try {
  const result = await agentbase.runAgent({
    message: userInput,
    mode: "base"
  });
} catch (error) {
  if (error.status === 429) {
    // Handle rate limiting
  } else if (error.status === 500) {
    // Handle server errors
  }
  // Log error and notify team
}
4

Monitor Usage

Track costs and usage in your dashboard:
  • Real-time cost tracking
  • Session monitoring
  • Performance metrics
  • Usage analytics
5

Set Up Persistence

Use sessions for multi-turn conversations:
// First message creates a session
const result1 = await agentbase.runAgent({
  message: "Create a Python script"
});

// Continue in the same session
const result2 = await agentbase.runAgent({
  message: "Now add error handling",
  session: result1.session
});

Architecture Patterns

Use case: One-off tasks, simple queries, independent operations
// Each request is independent
app.post('/api/analyze', async (req, res) => {
  const result = await agentbase.runAgent({
    message: `Analyze: ${req.body.data}`,
    mode: "base"
  });
  res.json(result);
});
Pros:
  • Simple to implement
  • No session management
  • Easy to scale
Cons:
  • No conversation history
  • Can’t build on previous context
Use case: Chat applications, multi-turn conversations, iterative tasks
// Store session per user
app.post('/api/chat', async (req, res) => {
  const userId = req.user.id;
  const session = await getUserSession(userId);

  const result = await agentbase.runAgent({
    message: req.body.message,
    session: session,
    mode: "base"
  });

  await saveUserSession(userId, result.session);
  res.json(result);
});
Pros:
  • Maintains conversation context
  • Builds on previous interactions
  • Natural chat experience
Cons:
  • Requires session storage
  • More complex state management
Use case: Long-running tasks, async workflows, scheduled jobs
// Queue job for background processing
app.post('/api/process', async (req, res) => {
  const jobId = generateJobId();

  // Return immediately
  res.json({ jobId, status: 'processing' });

  // Process in background
  processInBackground(async () => {
    const result = await agentbase.runAgent({
      message: req.body.task,
      mode: "max"
    });
    await saveResult(jobId, result);
    await notifyUser(jobId);
  });
});
Pros:
  • Non-blocking operations
  • Handle long tasks gracefully
  • Better user experience
Cons:
  • More complex architecture
  • Requires job queue
Use case: Real-time updates, chat UIs, progress tracking
// Stream agent responses
app.get('/api/stream', async (req, res) => {
  res.setHeader('Content-Type', 'text/event-stream');

  const stream = await agentbase.runAgent({
    message: req.query.message,
    mode: "base",
    stream: true
  });

  for await (const event of stream) {
    res.write(`data: ${JSON.stringify(event)}\n\n`);
  }

  res.end();
});
Pros:
  • Real-time feedback
  • Better UX for long tasks
  • See agent thinking process
Cons:
  • Requires SSE/WebSocket support
  • More complex client code

Security Best Practices

API Key Security

  • Never commit API keys to version control
  • Use environment variables
  • Rotate keys regularly
  • Use separate keys for dev/staging/prod

Input Validation

  • Validate and sanitize user inputs
  • Set message length limits
  • Filter sensitive information
  • Implement rate limiting

Access Control

  • Authenticate users before agent access
  • Implement role-based permissions
  • Log all agent interactions
  • Monitor for abuse

Data Privacy

  • Don’t send PII to agents unnecessarily
  • Implement data retention policies
  • Clear sensitive sessions
  • Comply with GDPR/CCPA

Monitoring & Observability

Track your agents in production:
Agentbase Dashboard (base.agentbase.sh)
  • Real-time cost tracking
  • Session monitoring
  • Usage analytics
  • Performance metrics

Scaling Considerations

Agentbase automatically handles scaling, but consider these patterns:

Connection Pooling

Reuse SDK instances across requests for better performance

Caching Strategy

Cache common agent responses to reduce costs and latency

Rate Limiting

Implement rate limits to prevent abuse and control costs

Load Balancing

Distribute requests across multiple API keys if needed

Next Steps