Getting StartedDeploy

Deploy

Beta

Deploy your ConnectOnion agents to production. Docker, GCP, AWS - your choice.

Why deploy? Run agents 24/7, scale horizontally, integrate with existing infrastructure. Your agents become production services.

Two Deployment Options

Recommended

co deploy

Quick deployment to ConnectOnion Cloud. Managed hosting, no infrastructure to manage.

  • One command deployment
  • Automatic HTTPS
  • Re-deploy updates same URL

Self-Host

Full control with your own infrastructure. Use Docker, GCP, AWS, or any VPS.

  • Full control
  • Custom domains
  • Compliance requirements

60-Second Quick Start

Deploy your agent with the CLI - one command:

Terminal
# Create an agent project co create my-agent # Navigate to the project cd my-agent # Deploy to ConnectOnion Cloud co deploy
output
Deploying to ConnectOnion Cloud...
 
Project: my-agent
Env vars: 3 keys
 
Uploading...
Building...
 
Deployed!
Agent URL: https://my-agent-abc123.agents.openonion.ai

co deploy Requirements

Git repository with committed code
.co/host.yaml (created by co create or co init)
Authenticated (co auth)

Configuration

.co/host.yaml
# .co/host.yaml name: my-agent entrypoint: agent.py env: .env

Environment Variables

Environment variables from .env are securely passed to your agent:

.env
# .env OPENAI_API_KEY=sk-xxx DATABASE_URL=postgres://...

Note: URL format is {project_name}-{your_address[:10]}.agents.openonion.ai. Re-deploying updates the same URL.

Self-Host Paths

Self-Host with host()

Deploy to your own infrastructure using host():

agent.py
# agent.py from connectonion import Agent, host agent = Agent("my-agent", tools=[my_tool]) # Export ASGI app for uvicorn/gunicorn app = host.app(agent) if __name__ == "__main__": host(agent)

Run with uvicorn/gunicorn

code
# Direct python agent.py # Uvicorn uvicorn agent:app --workers 4 # Gunicorn gunicorn agent:app -w 4 -k uvicorn.workers.UvicornWorker

For full API reference, see host() documentation.

Docker Deployment

The simplest way to deploy - works anywhere Docker runs:

1. Create Your Agent

agent.py
# agent.py from connectonion import Agent, host def search(query: str) -> str: """Search for information.""" return f"Results for: {query}" agent = Agent( name="my-agent", tools=[search], system_prompt="You are a helpful assistant." ) # Host the agent host(agent)

2. Dockerfile

Dockerfile
FROM python:3.11-slim WORKDIR /app # Install dependencies COPY requirements.txt . RUN pip install --no-cache-dir -r requirements.txt # Copy agent code COPY agent.py . # Run the agent CMD ["python", "agent.py"]

3. Build & Run

Terminal
# Build the image docker build -t my-agent . # Run with API key docker run -d \ -e OPENAI_API_KEY=$OPENAI_API_KEY \ --name my-agent \ my-agent
output
Building image...
Successfully built a1b2c3d4e5f6
Successfully tagged my-agent:latest
 
Container started: my-agent
Agent serving at: 0x3d4017c3e843895a...

Deploy to Google Cloud Run

Serverless deployment with automatic scaling:

1. Build & Push to Container Registry

Terminal
# Authenticate with GCP gcloud auth login # Set project gcloud config set project YOUR_PROJECT_ID # Build and push gcloud builds submit --tag gcr.io/YOUR_PROJECT_ID/my-agent

2. Deploy to Cloud Run

Terminal
gcloud run deploy my-agent \ --image gcr.io/YOUR_PROJECT_ID/my-agent \ --platform managed \ --region us-central1 \ --set-env-vars "OPENAI_API_KEY=sk-..." \ --allow-unauthenticated
output
Deploying container to Cloud Run service [my-agent]...
Done.
 
Service URL: https://my-agent-abc123-uc.a.run.app
Agent address: 0x3d4017c3e843895a92b70aa74d1b7ebc...

Security Note

Use Secret Manager for API keys in production instead of environment variables.

Deploy to AWS

Multiple options depending on your needs:

EC2 / Lightsail

Simple VPS deployment. Best for always-on agents.

  • Full control over environment
  • Predictable pricing
  • Easy SSH access

ECS / Fargate

Container orchestration. Best for scaling.

  • Auto-scaling built in
  • Load balancing
  • Rolling deployments

EC2 Quick Deploy

Terminal
# SSH to your EC2 instance ssh -i your-key.pem ubuntu@your-instance-ip # Install dependencies sudo apt update && sudo apt install -y python3-pip docker.io # Clone and run git clone https://github.com/your/agent-repo.git cd agent-repo docker build -t my-agent . docker run -d -e OPENAI_API_KEY=$OPENAI_API_KEY my-agent

Environment Variables

Configure your agent for different environments:

VariableDescriptionRequired
OPENAI_API_KEYOpenAI API key for GPT modelsYes*
ANTHROPIC_API_KEYAnthropic API key for ClaudeOptional
GOOGLE_API_KEYGoogle API key for GeminiOptional
RELAY_URLCustom relay server URLOptional
LOG_LEVELLogging verbosity (DEBUG, INFO, WARN)Optional

* Or use ConnectOnion managed keys with co auth - no API keys needed!

Best Practices

Security

  • Use secret managers for API keys
  • Never commit .co/ or .env
  • Use non-root container users
  • Enable HTTPS for all endpoints

Reliability

  • Add health checks to containers
  • Set up automatic restarts
  • Configure logging and monitoring
  • Use persistent volumes for keys

Ready to Deploy?

Your agents are production-ready. Ship them!

Star us on GitHub

If ConnectOnion saves you time, a ⭐ goes a long way — and earns you a coffee chat with our founder.