Skip to content

Provider error: 401 - {\"error\":\"API key not found\",\"code\":\"AUTH_FAILED\"} #14

@freakynit

Description

@freakynit

Error thrown by claude session

502 {"error":{"code":502,"message":"Provider error: 401 - {\"error\":\"API key not
     found\",\"code\":\"AUTH_FAILED\"}","type":"invalid_request_error"}}

config.yaml (~/.lunaroute/lunaroute.yaml)

# Save as claude-passthrough.yaml
host: "127.0.0.1"
port: 9001
api_dialect: "anthropic"  # Accept Anthropic format

providers:
  anthropic:
    enabled: true
    base_url: "https://ai.megallm.io"
    # No api_key needed - Claude Code sends it via x-api-key header

session_recording:
  enabled: true  # Disable for maximum performance

  # SQLite analytics - lightweight session stats
  sqlite:
    enabled: true
    path: "~/.lunaroute/sessions.db"
    max_connections: 10

  # JSONL logs - full request/response recording
  jsonl:
    enabled: true
    directory: "~/.lunaroute/sessions"
    retention:
      max_age_days: 30
      max_size_mb: 1024

# Web UI for browsing sessions
ui:
  enabled: true
  host: "127.0.0.1"
  port: 8082
  refresh_interval: 5

logging:
  level: "info"
  log_requests: true

Note: I have set base_url for anthropic since I was already using a proxy and my API token comes from that proxy (https://megallm.io)

Start Command

lunaroute-server --config ~/.lunaroute/lunaroute.yaml

lunaroite console logs

         ___---___
      .--         --.
    ./   ()      .-. \.
   /   o    .   (   )  \
  / .            '-'    \    _                      ____             _
 | ()    .  O         .  |  | |   _   _ _ __   __ _|  _ \ ___  _   _| |_ ___
|                         | | |  | | | | '_ \ / _` | |_) / _ \| | | | __/ _ \
|    o           ()       | | |__| |_| | | | | (_| |  _ < (_) | |_| | ||  __/
|       .--.          O   | |_____\__,_|_| |_|\__,_|_| \_\___/ \__,_|\__\___|
 | .   |    |            |
  \    `.__.'    o   .  /   https://lunaroute.org
   \                   /    version : 0.1.2
    `\  o    ()      /      commit  : 15b13475ee9bb809d24aeba48bac82199ae298ee
      `--___   ___--'
            ---

2025-10-22T13:00:22.648058Z  INFO lunaroute_server: 🚀 Initializing LunaRoute Gateway with Intelligent Routing
2025-10-22T13:00:22.648190Z  INFO lunaroute_server: 📋 Request/response logging enabled (stdout)
2025-10-22T13:00:22.648193Z  INFO lunaroute_server: ✓ Anthropic provider enabled
2025-10-22T13:00:22.793580Z  INFO lunaroute_server:   Request/response logging: enabled
2025-10-22T13:00:22.793890Z  INFO lunaroute_server: 📋 Created 2 routing rules
2025-10-22T13:00:22.793894Z  INFO lunaroute_server:    - Some("claude-to-anthropic"): ModelPattern { pattern: "^claude-.*", compiled: OnceCell(Uninit) } → Some("anthropic") (fallbacks: [])
2025-10-22T13:00:22.793899Z  INFO lunaroute_server:    - Some("default-route"): Always → Some("anthropic") (fallbacks: [])
2025-10-22T13:00:22.794112Z  INFO lunaroute_server: 📊 Initializing observability (metrics, health endpoints)
2025-10-22T13:00:22.795459Z  INFO lunaroute_server: 📊 Session statistics tracking enabled (max 100 sessions)
2025-10-22T13:00:22.795466Z  INFO lunaroute_server: 📡 API dialect: Anthropic (/v1/messages)
2025-10-22T13:00:22.795468Z  INFO lunaroute_server: ⚡ Passthrough mode: Anthropic→Anthropic (no normalization)
2025-10-22T13:00:22.798268Z  INFO lunaroute_server:
2025-10-22T13:00:22.798273Z  INFO lunaroute_server: ✅ LunaRoute gateway listening on http://127.0.0.1:9001
2025-10-22T13:00:22.798276Z  INFO lunaroute_server:    API endpoints:
2025-10-22T13:00:22.798278Z  INFO lunaroute_server:    - Anthropic API: http://127.0.0.1:9001/v1/messages
2025-10-22T13:00:22.798279Z  INFO lunaroute_server:    💡 For Claude Code: export ANTHROPIC_BASE_URL=http://127.0.0.1:9001
2025-10-22T13:00:22.798281Z  INFO lunaroute_server:    Observability:
2025-10-22T13:00:22.798282Z  INFO lunaroute_server:    - Health check:       http://127.0.0.1:9001/healthz
2025-10-22T13:00:22.798284Z  INFO lunaroute_server:    - Readiness check:    http://127.0.0.1:9001/readyz
2025-10-22T13:00:22.798286Z  INFO lunaroute_server:    - Prometheus metrics: http://127.0.0.1:9001/metrics
2025-10-22T13:00:22.798287Z  INFO lunaroute_server:
2025-10-22T13:00:22.800059Z  INFO lunaroute_ui::server: 📊 LunaRoute UI server starting on http://127.0.0.1:8082
2025-10-22T13:00:22.800067Z  INFO lunaroute_ui::server:    Dashboard:  http://127.0.0.1:8082/
2025-10-22T13:00:22.800068Z  INFO lunaroute_ui::server:    Sessions:   http://127.0.0.1:8082/sessions
2025-10-22T13:00:22.800070Z  INFO lunaroute_ui::server:    Analytics:  http://127.0.0.1:8082/analytics

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions