Skip to content

fix(decisions): support the litellm_proxy provider - #51611

Merged
kenneth-berri merged 5 commits into
BerriAI:mainfrom
bofenghuang:litellm_decisions_litellm_proxy
Nov 19, 2026
Merged

kenneth-berri merged 5 commits into
BerriAI:mainfrom
bofenghuang:litellm_decisions_litellm_proxy

Conversation

@bofenghuang

@bofenghuang bofenghuang commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

Decision calls failed whenever an SDK app sent its traffic through a LiteLLM proxy, with the global proxy setting or a proxy model name, while chat and responses calls worked the same way. This adds the proxy as a decisions provider, so those calls now reach the proxy's decisions endpoint with the proxy's own URL and key.

Details

Link to Devin session: https://app.devin.ai/sessions/cbf54201bf3f4a4bade38409b9bd020d
Open in Devin Desktop: https://app.devin.ai/desktop/session/cbf54201bf3f4a4bade38409b9bd020d?variant=devin
Requested by: @kenneth-berri

TLDR

Problem this solves:

  • Decision calls fail when litellm.use_litellm_proxy is on
  • Decision calls to a litellm_proxy/... model fail the same way
  • Chat, responses and images already work through the proxy

How it solves it:

  • Adds a decisions config for the litellm_proxy provider
  • It sends the OpenAI decisions request to the proxy's /v1/decisions
  • It uses the proxy's base URL and key, never OpenAI's
  • It forwards box questions, audio and videos for the proxy to accept or refuse, since only the proxy knows the model behind a name
  • A proxy that needs no key can be called without one

User Flow

Before: an SDK app that sends all its calls through a LiteLLM proxy cannot make decision calls

  1. The app sets litellm.use_litellm_proxy = True, LITELLM_PROXY_API_BASE and LITELLM_PROXY_API_KEY
  2. litellm.acompletion(model="openai/gpt-6-luna", ...) reaches the proxy and answers
  3. litellm.adecisions(model="openai/gpt-6-luna", ...) raises BadRequestError: Unknown Decisions provider 'litellm_proxy' before sending anything, and the same happens with model="litellm_proxy/openai/gpt-6-luna" and the flag off

After: the same decision call goes through the proxy

  1. The app sets litellm.use_litellm_proxy = True, LITELLM_PROXY_API_BASE and LITELLM_PROXY_API_KEY
  2. litellm.acompletion(model="openai/gpt-6-luna", ...) reaches the proxy and answers
  3. litellm.adecisions(model="openai/gpt-6-luna", ...) sends POST <LITELLM_PROXY_API_BASE>/v1/decisions with "model": "openai/gpt-6-luna" and the proxy key, and returns the proxy's answers, and model="litellm_proxy/openai/gpt-6-luna" with the flag off does the same

Linear ticket

Resolves LIT-10917

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

The fix is in the SDK, so the proxies stay the same throughout and only the client's litellm checkout changes between Before and After. Both proxies run current main with one worker and no Redis, since nothing here touches proxy state. The upstream is the real OpenAI openai/gpt-6-luna decisions model.

Shared setup, with env var names only

  1. Start the keyed proxy with LITELLM_MASTER_KEY=... OPENAI_API_KEY=... python litellm/proxy/proxy_cli.py --config config.yaml --port 4011
  2. Start the keyless proxy with LITELLM_DANGEROUSLY_PERMIT_WEAK_OR_UNSET_MASTER_KEY=true OPENAI_API_KEY=... python litellm/proxy/proxy_cli.py --config config_keyless.yaml --port 4012
  3. Point the client at a proxy with LITELLM_PROXY_API_BASE=http://127.0.0.1:<port> and, for the keyed proxy, LITELLM_PROXY_API_KEY set to the master key
  4. Run PYTHONPATH=<checkout> python client.py <case> for each case below
config.yaml, config_keyless.yaml, client.py
model_list:
  - model_name: openai/gpt-6-luna
    litellm_params:
      model: openai/gpt-6-luna
      api_key: os.environ/OPENAI_API_KEY
general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
model_list:
  - model_name: openai/gpt-6-luna
    litellm_params:
      model: openai/gpt-6-luna
      api_key: os.environ/OPENAI_API_KEY
"""The SDK user's flow: every decision call goes to a LiteLLM proxy. Run as `python client.py <case>`."""
import asyncio
import os
import sys

import litellm

M = "openai/gpt-6-luna"
INP = "The package arrived broken."
Q = [{"type": "predicate", "name": "is_defect", "instructions": "Is this a defect?"}]
BOX = [{"type": "box", "name": "crack", "instructions": "the crack on the screen"}]


