Skip to content

feat: add LiteLLM AI gateway provider preset - #385

Merged
lizhengfeng101 merged 1 commit into
alibaba:mainfrom
RheagalFire:feat/add-litellm-provider
Jul 17, 2026
Merged

lizhengfeng101 merged 1 commit into
alibaba:mainfrom
RheagalFire:feat/add-litellm-provider

Conversation

@RheagalFire

@RheagalFire RheagalFire commented Jul 16, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds LiteLLM as a built-in provider preset, giving users access to 100+ LLM providers (Anthropic, OpenAI, Bedrock, Vertex AI, Groq, Mistral, etc.) through a single proxy endpoint.

LiteLLM is a widely-adopted AI gateway (45k+ GitHub stars) that normalizes provider-specific auth and API formats server-side, exposing a standard OpenAI-compatible endpoint.

Changes (2 files, 67 insertions):

  • internal/llm/providers.go - Added litellm provider entry with ProtocolOpenAIChatCompletions, base URL http://localhost:4000/v1, env var LITELLM_API_KEY, and 12 representative models spanning 7 backing providers (Anthropic, OpenAI, Vertex AI, Bedrock, Groq, Mistral, DeepSeek)
  • internal/llm/providers_test.go - Updated TestListProviders_Order sorted list, added TestLookupProvider_LiteLLMDetails with full field and model list verification

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Refactoring (no functional changes)
  • Documentation update
  • CI / Build / Tooling

How Has This Been Tested?

  • make test passes locally
  • Manual testing (describe below)

Unit tests (36 tests, 0 regressions):

=== RUN   TestLookupProvider_LiteLLMDetails
--- PASS: TestLookupProvider_LiteLLMDetails (0.00s)
=== RUN   TestListProviders_Order
--- PASS: TestListProviders_Order (0.00s)
=== RUN   TestProviders_AllProtocolsCanonical
--- PASS: TestProviders_AllProtocolsCanonical (0.00s)
PASS
ok  	github.com/open-code-review/open-code-review/internal/llm	0.569s

Format + vet: make check -> check passed

Live E2E (Azure Foundry Claude Sonnet 4.6 via LiteLLM proxy):

=== RUN   TestLiteLLM_LiveE2E/LookupProvider
Name: litellm, Protocol: openai, BaseURL: http://localhost:4000/v1
--- PASS
=== RUN   TestLiteLLM_LiveE2E/LiveCompletion
Content: "14"
Usage: prompt=20 completion=5 total=25
--- PASS

Checklist

  • My code follows the project's coding style (go fmt, go vet)
  • I have performed a self-review of my code
  • I have added tests that prove my fix is effective or my feature works
  • New and existing unit tests pass locally with my changes
  • I have updated the documentation accordingly (if applicable)
  • I have signed the CLA

Example usage

The model value should match the model name configured on your LiteLLM proxy (see your proxy's config.yaml). The proxy handles routing to the actual backing provider.

# Set provider via CLI
ocr config set provider litellm

# Or via config file
cat > ~/.config/opencodereview/config.json << 'EOF'
{
  "provider": "litellm",
  "providers": {
    "litellm": {
      "api_key": "sk-litellm-key",
      "model": "my-model"
    }
  }
}
EOF

# Or via environment variables
export LITELLM_API_KEY=sk-litellm-key
export OCR_LLM_MODEL=my-model
ocr --staged

@CLAassistant

CLAassistant commented Jul 16, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@github-actions

Copy link
Copy Markdown
Contributor

✅ OpenCodeReview: No comments generated. Looks good to me.

@lizhengfeng101 lizhengfeng101 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.

LGTM

@lizhengfeng101
lizhengfeng101 merged commit d75e215 into alibaba:main Jul 17, 2026
2 checks passed
lizhengfeng101 pushed a commit that referenced this pull request Aug 8, 2026
Add Mistral AI to the provider registry using the existing OpenAI-compatible
chat completions protocol. Mistral's endpoint at https://api.mistral.ai/v1
speaks the same request/response shape, so no client code or new protocol
constant is required — this is a registry-only addition matching the pattern
established by the recently merged Eden AI (#346), Ollama Cloud (#375), and
LiteLLM (#385) provider presets.

Auth via MISTRAL_API_KEY. Curated model list kept deliberately minimal
(codestral-latest, mistral-large-latest, mistral-small-latest); users can
select any other Mistral model via `ocr config set model <name>`.

Tested end-to-end against api.mistral.ai with codestral-latest against a
staged diff — review returned an accurate high-severity SQL injection
finding with a correct parameterized-query fix suggestion.
Githab-capibara added a commit to Githab-capibara/open-code-review that referenced this pull request Sep 17, 2026
Githab-capibara added a commit to Githab-capibara/open-code-review that referenced this pull request Sep 17, 2026
Add Mistral AI to the provider registry using the existing OpenAI-compatible
chat completions protocol. Mistral's endpoint at https://api.mistral.ai/v1
speaks the same request/response shape, so no client code or new protocol
constant is required — this is a registry-only addition matching the pattern
established by the recently merged Eden AI (alibaba#346), Ollama Cloud (alibaba#375), and
LiteLLM (alibaba#385) provider presets.

Auth via MISTRAL_API_KEY. Curated model list kept deliberately minimal
(codestral-latest, mistral-large-latest, mistral-small-latest); users can
select any other Mistral model via `ocr config set model <name>`.

Tested end-to-end against api.mistral.ai with codestral-latest against a
staged diff — review returned an accurate high-severity SQL injection
finding with a correct parameterized-query fix suggestion.
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.

3 participants