Janus

Documentation

Configuration & Auth

Install, configure, and run Janus, then complete your first agent-to-agent task handoff.

3. Build from Source (optional)

To run Janus outside Docker (development, custom builds, debugging):

# Start the three dependencies
docker compose -f deployments/smoke-deps.compose.yaml up -d postgres nats redis

# Build the server binary
cd server && go build -o janus-api ./cmd/janus-api/

# Run with environment variables
JANUS_PG_HOST=localhost JANUS_PG_USER=janus JANUS_PG_DATABASE=janus \
JANUS_NATS_URL=nats://localhost:4222 JANUS_REDIS_ADDR=localhost:6379 \
JANUS_AUTH_ENABLED=false ./janus-api

4. Configure Janus

Janus reads configuration from environment variables (highest priority) and/or a YAML config file. The Compose file already wires up sensible defaults for local development.

Environment Variables

The most commonly tuned variables (all prefixed JANUS_):

VariableDefaultDescription
JANUS_CONFIG_FILE—Path to a YAML config file; environment variables still take precedence over file values
JANUS_HTTP_PORT8080HTTP REST API port
JANUS_GRPC_PORT9090gRPC API port
JANUS_PG_HOSTlocalhostPostgreSQL host
JANUS_PG_PORT5432PostgreSQL port
JANUS_PG_USER / PASSWORD / DATABASEjanusPostgreSQL credentials
JANUS_NATS_URLnats://localhost:4222NATS connection URL
JANUS_REDIS_ADDRlocalhost:6379Redis address (rate-limit & heartbeat)
JANUS_AUTH_ENABLEDtrueEnable API key authentication
JANUS_MIGRATION_AUTOfalseAuto-run DB migrations on boot
JANUS_OUTBOX_RETENTION_DAYS0Delete delivered & projected outbox rows older than N days (0 keeps every row; use ≥ 35 when Janus Enterprise is deployed)
JANUS_TLS_ENABLEDfalseEnable TLS (set with CERT_FILE / KEY_FILE / CLIENT_CA_FILE)

YAML Config File

For complex deployments, point Janus at a YAML file via JANUS_CONFIG_FILE. Start from the reference file:

cp configs/janus.example.yaml configs/janus.local.yaml

# Then run with:
JANUS_CONFIG_FILE=configs/janus.local.yaml ./janus-api

The YAML mirrors the environment variables and adds structured sections for the outbox, heartbeat, and observability:


queue:
  driver: nats

http_port: 8080
grpc_port: 9090

postgres:
  host: localhost
  port: 5432
  user: janus
  password: ${JANUS_PG_PASSWORD}   # env interpolation supported
  database: janus
  max_conns: 20

nats:
  url: "nats://localhost:4222"

redis:
  addr: "localhost:6379"    # optional accelerator

migration:
  auto: true
  path: migrations/

outbox:
  worker_interval: 500ms
  batch_size: 50            # tune up for high write volume
  lease_duration: 60s
  max_attempts: 10
  retention_days: 0         # 0 = keep forever; >= 35 when Janus Enterprise is deployed

budget:
  rate_limit_failure_mode: fail-open

metrics:
  enabled: true
  path: /metrics

tracing:
  enabled: false
  otlp_endpoint: "localhost:4317"

Project Config (Declarative)

A second YAML file — the project config — declares your agents, budgets, and governance policies as code. It complements the server config above (connections & runtime): the project file defines your tenant topology. Apply it with the Janus CLI:

# 1. Generate a starter janus.project.yaml in the current directory
janus project init

# 2. Edit it to declare agents, budgets, and policies
#    (full schema: configs/janus.project.example.yaml)

# 3. Preview the changes without applying them
janus project diff

# 4. Apply (idempotent — safe to re-run in CI/CD)
janus project apply

How the CLI finds the project file — resolved in this order (first hit wins):

PrioritySourceExample
1--file flagjanus project apply --file configs/janus.project.yaml
2JANUS_PROJECT_FILE env varexport JANUS_PROJECT_FILE=configs/janus.project.yaml
3janus.project.yaml in the current directory (default)run janus project init to create it

JANUS_PROJECT_FILE tells the CLI where to look — the API server does not read it directly. End-to-end example:

# Generate the starter file
janus project init

# Declare agents, budgets, and policies in the YAML (see below)

# Apply the file explicitly by path
export JANUS_PROJECT_FILE=configs/janus.project.yaml
janus project diff      # review
janus project apply     # apply (idempotent)

A project file declares the full tenant topology — agents and their capabilities, per-tenant and per-team budgets, and allow/deny/approve policies:

version: v1
default_tenant: acme

defaults:
  protocol: custom-sdk
  mailbox:
    ack_wait_seconds: 300
    max_deliver: 5
  policy:
    priority: 100

