# HarnessRouter

> One self-hosted API that runs Codex, Claude Code, Hermes and other agent harnesses as product backends

- Category: AI Coding / Coding-Agent Harnesses & Runtimes
- Language: Python
- Licence: Apache-2.0
- Repository: https://github.com/HarnessRouter/harnessrouter
- Website: https://harnessrouter.ai/
- Canonical page: https://ai-tldr.dev/tools/harnessrouter/

## In short

HarnessRouter is an infrastructure layer that turns existing agent harnesses such as Codex and Claude Code into plug-and-play backends for your own product. Instead of integrating each harness separately and rebuilding sessions, streaming, file handling, cancellation and failure handling for every one, your product makes one integration and picks the harness per request. It sits in the Coding-Agent Harnesses & Runtimes category of the AI Coding tools and is open-source, written in Python and licensed Apache-2.0.

## Overview

HarnessRouter is an infrastructure layer that turns existing agent harnesses such as Codex and Claude Code into plug-and-play backends for your own product. Instead of integrating each harness separately and rebuilding sessions, streaming, file handling, cancellation and failure handling for every one, your product makes one integration and picks the harness per request. The Community Edition in this repository is the self-hosted, Apache-2.0 edition: you run it on your own infrastructure with your own model-provider keys, and no HarnessRouter account is needed.

It ships as a single Docker container holding three services. The Console (the only published port, 3000) is the web UI and the API entry point; the Gateway serves the OpenAI Responses-compatible API and the harness lifecycle; and the Runner executes harnesses in per-session workspaces with separate operating-system users. A /data volume keeps the database, files, secrets, installed harness CLIs and workspaces between restarts. On first launch it installs the enabled harness CLIs; its setup guide lists backends including Claude Code, Codex, Hermes, Pi, DeepSeek Harness, OpenCode, Qwen Code, Gemini CLI, Cline, Oh My Pi, goose and Kimi Code CLI.

The API follows the Unified Harness Protocol (UHP), an open, versioned standard whose task surface is deliberately compatible with the OpenAI Responses API, so existing Responses SDKs and streaming parsers can talk to it. You select a harness with metadata.harness_id, continue a session with previous_response_id, stream progress as server-sent events, attach input files and retrieve outputs. The repository also contains the UHP specification, its OpenAPI and JSON Schemas, and a conformance suite. A managed HarnessRouter Cloud offers the same API contract with serverless sandboxes, and custom harnesses built locally can be uploaded to it.

## What it does

- One OpenAI Responses-compatible API for many agent harnesses, chosen per request with metadata.harness_id
- Persistent sessions, streaming progress, input files and generated artifacts, cancellation, structured errors and execution traces
- Web Console to connect model providers (bring your own key), run tasks, and create custom harnesses with instructions, MCP tools and skills
- Self-hosted single Docker container: Console, Gateway and Runner, with separate session workspaces and native filesystem, shell and Git
- Per-request environment variables resolved from request headers or stored secrets, redacted from responses, streams and traces
- Reference implementation of the Unified Harness Protocol, with schemas and a conformance suite

## Getting started

The Community Edition runs from one Docker image. You need Docker, about 4 GB of disk and an API key from a model provider; no HarnessRouter account is required.

1. Start the container

   The named volume preserves the database, files, installed harness CLIs and workspaces between restarts. Do not add --user: the entrypoint and Runner need root to manage per-session users.

```bash
docker run -d --name harnessrouter \
  -p 127.0.0.1:3000:3000 \
  -v harnessrouter:/data \
  harnessrouter/harnessrouter
```

2. Wait for the first launch

   The first launch installs the enabled harness CLIs. Continue when the logs show "[harnessrouter] ready on :3000", then press Ctrl+C to stop following them.

```bash
docker logs -f harnessrouter
```

3. Open the Console

   Go to http://localhost:3000 and sign in with username harnessrouter and password harnessrouter. Change the default password in Profile, and keep the instance local until you do.

4. Connect a model provider

   Open Bring Your Own Key in the sidebar, press Add Integration, choose a provider, name the integration and add its API key. Its supported models become available in the Console.

5. Run your first task

   Open Agent harnesses, choose a harness and select New task. Pick a model, give the agent a concrete task, and follow its progress and output files in the same session.

6. Call it from your backend

   Create a key under API Keys in the Console, store it as HARNESSROUTER_API_KEY in your backend (never in browser code), and call the Responses-compatible endpoint with a harness id. Set "stream": true for server-sent events. The full API is described at $HARNESSROUTER_BASE_URL/v1/openapi.json.

```bash
export HARNESSROUTER_BASE_URL=http://localhost:3000/api/harness

curl --fail-with-body -sS "$HARNESSROUTER_BASE_URL/v1/responses" \
  -H "Authorization: Bearer ${HARNESSROUTER_API_KEY:?}" \
  -H 'content-type: application/json' \
  -d '{
    "input":"Reply with exactly: it works.",
    "metadata":{"harness_id":"codex"},
    "model":"gpt-5.4-mini",
    "stream":false
  }'
```

## When to use it

- Reach for it when your product needs agentic features and you want Codex, Claude Code or another harness as the backend without writing session, streaming and file plumbing for each
- Reach for it to compare or switch harnesses and models for a task behind one API, trading off cost and latency
- Reach for it when provider keys, sessions and workspaces must stay on infrastructure you control
- Reach for it to build a reusable custom harness with your own instructions, MCP tools and skills, test it in the Console, then call it by id