async def call(case: str):
    if case == "prefix":
        return await litellm.adecisions(model=f"litellm_proxy/{M}", input=INP, questions=Q)
    if case == "prefix-sync":
        return await asyncio.to_thread(litellm.decisions, model=f"litellm_proxy/{M}", input=INP, questions=Q)
    if case == "flag":
        litellm.use_litellm_proxy = True
        return await litellm.adecisions(model=M, input=INP, questions=Q)
    if case == "per-call":
        return await litellm.adecisions(model=M, input=INP, questions=Q, use_litellm_proxy=True)
    if case == "router":
        router = litellm.Router(
            model_list=[{"model_name": "d", "litellm_params": {"model": M, "use_litellm_proxy": True}}]
        )
        return await router.adecisions(model="d", input=INP, questions=Q)
    if case == "wrong-key":
        return await litellm.adecisions(model=f"litellm_proxy/{M}", input=INP, questions=Q, api_key="sk-wrong")
    if case == "unknown-model":
        return await litellm.adecisions(model="litellm_proxy/nope", input=INP, questions=Q)
    if case == "no-key":
        del os.environ["LITELLM_PROXY_API_KEY"]
        return await litellm.adecisions(model=f"litellm_proxy/{M}", input=INP, questions=Q)
    if case == "box":
        return await litellm.adecisions(model=f"litellm_proxy/{M}", input=INP, questions=BOX)
    if case == "audio":
        return await litellm.adecisions(
            model=f"litellm_proxy/{M}", input=INP, questions=Q, audio=["data:audio/wav;base64,UklGRg=="]
        )
    raise SystemExit(f"unknown case {case}")


async def main(case: str) -> None:
    try:
        response = await call(case)
        print(f"{case}: OK model={response.model} answers={response.answers}")
    except Exception as error:
        print(f"{case}: {type(error).__name__}: {str(error)[:230]}")


asyncio.run(main(sys.argv[1]))

Before (f041b70, the merge base with main)

prefix: BadRequestError: litellm.BadRequestError: Unknown Decisions provider 'litellm_proxy'. Supported providers: openai, openrouter, gemini, ...
prefix-sync: BadRequestError: litellm.BadRequestError: Unknown Decisions provider 'litellm_proxy'. Supported providers: openai, openrouter, gemini, ...
flag: BadRequestError: litellm.BadRequestError: Unknown Decisions provider 'litellm_proxy'. Supported providers: openai, openrouter, gemini, ...
per-call: OK model=gpt-6-luna answers=(OpenAIPredicateAnswer(type='predicate', name='is_defect', probability=0.97),)
router: OK model=gpt-6-luna answers=(OpenAIPredicateAnswer(type='predicate', name='is_defect', probability=0.97),)
wrong-key: BadRequestError: litellm.BadRequestError: Unknown Decisions provider 'litellm_proxy'. Supported providers: openai, openrouter, gemini, ...
unknown-model: BadRequestError: litellm.BadRequestError: Unknown Decisions provider 'litellm_proxy'. Supported providers: openai, openrouter, gemini, ...
box: BadRequestError: litellm.BadRequestError: Unknown Decisions provider 'litellm_proxy'. Supported providers: openai, openrouter, gemini, ...
audio: BadRequestError: litellm.BadRequestError: Unknown Decisions provider 'litellm_proxy'. Supported providers: openai, openrouter, gemini, ...
no-key (keyless proxy): BadRequestError: litellm.BadRequestError: Unknown Decisions provider 'litellm_proxy'. Supported providers: openai, openrouter, gemini, ...

Neither proxy logged a POST /v1/decisions. The per-call and router cases answered because the use_litellm_proxy flag was ignored and the SDK called OpenAI directly with the local OPENAI_API_KEY, skipping the proxy.

After (abcbd7a, the latest product commit)

