Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 0 additions & 38 deletions .github/pull_request_template.md

This file was deleted.

4 changes: 0 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,6 @@ jobs:
./athena start --help
./athena stop --help
./athena status --help
./athena logs --help
./athena code --help

# Test version/help flags work
./athena --version || true # May not have version flag
Expand All @@ -117,8 +115,6 @@ jobs:
./athena.exe start --help
./athena.exe stop --help
./athena.exe status --help
./athena.exe logs --help
./athena.exe code --help

echo "✅ CLI commands validated on Windows"

Expand Down
17 changes: 5 additions & 12 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ jobs:
2. Make it executable: `chmod +x athena-<platform>`
3. Copy example config: `cp athena.example.yml ~/.config/athena/athena.yml`
4. Edit config with your OpenRouter API key
5. Run: `./athena-<platform> code` (launches daemon + Claude Code)
5. Run: `./athena-<platform> start` to launch daemon

## Files

Expand All @@ -147,17 +147,11 @@ jobs:

## Usage

### Launch daemon + Claude Code:
```bash
./athena-<platform> code
```

### Daemon management:
```bash
./athena-<platform> start # Start daemon in background
./athena-<platform> stop # Stop daemon
./athena-<platform> status # Check daemon status
./athena-<platform> logs # View daemon logs
```

### Run server directly (foreground):
Expand All @@ -183,17 +177,16 @@ jobs:
- Tool/function calling support
- Configurable model mappings (Opus, Sonnet, Haiku)
- Multiple configuration methods (CLI, config files, env vars)
- Built-in daemon management (start, stop, status, logs)
- Integrated Claude Code launcher (`athena code`)
- Structured logging with rotation
- Built-in daemon management (start, stop, status)
- Structured logging

### Quick Start
```bash
# Download binary for your platform
chmod +x athena-<platform>

# Launch daemon + Claude Code
./athena-<platform> code
# Launch daemon
./athena-<platform> start
```

### Downloads
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,5 @@ coverage.html
*.tmp
temp/
tmp/

worktrees/
74 changes: 64 additions & 10 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co

## Project Overview

Athena is a Go-based HTTP proxy server that translates Anthropic API requests to OpenRouter format, enabling Claude Code to work with OpenRouter's diverse model selection. The application uses minimal external dependencies (Cobra CLI framework, YAML parser, log rotation) and follows standard Go project layout with `cmd/` and `internal/` packages.
Athena is a Go-based HTTP proxy server that translates Anthropic API requests to OpenRouter format, enabling Claude Code to work with OpenRouter's diverse model selection. The application uses minimal external dependencies (Cobra CLI framework, YAML parser) and follows standard Go project layout with `cmd/` and `internal/` packages.

**Status**: Production-ready with all core features implemented and tested.

Expand Down Expand Up @@ -86,25 +86,79 @@ make build
./athena -port 9000 -api-key YOUR_KEY
```

### CLI Commands

Athena provides a simple 4-command interface:

```bash
# Run server in foreground (default)
athena

# Start server as background daemon
athena start

# Stop the daemon
athena stop

# Show daemon status
athena status
```

Logs are written to `~/.athena/athena.log` in daemon mode. View with standard tools:
```bash
# Follow logs in real-time
tail -f ~/.athena/athena.log

# Search logs
grep "error" ~/.athena/athena.log

# View last 100 lines
tail -n 100 ~/.athena/athena.log
```

**Log Levels:**
- `info` (default): High-level request/response metadata without bodies
- `debug`: Full request/response bodies logged (useful for troubleshooting)
- `warn`: Warnings and errors only
- `error`: Errors only

```bash
# Enable debug logging
athena --log-level debug

# Or via config file
# athena.yml:
log_level: "debug"

# Or via environment variable
export ATHENA_LOG_LEVEL=debug
athena start
```

### Testing the Proxy
```bash
# Health check
curl http://localhost:11434/health
curl http://localhost:12377/health

