Skip to content

feat: add configurable base URL for LiteLLM proxy support#72

Open
RheagalFire wants to merge 1 commit into
dabit3:mainfrom
RheagalFire:feat/add-litellm-provider
Open

feat: add configurable base URL for LiteLLM proxy support#72
RheagalFire wants to merge 1 commit into
dabit3:mainfrom
RheagalFire:feat/add-litellm-provider

Conversation

@RheagalFire

@RheagalFire RheagalFire commented May 25, 2026

Copy link
Copy Markdown

Summary

  • Makes the OpenAI base URL configurable via OPENAI_BASE_URL env var, enabling routing through LiteLLM or any OpenAI-compatible proxy.
  • Also allows passing any model ID directly (not just the hardcoded gpt52/gpt5Mini keys), so users can use LiteLLM model IDs like anthropic/claude-3-5-sonnet.

Motivation

Currently gpt.ts hardcodes https://api.openai.com/v1/chat/completions. Users who want to use other providers (Anthropic, Azure, Bedrock, Groq, local Ollama, etc.) can't without modifying source code. By making the base URL configurable, users can point at a LiteLLM proxy that routes to 100+ providers through a single endpoint.

Changes

  • server/src/chat/gpt.ts - extracted baseUrl from OPENAI_BASE_URL env var (defaults to https://api.openai.com/v1), use baseUrl in fetch URL instead of hardcoded string. Also falls back to raw model value if not found in the models map, so arbitrary model IDs work.

Tests

Live E2E - streaming via LiteLLM proxy routing to Claude Sonnet 4.6:

$ curl http://localhost:4000/v1/chat/completions -d '{"model":"anthropic/claude-sonnet-4-6","messages":[...],"stream":true}'

data: {"model":"claude-sonnet-4-6","choices":[{"delta":{"content":"OK","role":"assistant"}}]}
data: {"model":"claude-sonnet-4-6","choices":[{"finish_reason":"stop","delta":{}}]}

Streaming SSE chunks parse correctly through the same code path in gpt.ts.

Risk / Compatibility

  • Fully backward-compatible. Without OPENAI_BASE_URL set, defaults to https://api.openai.com/v1 (existing behavior).
  • 1 file changed, 6 lines modified.
  • No new dependencies.

Example usage

# Default behavior (unchanged):
OPENAI_API_KEY=sk-... npm start

# Route through LiteLLM proxy:
OPENAI_BASE_URL=http://localhost:4000/v1 OPENAI_API_KEY=sk-litellm-key npm start

# Use any LiteLLM model by passing model ID directly:
# In the app, send model: "anthropic/claude-3-5-sonnet" instead of "gpt52"

Start a LiteLLM proxy:

pip install litellm
litellm --model anthropic/claude-3-5-sonnet --port 4000

Devin Review

Status Commit
⚪ Not started

Run Devin Review

💡 Connect your GitHub account to enable automatic code reviews.

Open in Devin Review (Staging)
Open in Devin Review

@RheagalFire

Copy link
Copy Markdown
Author

cc @dabit3

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 2 additional findings.

Open in Devin Review

@RheagalFire

Copy link
Copy Markdown
Author

@dabit3 do you have any update on this PR?

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