suna/backend
Pratyush Shukla 2b7e437d63
Merge branch 'main' into new-system-prompt
2025-10-03 15:09:07 +05:30
..
core Merge branch 'main' into new-system-prompt 2025-10-03 15:09:07 +05:30
supabase fix 2025-09-29 16:39:15 +02:00
.dockerignore migrate: switch to uv from poetry 2025-06-15 12:29:47 +00:00
.env.example doc parser tool 2025-09-29 10:59:50 +05:30
.gitignore final 2025-08-11 13:51:28 +05:30
Dockerfile docker dependencies 2025-09-27 04:14:38 +05:30
MANIFEST.in fe reference wip 2025-03-29 23:48:57 -07:00
README.md frontend model selection slight cleanup 2025-09-21 18:36:53 +02:00
TESTING.md fix: prompt caching and double system prompt 2025-09-14 15:13:00 +05:30
api.py Merge pull request #1759 from escapade-mckv/research-agent 2025-09-30 21:01:41 +05:30
docker-compose.yml refactor: remove RabbitMQ from the project 2025-08-05 21:29:36 +05:30
lucide_icons.json icons 2025-09-19 09:20:58 +05:30
lucide_icons_cleaned.json icons 2025-09-19 09:20:58 +05:30
pyproject.toml Merge branch 'main' into doc-parser 2025-09-29 23:17:00 +05:30
pytest.ini fix: prompt caching and double system prompt 2025-09-14 15:13:00 +05:30
run_agent_background.py rm general tab, integrations tab default 2025-09-29 14:12:45 +02:00
run_tests.py fix: prompt caching and double system prompt 2025-09-14 15:13:00 +05:30
sentry.py Revert "Merge pull request #901 from tnfssc/perf/remove-dramatiq-worker-rabbitmq" 2025-07-09 18:15:37 +00:00
test fix: prompt caching and double system prompt 2025-09-14 15:13:00 +05:30
uv.lock Merge branch 'main' into doc-parser 2025-09-29 23:17:00 +05:30
worker_health.py mv around files, update imports 2025-09-04 16:59:34 -07:00

README.md

Suna Backend

Quick Setup

The easiest way to get your backend configured is to use the setup wizard from the project root:

cd .. # Navigate to project root if you're in the backend directory
python setup.py

This will configure all necessary environment variables and services automatically.

Running the backend

Within the backend directory, run the following command to stop and start the backend:

docker compose down && docker compose up --build

Running Individual Services

You can run individual services from the docker-compose file. This is particularly useful during development:

Running only Redis

docker compose up redis

Running only the API and Worker

docker compose up api worker

Development Setup

For local development, you might only need to run Redis, while working on the API locally. This is useful when:

  • You're making changes to the API code and want to test them directly
  • You want to avoid rebuilding the API container on every change
  • You're running the API service directly on your machine

To run just Redis for development:

docker compose up redis

Then you can run your API service locally with the following commands:

# On one terminal
cd backend
uv run api.py

# On another terminal
cd backend
uv run dramatiq --processes 4 --threads 4 run_agent_background

Environment Configuration

The setup wizard automatically creates a .env file with all necessary configuration. If you need to configure manually or understand the setup:

Required Environment Variables

# Environment Mode
ENV_MODE=local

# Database (Supabase)
SUPABASE_URL=https://your-project.supabase.co
SUPABASE_ANON_KEY=your-anon-key
SUPABASE_SERVICE_ROLE_KEY=your-service-role-key

# Infrastructure
REDIS_HOST=redis  # Use 'localhost' when running API locally
REDIS_PORT=6379
# LLM Providers (at least one required)
ANTHROPIC_API_KEY=your-anthropic-key
OPENAI_API_KEY=your-openai-key
OPENROUTER_API_KEY=your-openrouter-key
GEMINI_API_KEY=your-gemini-api-key

# Search and Web Scraping
TAVILY_API_KEY=your-tavily-key
FIRECRAWL_API_KEY=your-firecrawl-key
FIRECRAWL_URL=https://api.firecrawl.dev

# Agent Execution
DAYTONA_API_KEY=your-daytona-key
DAYTONA_SERVER_URL=https://app.daytona.io/api
DAYTONA_TARGET=us

WEBHOOK_BASE_URL=https://yourdomain.com

# MCP Configuration
MCP_CREDENTIAL_ENCRYPTION_KEY=your-generated-encryption-key

# Optional APIs
RAPID_API_KEY=your-rapidapi-key

NEXT_PUBLIC_URL=http://localhost:3000

When running services individually, make sure to:

  1. Check your .env file and adjust any necessary environment variables
  2. Ensure Redis connection settings match your local setup (default: localhost:6379)
  3. Update any service-specific environment variables if needed

Important: Redis Host Configuration

When running the API locally with Redis in Docker, you need to set the correct Redis host in your .env file:

  • For Docker-to-Docker communication (when running both services in Docker): use REDIS_HOST=redis
  • For local-to-Docker communication (when running API locally): use REDIS_HOST=localhost

Example .env configuration for local development:

REDIS_HOST=localhost # (instead of 'redis')
REDIS_PORT=6379
REDIS_PASSWORD=


Production Setup

For production deployments, use the following command to set resource limits

docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d