Skip to main content
Run autonomous coding agents all night long for under $18 and wake up to a completed project with passing tests.

Overview

Ralph is an agentic loop that implements a project from a PRD. It picks a user story, writes the code, runs tests, and moves to the next story, repeating until everything passes. By running on Vast.ai with an open-source model, you get autonomous development without API costs. In this guide, we’ll start with a simple calculator example to see Ralph in action. Once that works, you can scale up to complex projects that run overnight.

Model: Qwen3-Coder-Next-FP8

Why Qwen3-Coder-Next?
  • Trained specifically for agentic coding tools (aider, Claude Code, Cline, etc.)
  • 256K context length

Prerequisites

  • Vast.ai account with API key (Sign up here)
  • Python 3.10 or later
  • git, jq, curl, openssl

Setup

Bash

Step 1: Deploy Qwen3-Coder-Next on Vast

Find a 4x RTX 4090 instance with CUDA 12.9+:
Bash
Generate a bearer token for the inference endpoint and deploy (replace <OFFER_ID> with an ID from the first column):
Bash
This guide uses three different keys:
  • Vast account API key, authenticates the Vast CLI (vastai set api-key)
  • Endpoint bearer token (MODEL_API_KEY), secures your SGLang inference endpoint
  • Client SDK key (OPENAI_API_KEY), set to the same value as the endpoint bearer token so Aider’s OpenAI-compatible client can authenticate

Step 2: Get Your Endpoint

Wait 10-15 minutes for the model weights (~80GB) to download and load. You can monitor progress with vastai logs <INSTANCE_ID>, look for “The server is fired up and ready to roll!” Then get your endpoint:
Bash
Verify it’s ready (SGLang returns HTTP 200 with an empty body, that’s normal):
Bash

Step 3: Configure Aider for Vast

Set environment variables to point Aider at your Vast endpoint. OPENAI_API_KEY must be set to the same endpoint bearer token you generated in Step 1:
Bash

Step 4: Verify Aider Connectivity

Test that Aider can reach your Vast endpoint:
Bash
You should see Aider respond. If you get connection errors, verify the endpoint URL and that the model finished loading (check vastai logs <INSTANCE_ID>).

Step 5: Add Aider Support to Ralph

Ralph doesn’t include aider as a tool out of the box. You need to make two edits to ralph.sh: Edit 1: Add aider to the tool validation. Find the line that validates the --tool argument:
Bash
Add aider as a valid option:
Bash
Edit 2: Add the aider tool block. Find the elif chain that runs each tool (look for the claude block). After the last elif block and before the closing fi, add:
Bash
This tells aider to use the Vast-hosted Qwen3-Coder-Next model (via the OPENAI_API_BASE env var you set in Step 3), load the PRD file for context, and run non-interactively with the Ralph prompt.

Step 6: Run Ralph

Create a prd.json that defines what you want Ralph to build. Note that testCommand is informational, the agent reads it from the PRD to know how to run tests, but ralph.sh itself doesn’t execute it.
JSON
Run Ralph:
Bash
Ralph creates calculator.py and test_calculator.py from scratch, implementing each user story and running tests until they pass. Example output (calculator.py):
Python
Example output (test_calculator.py):
Python

Cleanup

Destroy the instance when done:
Bash

Next Steps: Overnight Ralph Loop

Project ideas for overnight runs:
  • Full CLI application with subcommands, config files, and help system
  • REST API with authentication, validation, and multiple resource types
  • Web scraper with multiple site adapters, rate limiting, and data export
  • Complete test suite for an existing codebase (one test file per module)
  • Database migration system with schema versioning and rollback
To run Ralph unattended overnight:
Bash
Cost estimate: At ~$1.50/hr, an 8-12 hour overnight run costs $12-18. Tips:
  • Use tmux or screen instead of nohup if you want to reattach later
  • Monitor with vastai show instance <ID> to ensure the instance stays running
  • Check progress.txt for Ralph’s learnings across iterations
  • Commit your prd.json before starting so you can reset if needed
  • Remember to vastai destroy instance <INSTANCE_ID> when the run finishes, instances bill by the hour even when idle

Resources