tenants:
  acme:
    name: Acme Engineering

    agents:
      code-review:
        team: engineering
        capabilities:
          - id: code_review
            data_classifications: [public, internal, confidential]
        concurrency: 4

    budgets:
      tenant:
        tpm: 2000000# tokens per minute
      teams:
        engineering:
          concurrency: 20
          tpm: 600000

    policies:
      approve:
        capabilities: [prod_deploy]# require human approval
      allow:
        - agent: code-review
          capability: code_review
      deny:
        - agent: intern-agent
          tool: deploy.prod
      data_classification:
        deny:
          - team: interns
            classifications: [confidential, restricted]

Full schema: configs/janus.project.example.yaml in the repo.

Field Reference

Every field maps to a Janus core resource. The tables below explain each level of the file.

Top level

FieldTypeDescription
versionstringSchema version. Currently v1. Required.
default_tenantstringTenant targeted when --tenant isn't passed. Must exist under tenants.
defaultsobjectValues inherited by every tenant and agent unless overridden locally.
tenantsmapTenant declarations, keyed by tenant ID. Required.

defaults — inherited by all tenants:

FieldDefaultDescription
protocolcustom-sdkAgent communication protocol. Applied when an agent doesn't set its own.
classification—Default data classification. One of: public, internal, confidential, restricted.
mailbox.ack_wait_seconds—Seconds before an unacked task is redelivered to the mailbox.
mailbox.max_deliver—Max delivery attempts before the task moves to the dead letter queue.
mailbox.retention_seconds—How long completed mailbox state is retained.
capacity.max_concurrency1Default max concurrent in-flight tasks per agent.
policy.priority—Priority assigned to auto-generated policy rules (higher = evaluated first).

Tenant (tenants.<id>):

FieldTypeDescription
namestringHuman-readable display name.
agentsmapAgent declarations keyed by agent ID.
budgetsobjectCost and rate limits at tenant, team, agent, model, and task scope.
policiesobjectAllow, deny, approval, and data-classification rules compiled into policy templates.

Agent (tenants.<id>.agents.<id>):

FieldTypeDescription
namestringDisplay name. Defaults to the agent ID.
teamstringTeam ID. Enables team-level budgets and policy targeting.
protocolstringOverrides defaults.protocol for this agent.
endpointstringCallback URL where the agent receives task notifications.
descriptionstringFree-text description of what the agent does.
capabilitieslistCapabilities this agent can handle. Each entry is a string or an object with id, description, and data_classifications. Required — at least one.
concurrencyintMax concurrent in-flight tasks. Overrides capacity.max_concurrency.
rpm / tpmintRequests-per-minute and tokens-per-minute metadata for budget enforcement.
mailboxobjectPer-agent mailbox override. If omitted, a default mailbox <agent-id>.default is auto-created.

Budget limits — each budget scope accepts the same fields:

FieldDescription
rpmMax requests per minute.
tpmMax tokens per minute.
concurrencyMax concurrent operations.
daily_usdProject-config entry: not wired. Daily cost thresholds ARE enforced — via the budgets API/CLI (daily_cost_usd, estimated at a fixed rate from ACK-reported tokens), not through this project-file field.
monthly_usdPlanned. Not yet enforced — awaiting trusted token metering.

Budget scopes: tenant (whole tenant), teams.<id>, agents.<id>, models.<id>, model_providers.<id>, tasks.<id>.

Policies — compiled into policy rules via templates:

FieldDescription
approve.capabilitiesCapabilities that require human approval before execution.
approve.toolsTools that require human approval before invocation.
allow / denyBindings of agent or team to a capability or tool. A binding must set exactly one of agent/team and one of capability/tool.
data_classification.allow/denyControls which data classifications an agent or team may receive.

Multi-Agent Example

A realistic project file with three agents across two teams, per-team budgets, and governance policies:

version: v1
default_tenant: acme

defaults:
  protocol: custom-sdk
  mailbox:
    ack_wait_seconds: 300
    max_deliver: 5
  policy:
    priority: 100

tenants:
  acme:
    name: Acme Engineering
    agents:
      code-review:          # agent 1: reviews pull requests
        team: engineering
        capabilities:
          - id: code_review
            data_classifications: [public, internal, confidential]
        concurrency: 4
      test-runner:           # agent 2: runs test suites
        team: engineering
        capabilities: [test_run]
        concurrency: 8
      deploy-bot:            # agent 3: production deployments
        team: sre
        endpoint: https://deploy.internal.acme.com
        capabilities:
          - id: prod_deploy
            description: Deploy to production
        concurrency: 1
        mailbox:
          ack_wait_seconds: 600    # deploys take longer
    budgets:
      tenant:
        tpm: 2000000
      teams:
        engineering:
          concurrency: 20
          tpm: 600000
        sre:
          concurrency: 4
    policies:
      approve:
        capabilities: [prod_deploy]   # require human approval
        tools: [deploy.prod]
      allow:
        - agent: code-review
          capability: code_review
        - agent: test-runner
          capability: test_run
      deny:
        - agent: deploy-bot
          tool: deploy.prod          # blocked unless approved
      data_classification:
        deny:
          - team: interns
            classifications: [confidential, restricted]