# Test message endpoint
curl -X POST http://localhost:11434/v1/messages \
curl -X POST http://localhost:12377/v1/messages \
-H "Content-Type: application/json" \
-H "X-Api-Key: your-openrouter-key" \
-d '{"model":"claude-3-sonnet","messages":[{"role":"user","content":"Hello"}]}'
```

### Configuration Management
The configuration system follows this priority: CLI flags > config files > env vars > defaults

Config files searched in order:
- `~/.config/athena/athena.{yml,json}`
- `./athena.{yml,json}`
- `./.env` (environment variables)
The configuration system follows this priority (highest to lowest):
1. **CLI flags** (via --flag options)
2. **Environment variables** (ATHENA_* prefixed)
3. **Local config file** (./athena.yml in current directory)
4. **Global config file** (~/.config/athena/athena.yml)
5. **Defaults** (hardcoded in config.go)

Config file discovery:
- If `--config` flag is provided, only that file is loaded
- Otherwise, both global and local configs are discovered and merged (local overrides global)
- Runtime state (PID file, logs) stored in `~/.athena/`

## Key Implementation Details

Expand Down Expand Up @@ -180,7 +234,7 @@ haiku_model: "google/gemini-pro" # Fast/cheap

### Local development with Ollama
```yaml
base_url: "http://localhost:11434/v1"
base_url: "http://localhost:12377/v1"
opus_model: "llama3:70b"
sonnet_model: "llama3:8b"
```
Expand Down
80 changes: 50 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ A proxy server that maps Anthropic's API format to OpenAI API format, allowing y
- 🎯 **Model Mapping**: Configurable mappings for Opus, Sonnet, and Haiku models
- 🔀 **Provider Routing**: Automatic Groq provider routing for Kimi K2 models
- ⚙️ **Flexible Configuration**: CLI flags, config files, environment variables, and .env files
- 🖥️ **Claude Code Integration**: Built-in launcher for seamless Claude Code TUI experience
- 🚀 **Minimal Dependencies**: Lightweight with only essential external packages (Cobra CLI, YAML, log rotation)
- 🚀 **Minimal Dependencies**: Lightweight with only essential external packages (Cobra CLI, YAML parser)

## Quick Start

Expand All @@ -33,16 +32,17 @@ curl -fsSL https://raw.githubusercontent.com/martinffx/athena/main/install.sh |

## Configuration

The proxy looks for configuration in this priority order:
1. Command line flags (highest priority)
2. Config files: `~/.config/athena/athena.{yml,json}` or `./athena.{yml,json}`
3. Environment variables (including `.env` file)
4. Built-in defaults (lowest priority)
The proxy looks for configuration in this priority order (highest to lowest):
1. **Command line flags** - CLI arguments override everything
2. **Environment variables** - ATHENA_* prefixed env vars
3. **Local config file** - `./athena.yml` in current directory
4. **Global config file** - `~/.config/athena/athena.yml`
5. **Built-in defaults** - Hardcoded fallback values

### Config File Example (YAML):
```yaml
# ~/.config/athena/athena.yml
port: "11434"
port: "12377"
api_key: "your-openrouter-api-key-here"
base_url: "https://openrouter.ai/api"
model: "moonshotai/kimi-k2-0905"
Expand All @@ -58,7 +58,7 @@ haiku_model: "anthropic/claude-3.5-haiku"
For fine-grained control over provider routing, add provider configurations to your YAML config:

```yaml
port: "11434"
port: "12377"
api_key: "your-openrouter-api-key-here"
base_url: "https://openrouter.ai/api"
model: "moonshotai/kimi-k2-0905"
Expand Down Expand Up @@ -87,7 +87,7 @@ export OPUS_MODEL="anthropic/claude-3-opus"
export SONNET_MODEL="anthropic/claude-3.5-sonnet"
export HAIKU_MODEL="anthropic/claude-3.5-haiku"
export DEFAULT_MODEL="moonshotai/kimi-k2-0905"
export PORT="11434"
export PORT="12377"
```

### .env File:
Expand All @@ -101,26 +101,49 @@ HAIKU_MODEL=anthropic/claude-3.5-haiku

## Usage

### Option 1: Just the proxy server
### Daemon Management

```bash
# Start the proxy server
athena -api-key YOUR_OPENROUTER_KEY
# Run in foreground (default)
athena

# In another terminal, configure Claude Code
export ANTHROPIC_BASE_URL=http://localhost:11434
export ANTHROPIC_API_KEY=YOUR_OPENROUTER_KEY
claude
# Run as background daemon
athena start

# Stop daemon
athena stop

# Check daemon status
athena status

# View logs (daemon mode)
tail -f ~/.athena/athena.log
```

### Option 2: Custom configuration
### Custom Configuration
```bash
# Use specific models and port
athena \
-port 9000 \
-api-key YOUR_KEY \
-opus-model "openai/gpt-4" \
-sonnet-model "google/gemini-pro" \
-haiku-model "meta-llama/llama-2-13b-chat"
# Use specific models and port (foreground)
athena -port 9000 -api-key YOUR_KEY

# Or run as daemon with custom port
athena start -port 9000 -api-key YOUR_KEY

# Enable debug logging to see full request/response bodies
athena --log-level debug
```

### Using with Claude Code

```bash
# Start Athena daemon
athena start

# Configure Claude Code to use the proxy
export ANTHROPIC_BASE_URL=http://localhost:12377
export ANTHROPIC_API_KEY=your-openrouter-key

# Run Claude Code
claude
```

## How It Works
Expand Down Expand Up @@ -192,7 +215,7 @@ haiku_model: "google/gemini-pro"

### Use Claude Code with Local Ollama:
```yaml
base_url: "http://localhost:11434/v1"
base_url: "http://localhost:12377/v1"
opus_model: "llama3:70b"
sonnet_model: "llama3:8b"
haiku_model: "llama3:8b"
Expand All @@ -212,15 +235,12 @@ athena -port 9000
echo $OPENROUTER_API_KEY

# Test the proxy directly
curl -X POST http://localhost:11434/v1/messages \
curl -X POST http://localhost:12377/v1/messages \
-H "Content-Type: application/json" \
-H "X-Api-Key: your-key" \
-d '{"model":"claude-3-sonnet","messages":[{"role":"user","content":"Hi"}]}'
```

### Claude Code not found:
Install Claude Code from: https://claude.ai/code

## License

MIT License - see [LICENSE](LICENSE) for details.
Expand Down
Binary file modified athena
Binary file not shown.
Loading
Loading