prefix: OK model=gpt-6-luna answers=(OpenAIPredicateAnswer(type='predicate', name='is_defect', probability=0.97),)
prefix-sync: OK model=gpt-6-luna answers=(OpenAIPredicateAnswer(type='predicate', name='is_defect', probability=0.97),)
flag: OK model=gpt-6-luna answers=(OpenAIPredicateAnswer(type='predicate', name='is_defect', probability=0.97),)
per-call: OK model=gpt-6-luna answers=(OpenAIPredicateAnswer(type='predicate', name='is_defect', probability=0.97),)
router: OK model=gpt-6-luna answers=(OpenAIPredicateAnswer(type='predicate', name='is_defect', probability=0.97),)
wrong-key: AuthenticationError: litellm.AuthenticationError: AuthenticationError: Litellm_proxyException - {"error":{"message":"Authentication Error, Invalid API key provided.","type":"token_not_found_in_db","param":"key","code":"401"}}
unknown-model: BadRequestError: litellm.BadRequestError: Litellm_proxyException - {"error":{"message":"/decisions: Invalid model name passed in model=nope. Call `/v1/models` to view available models for your key.","type":"invalid_request_error", ...
box: UnsupportedParamsError: litellm.UnsupportedParamsError: {"error":{"message":"litellm.UnsupportedParamsError: openai does not support parameters: ['box questions'], for model=openai/gpt-6-luna. ...
audio: UnsupportedParamsError: litellm.UnsupportedParamsError: {"error":{"message":"litellm.UnsupportedParamsError: openai does not support parameters: ['audio'], for model=openai/gpt-6-luna. ...
no-key (keyless proxy): OK model=gpt-6-luna answers=(OpenAIPredicateAnswer(type='predicate', name='is_defect', probability=0.97),)

The keyed proxy logged nine POST /v1/decisions for these nine calls, five with 200, three with 400 (unknown-model, box, audio) and one with 401 (wrong-key). The keyless proxy logged one with 200. So every call now reaches the proxy, and the box and audio errors are the proxy's own answer for a model that takes neither.

Focused checks at abcbd7a are pytest tests/unit/decisions (553 passed) and make check (PASS).

Type

🐛 Bug Fix

Caveats (if any)

Low

  • The proxy key comes from api_key or LITELLM_PROXY_API_KEY only
    • OPENAI_API_KEY and litellm.api_key are never sent to the proxy, unlike the plain openai decisions config
  • Box questions, audio and videos were only run live against a model that takes none of them
    • The run shows they reach the proxy and the proxy's refusal comes back. No credentials for a box or audio capable decisions model were available, so a successful answer is covered by the unit test only

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

Note

Low Risk
Narrow routing fix for the Decisions API with regression tests; main risk is misrouted requests or credentials, which the new config and tests explicitly guard against.

Overview
Adds LiteLLMProxyDecisionsConfig so adecisions / decisions can reach the proxy’s /v1/decisions endpoint the same way chat and responses already do when use_litellm_proxy is on or the model is prefixed with litellm_proxy/.

prepare_call now passes use_litellm_proxy into get_llm_provider, so per-call and Router deployments route to the proxy instead of OpenAI. The new config uses LITELLM_PROXY_API_BASE and LITELLM_PROXY_API_KEY (optional key), refuses OpenAI credential fallbacks, and forwards box questions, audio, and video unless deployment model_info turns them off—leaving capability checks to the proxy.

Provider registration is wired through lazy imports, ProviderConfigManager, and tests cover routing, missing proxy base, auth headers, media payloads, and Router use_litellm_proxy.

Reviewed by Cursor Bugbot for commit 20f7864. Bugbot is set up for automated code reviews on this repo. Configure here.

Decision calls failed with "Unknown Decisions provider 'litellm_proxy'" when
litellm.use_litellm_proxy was on, or with a litellm_proxy/ model, because the
decisions lookup had no config for that provider. Chat, responses and images
already have one. The new config posts the OpenAI decisions format to the
proxy's /v1/decisions, with LITELLM_PROXY_API_BASE and LITELLM_PROXY_API_KEY
as fallbacks and no fallback to OpenAI's base URL or key.
@CLAassistant

CLAassistant commented Nov 13, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@bofenghuang
bofenghuang marked this pull request as ready for review November 13, 2026 11:33
@veria-ai

veria-ai Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews

Pass the per-call use_litellm_proxy flag into provider resolution so a router deployment flagged for the proxy sends Decisions to the proxy with its own key, and pin that litellm_proxy never falls back to OpenAI's base or key.
@codecov

codecov Bot commented Nov 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@kenneth-berri kenneth-berri self-assigned this Nov 19, 2026
@kenneth-berri

Copy link
Copy Markdown
Collaborator

@greptile

@kenneth-berri

Copy link
Copy Markdown
Collaborator

bugbot run

@greptile-apps

greptile-apps Bot commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] This PR appears safe to merge.

Summary

Decision calls can now use the LiteLLM proxy through a model prefix, a global setting, or a per-call setting.

  • Decision calls can now use the LiteLLM proxy.

No new actionable issues found. The earlier media-forwarding and keyless-call findings are addressed.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[SDK decision call] --> B{Proxy selected?}
  B -->|Yes| C[Proxy URL and optional proxy key]
  C --> D[POST /v1/decisions]
  D --> E[Proxy selects the model]
  B -->|No| F[Existing provider route]
Loading

Reviews (3) · Last reviewed commit: "Merge remote-tracking branch 'origin/mai..." · Reviewed by Greptile

Comment thread litellm/decisions/call.py Resolved

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

Stale Bugbot comment from a previous run.

…and allow a keyless proxy

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@kenneth-berri

Copy link
Copy Markdown
Collaborator

@greptile

@kenneth-berri

Copy link
Copy Markdown
Collaborator

bugbot run

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

Stale Bugbot comment from a previous run.

@kenneth-berri

Copy link
Copy Markdown
Collaborator

@greptile

@kenneth-berri

Copy link
Copy Markdown
Collaborator

bugbot run

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 20f7864. Configure here.

@kenneth-berri
kenneth-berri merged commit c3cd9ad into BerriAI:main Nov 19, 2026
63 checks passed
@bofenghuang
bofenghuang deleted the litellm_decisions_litellm_proxy branch November 19, 2026 21:23
mateo-berri added a commit that referenced this pull request Nov 21, 2026
fix(decisions): support the litellm_proxy provider (#51611, #53195) [lts/1.108.x]
mateo-berri pushed a commit to chaznm/litellm that referenced this pull request Nov 21, 2026
Backport of BerriAI#51611 to lts/1.108.x.
Cherry-picked from 8f651ba (litellm_decisions_litellm_proxy).
Adapted to the line: lts/1.108.x registers lazy imports in its tuple-and-map registry and resolves
decisions configs with per-provider ifs, and the test file gains main's single-answer predicate fixture.
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.

4 participants