The project file is declarative and idempotent — janus project apply creates missing resources and updates existing ones without deleting anything. Run janus project diff first to preview changes.

Adding Agents Dynamically

The project file is not the only entry point — you can add an agent to an existing tenant at any time with janus agent add. It registers the agent, creates its default mailbox, and persists the change back to janus.project.yaml:

janus agent add summarizer --tenant acme --team engineering --capability summarize
# → Agent summarizer added to tenant acme and saved to janus.project.yaml

Repeat --capability to grant multiple capabilities, use --classification to restrict data classifications per capability, and omit --mailbox to auto-create the <agent-id>.default mailbox:

janus agent add indexer --tenant acme --endpoint https://idx.internal.acme.com --capability index --capability search --concurrency 4
janus agent status indexer --tenant acme
janus agent heartbeat indexer --tenant acme

For a one-off runtime registration that is not written to the project file, use janus agent register. --protocol accepts a2a, acp, or custom-sdk (default a2a):

janus agent register --id adhoc-worker --name "Adhoc Worker" --protocol custom-sdk

Authentication

Every API call to Janus is authenticated with a tenant-scoped API key (enabled by default). Optionally, mTLS can be layered on for stricter machine-to-machine deployments.

Installing the CLI

The janus CLI ships with the repo and is also published on the releases page. Build it once (requires Go 1.25+):

go install ./cli # from the repo root; binary lands in $(go env GOPATH)/bin
janus version

Or download a prebuilt binary from the releases page and put it on your PATH.
Or install remotely once the module is published: go install github.com/agentium-lab/Janus/cli@v1.11.0.

API Keys

With auth.enabled on (the default), every request must present a valid key via the X-API-Key or Authorization: Bearer <key> header. Keys are bound to one tenant — a key issued for tenant A cannot reach tenant B (the server rejects the call with 403).

Create a key with the CLI. The raw key — janus_<64 hex chars> — is returned only once, so store it immediately:

janus --tenant acme api-key create --name ci-bot
# → {"tenant_id":"acme","name":"ci-bot","prefix":"janus_a1","key":"janus_a1b2c3...","created_at":"..."}  (store the key — shown only once)

The server keeps only a SHA-256 hash of the key plus its 8-character prefix for lookup, so the raw key can never be recovered. List and revoke keys the same way:

janus --tenant acme api-key list
janus --tenant acme api-key revoke <key-id>

Point the CLI or SDK at a key with --api-key or the JANUS_API_KEY environment variable, and pass it on plain HTTP calls as a header:

export JANUS_API_KEY=janus_a1b2c3d4e5…
curl -H "Authorization: Bearer $JANUS_API_KEY" http://localhost:8080/v1/tenants/acme/tasks

mTLS (optional)

For stricter machine-to-machine security, enable TLS and require client certificates. When client_ca_file is set, Janus verifies client certificates (mutual TLS, minimum TLS 1.2):

# configs/janus.local.yaml
auth:
  enabled: true

tls:
  enabled: true
  cert_file: /etc/janus/server.crt
  key_file: /etc/janus/server.key
  client_ca_file: /etc/janus/ca.crt   # set to require client certificates (mTLS)

Or with environment variables (all JANUS_-prefixed):

export JANUS_AUTH_ENABLED=true
export JANUS_TLS_ENABLED=true
export JANUS_TLS_CERT_FILE=/etc/janus/server.crt
export JANUS_TLS_KEY_FILE=/etc/janus/server.key
export JANUS_TLS_CLIENT_CA_FILE=/etc/janus/ca.crt

Keep auth.enabled on in production — when disabled, every API endpoint is unauthenticated.

LLM for Intent Routing (optional)

To enable target_type: "intent" (natural language → capability routing), configure an OpenAI-compatible LLM:

# Environment variables
export JANUS_LLM_ENABLED=true
export JANUS_LLM_API_KEY=sk-xxx
export JANUS_LLM_MODEL=gpt-4o-mini
export JANUS_LLM_BASE_URL=https://api.openai.com/v1  # or Ollama/vLLM/Azure

When LLM is not configured, target_type: "intent" falls back to keyword matching (no external dependency). When configured, Janus maps natural language to the best matching capability via the LLM, validates the result against the online agent catalog, then routes deterministically.