Skip to content
openma

Self-hosted AI agents

Self-Hosted AI Agents: Run Agents on Your Infra

Self-hosting an AI agent means running the part that matters for control: the agent loop, session history, tool sandbox, and credentials, on infrastructure you own, while still calling whichever model API you choose. An open managed runtime such as OpenMA provides those pieces as one deployable service.

What you keep

  • Data: conversation history, tool output, and files stay in your database and storage.
  • Keys: model and integration credentials stay in your vaults.
  • Choice: swap models, sandboxes, and harnesses without changing your client.

Self-host vs vendor-managed

The table compares the two vendor-managed agent runtimes with a self-hosted one on who runs each part and where data lives.

Self-hosted vs vendor-managed agent runtimes
Claude Managed AgentsOpenAI Agents API (managed harness)Self-hosted runtime
Who runs the agent loop The vendorThe vendorYou
Where session history lives Vendor cloudVendor cloudYour database
Where tools execute Vendor sandbox or self-hosted sandboxHosted or self-hosted sandboxSandbox provider you choose
Models ClaudeOpenAIAny provider or gateway you configure
Credentials Stored with the vendorStored with the vendorYour vault and secret store
Operations None for youNone for youYour team

Claude Managed Agents

Anthropic hosts the harness and sessions. Self-hosted sandboxes move only tool execution to your infrastructure. Read what Claude Managed Agents is, or compare Claude Managed Agents alternatives.

OpenAI Agents API (managed harness)

OpenAI runs the Codex-based harness, session state, and API. A self-hosted sandbox moves code execution to your infrastructure. See the OpenAI Agents API comparison.

This page is about self-hosting a managed agent runtime. Coding agents and agent frameworks can also be self-hosted, and the AI agent platform & orchestration guide explains how those categories differ.

Why teams self-host

Security and data residency

Agents see sensitive context: tickets, code, customer records, tool output. Self-hosting keeps that history and the sandbox inside your network, region, and audit tooling.

BYOK and model choice

Bring your own keys and pay providers directly. Route agents to different models by task, keep a fallback vendor, or use a private gateway, without changing the runtime.

Control of the loop

With an open runtime you can read the harness, change context engineering, and pick the sandbox. The trade-off is that you also own upgrades and on-call.

Deploying OpenMA

  1. Pick a target: Node.js or Docker on your servers, Fly.io, Vercel (beta), or Cloudflare.
  2. Choose storage: SQLite for one host, PostgreSQL or MySQL for replicas, or Cloudflare D1 / Durable Objects. Use S3-compatible storage or R2 for blobs.
  3. Choose a sandbox driver: Docker, BoxLite, E2B, Daytona, Modal, Sprites, Cloudflare, and others.
  4. Add model credentials as Model Cards: Anthropic, OpenAI, DeepSeek, OpenRouter, or a custom endpoint.
  5. Create an agent and a session through the Console, CLI, or API, and point your SDK at your deployment.

The quickest local start is Docker Compose:

git clone https://github.com/openma-ai/open-managed-agents
cd open-managed-agents
cp .env.example .env   # add a model provider key
docker compose up -d

For production, follow the Node + Docker guide, or read how to self-host an agent platform on Cloudflare Workers. Node deployments scale out across replicas with shared PostgreSQL or MySQL.

Where OpenMA fits

Coding agents inside the runtime

OpenMA is an open-source managed agent runtime. It provides the same building blocks as vendor-managed services (agents, environments, sessions, events, vaults, memory stores) with a Claude Managed Agents-compatible API at /v1 and an OpenAI Agents API adapter at /openai/v1.

Your applications, integrations, and teams call it to run agents of any kind. Coding agents such as Claude Code and Codex can run inside it through ACP adapters. For the category view, see AI agent platform & orchestration.

Related open-source paths

Compare open-source AI agents by category, or go straight to the open-source managed agents shortlist.

FAQ

What is a self-hosted AI agent?

An AI agent whose runtime (the agent loop, session history, tool execution, and credentials) runs on infrastructure you control. The model can still be a hosted API you call with your own key.

Do I need to self-host the model too?

No. You can call hosted model APIs with your own keys, or point the runtime at a private gateway or an open-weight model server if your policy requires it.

Can I self-host Claude Managed Agents?

Not the control plane. Claude Managed Agents supports self-hosted sandboxes, but the harness and sessions run on Anthropic. An open runtime such as OpenMA keeps the same API shape and runs entirely on your infrastructure.

What does it take to run OpenMA myself?

For a single host, Docker Compose with SQLite. For production, a Node deployment with PostgreSQL or MySQL, object storage, and a sandbox provider, or the Cloudflare setup wizard. The self-host docs cover each path.