Skip to content

feat(infra): LiteLLM unified gateway for multi-provider LLM routing#20

Closed
moralespanitz wants to merge 1 commit intofeat/first-mention-tll-on-mainfrom
feat/litellm-unified-gateway
Closed

feat(infra): LiteLLM unified gateway for multi-provider LLM routing#20
moralespanitz wants to merge 1 commit intofeat/first-mention-tll-on-mainfrom
feat/litellm-unified-gateway

Conversation

@moralespanitz
Copy link
Copy Markdown
Contributor

Summary

Adds a self-contained LiteLLM proxy under docker/litellm/ so the AtomicMemory stack can route to Anthropic, OpenAI, Foundry/Azure, Bedrock, or Gemini via a single OpenAI-compatible HTTP endpoint at localhost:4000.

The integration is config-only on the AtomicMemory side — core's existing LLM_PROVIDER=openai-compatible lane already supports OPENAI_BASE_URL overrides. No code changes required in src/services/llm.ts.

What's added

  • docker/litellm/litellm-config.yaml — provider routes for 5 providers (Anthropic, OpenAI, Foundry, Bedrock, Gemini), env-var-driven keys, model aliases like anthropic/claude-haiku-4-5, azure/gpt-5-chat, gemini/gemini-1.5-pro.
  • docker/litellm/docker-compose.litellm.yml — runs ghcr.io/berriai/litellm:main-stable mounted with the config; exposes port 4000.
  • docker/litellm/.env.example — template for the four credential env vars (ANTHROPIC, OPENAI, GEMINI, AZURE — Bedrock placeholder).
  • docker/litellm/README.md — quick-start: env vars, docker compose up, smoke test.

Behavior changes for callers

None — purely additive infrastructure. The dev server's existing direct-Anthropic path keeps working. To opt into LiteLLM routing:

LLM_PROVIDER=openai-compatible
OPENAI_BASE_URL=http://localhost:4000/v1
OPENAI_API_KEY=<litellm-master-key>
LLM_MODEL=anthropic/claude-haiku-4-5  # or any other provider/model from the config

Test plan

  • docker compose -f docker/litellm/docker-compose.litellm.yml up -d
  • curl http://localhost:4000/health/liveness returns 200
  • Smoke test all 4 providers via bash atomicmemory-research/memory-research/litellm-setup/smoke-test.sh
  • Run an existing AM smoke ingest with LITELLM proxy as the LLM endpoint, verify no regression

Adds an opt-in LiteLLM proxy sidecar under docker/litellm/ so AtomicMemory
can route LLM calls to Anthropic, OpenAI, Microsoft Foundry / Azure, AWS
Bedrock, or Google Gemini through a single OpenAI-compatible endpoint.
Provider swap is config-only — no new code path in src/services/llm.ts.

Why
- Today llm.ts already supports `LLM_PROVIDER=openai-compatible` with
  `LLM_API_URL` + `LLM_API_KEY`. Pointing that lane at a LiteLLM proxy
  reuses the existing seam and keeps cost-telemetry, AUDN-timeout, and
  retry behavior unchanged.
- A single config.yaml replaces per-provider client wiring across the
  research harness and any future deployment, so we add a provider by
  appending one model_list entry instead of touching TypeScript.

What ships
- docker/litellm/litellm-config.yaml — model_list entries for Anthropic
  (Haiku 4.5, Sonnet 4.6), OpenAI (gpt-5-chat, gpt-4o-mini), Foundry
  (gpt-5-chat via azure/), Bedrock (Claude Sonnet), Gemini (1.5-pro).
  Provider keys resolved via os.environ/VAR_NAME at request time.
- docker/litellm/docker-compose.litellm.yml — pinned compose service on
  port 4000 with explicit `name: atomicmemory-litellm` so the project
  never collides with another `litellm/`-named compose stack.
- docker/litellm/README.md — quick start, env-var table per provider,
  cost-telemetry caveats.
- docker/litellm/.env.example — credential template.

No src/ changes; the existing openai-compatible lane already accepts
LLM_API_URL + LLM_API_KEY (config.ts → llm.ts → OpenAICompatibleLLM).

Smoke
- Anthropic Haiku 4.5 via the proxy: 200 OK, 1.95s, 23 in / 14 out
  tokens, ~$0.00009. Output coherent.
- Foundry / Bedrock / Gemini / OpenAI: model aliases load cleanly at
  proxy startup (`Set models:` lists all 7); no live calls without
  credentials.
@moralespanitz
Copy link
Copy Markdown
Contributor Author

Closing as duplicate of #19 (created by the implementing subagent first, has the canonical description). Both target the same branch feat/litellm-unified-gateway. Continuing review on #19.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant