Skip to content
// reference [ 3.00 ]

API Reference

CLI commands and REST API endpoints.


API Reference

// CLI Commands

elith init

Initialize Elith configuration:

bashcopy
elith init

Creates ~/.elith/config.toml with provider settings.

elith explain

Understand code with detailed explanations:

bashcopy
elith explain <file_or_directory>

Examples:

bashcopy
elith explain src/auth/login.ts
elith explain src/cache/

elith architect

Design solutions and create architecture plans:

bashcopy
elith architect "<task description>"

Examples:

bashcopy
elith architect "Design a caching layer for the API"
elith architect "Plan database migration strategy"

elith refactor

Implement code changes:

bashcopy
elith refactor "<task description>"

Examples:

bashcopy
elith refactor "Add error handling to auth module"
elith refactor "Optimize database queries in user service"

elith test-gen

Generate test suites:

bashcopy
elith test-gen <file>

Examples:

bashcopy
elith test-gen src/auth/login.ts
elith test-gen src/cache/redis-client.ts

elith service

Manage the backend service:

bashcopy
elith service start     # Start backend daemon
elith service stop      # Stop backend daemon
elith service restart   # Restart backend daemon
elith service status    # Check if running

The backend auto-starts when you run any operation command.

// REST API

Base URL: http://localhost:8000

POST /scan

Scan repository structure:

curl -X POST http://localhost:8000/scan \
  -H "Content-Type: application/json" \
  -d '{
    "repo_path": "/path/to/repo"
  }'
Response
jsoncopy
{
  "files": 247,
  "directories": 42,
  "languages": ["TypeScript", "Python", "JavaScript"]
}

POST /execute

Execute an operation:

curl -X POST http://localhost:8000/execute \
  -H "Content-Type: application/json" \
  -d '{
    "operation": "explain",
    "target": "src/auth/login.ts",
    "repo_path": "/path/to/repo"
  }'

Operations: explain, architect, refactor, test-gen

Response
jsoncopy
{
  "session_id": "abc123",
  "status": "running"
}

GET /stream

Stream operation results via Server-Sent Events:

curl -N http://localhost:8000/stream?session_id=abc123

Event format:

data: {"type": "token", "content": "Analyzing code..."}

data: {"type": "skill", "name": "read_file", "args": {"path": "src/auth/login.ts"}}

data: {"type": "complete", "session_id": "abc123"}

Event types:

  • token — Streaming LLM output
  • skill — Skill execution
  • complete — Operation finished
  • error — Operation failed

GET /models

List available models:

curl http://localhost:8000/models
Response
jsoncopy
{
  "providers": [
    {
      "name": "claude",
      "enabled": true,
      "models": ["claude-3-5-sonnet-20241022", "claude-3-opus-20240229"]
    },
    {
      "name": "lmstudio",
      "enabled": false,
      "models": ["local-model"]
    },
    {
      "name": "openrouter",
      "enabled": false,
      "models": ["anthropic/claude-3.5-sonnet"]
    }
  ]
}

GET /tasks

List recent tasks:

curl http://localhost:8000/tasks
Response
jsoncopy
{
  "tasks": [
    {
      "session_id": "abc123",
      "operation": "explain",
      "target": "src/auth/login.ts",
      "timestamp": "2026-05-18T12:30:45Z",
      "status": "complete"
    }
  ]
}

GET /history

Get session history:

curl http://localhost:8000/history
Response
jsoncopy
{
  "sessions": [
    {
      "id": "abc123",
      "operation": "refactor",
      "started": "2026-05-18T12:30:45Z",
      "completed": "2026-05-18T12:35:12Z",
      "files_modified": 4,
      "provider": "claude-3-5-sonnet-20241022"
    }
  ]
}

GET /results/:session_id

Get operation results:

curl http://localhost:8000/results/abc123
Response
jsoncopy
{
  "session_id": "abc123",
  "operation": "refactor",
  "status": "complete",
  "output": "Full operation output...",
  "files_modified": ["src/auth/login.ts", "src/auth/types.ts"],
  "report_path": "bob-reports/session_20260518_123045_abc123.md"
}

// CLI Exit Codes

  • 0 — Success
  • 1 — Operation failed
  • 2 — Configuration error
  • 3 — Backend not running

// Environment Variables

Override config with environment variables:

# Provider API keys
ANTHROPIC_API_KEY=sk-ant-...
OPENAI_API_KEY=sk-...
GOOGLE_API_KEY=AIza...

# Provider selection
ANTHROPIC_MODEL=claude-3-opus-20240229
OPENROUTER_API_KEY=sk-or-...

# Backend configuration
ELITH_BACKEND_PORT=8000
ELITH_LOG_LEVEL=DEBUG

// Session Logs

All operations are logged to bob-reports/:

# List all sessions
ls -la bob-reports/

# View a session
cat bob-reports/session_20260518_123045_abc123.md

# View session history JSON
cat bob-reports/session_history.json

// Next Steps