litellm - 💡(How to fix) Fix Feature Request: support per-model SOCKS5 / outbound proxy settings in LiteLLM Proxy [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
BerriAI/litellm#25563Fetched 2026-04-12 13:24:50
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
labeled ×1

Error Message

  • validation error if the proxy scheme is unsupported

Root Cause

This would make LiteLLM Proxy much easier to use in real-world environments where outbound routing differs by model/provider:

  • geo/network routing by provider
  • regulated environments
  • proxy segmentation between tenants/providers
  • local lab / bastion / tunnel setups
  • migration scenarios where only some providers are reachable through a proxy

Fix Action

Fix / Workaround

Right now the practical workaround seems to be running multiple LiteLLM Proxy instances and splitting traffic externally, which adds operational complexity.

Workaround today

The current workaround is to run multiple LiteLLM proxy instances, each with different env proxy settings, and route models across instances manually. It works, but it is much more operationally expensive than a native per-model setting.

Code Example

model_list:
  - model_name: openai-via-socks5
    litellm_params:
      model: openai/gpt-4o
      api_key: os.environ/OPENAI_API_KEY
      outbound_proxy: socks5://127.0.0.1:1080

  - model_name: anthropic-direct
    litellm_params:
      model: anthropic/claude-sonnet-4-20250514
      api_key: os.environ/ANTHROPIC_API_KEY
      outbound_proxy: null

  - model_name: azure-via-http-proxy
    litellm_params:
      model: azure/gpt-4o
      api_base: os.environ/AZURE_API_BASE
      api_key: os.environ/AZURE_API_KEY
      outbound_proxy: http://proxy.internal:8080
RAW_BUFFERClick to expand / collapse

What problem is this solving?

Today LiteLLM Proxy appears to support outbound proxying mainly via process-level / environment-level proxy settings such as:

  • HTTP_PROXY
  • HTTPS_PROXY
  • ALL_PROXY
  • AIOHTTP_TRUST_ENV

That works for a single global egress path, but it does not solve a common deployment need:

Different upstream models/providers need to use different outbound proxies.

Examples:

  • some model deployments must go through a SOCKS5 proxy
  • some should use direct outbound traffic
  • some should use a different HTTP/SOCKS proxy depending on provider, region, compliance, or network topology

Right now the practical workaround seems to be running multiple LiteLLM Proxy instances and splitting traffic externally, which adds operational complexity.


Requested feature

Please support per-model outbound proxy configuration in config.yaml for LiteLLM Proxy.

For example, something like this:

model_list:
  - model_name: openai-via-socks5
    litellm_params:
      model: openai/gpt-4o
      api_key: os.environ/OPENAI_API_KEY
      outbound_proxy: socks5://127.0.0.1:1080

  - model_name: anthropic-direct
    litellm_params:
      model: anthropic/claude-sonnet-4-20250514
      api_key: os.environ/ANTHROPIC_API_KEY
      outbound_proxy: null

  - model_name: azure-via-http-proxy
    litellm_params:
      model: azure/gpt-4o
      api_base: os.environ/AZURE_API_BASE
      api_key: os.environ/AZURE_API_KEY
      outbound_proxy: http://proxy.internal:8080

Even if the final config name is different (proxy, transport_proxy, network_proxy, etc.), the key need is:

  • configurable per deployment / per model entry
  • support for SOCKS5 and regular HTTP(S) proxies
  • ability to explicitly override global env-based proxy behavior

Why this matters

This would make LiteLLM Proxy much easier to use in real-world environments where outbound routing differs by model/provider:

  • geo/network routing by provider
  • regulated environments
  • proxy segmentation between tenants/providers
  • local lab / bastion / tunnel setups
  • migration scenarios where only some providers are reachable through a proxy

Expected behavior

Ideal behavior

  1. If a per-model outbound proxy is set, requests for that model use it.
  2. If a per-model outbound proxy is explicitly null / disabled, the request bypasses proxy env vars where possible.
  3. If not set, current global env-based behavior remains unchanged.

Nice to have

  • support in both sync + async paths
  • works whether LiteLLM is using aiohttp transport or httpx
  • docs include examples for SOCKS5
  • validation error if the proxy scheme is unsupported

Workaround today

The current workaround is to run multiple LiteLLM proxy instances, each with different env proxy settings, and route models across instances manually. It works, but it is much more operationally expensive than a native per-model setting.


If helpful

I’d be happy with even a first version that:

  • supports per-model proxy config for the proxy server path only
  • supports SOCKS5 via ALL_PROXY-equivalent client configuration internally
  • leaves advanced routing/policy to future iterations

Thanks — this would remove a lot of deployment pain.

extent analysis

TL;DR

To address the need for per-model outbound proxy configuration in LiteLLM Proxy, consider implementing a feature that allows specifying an outbound_proxy setting in the config.yaml file for each model.

Guidance

  • Review the proposed config.yaml example to understand the desired per-model outbound proxy configuration format.
  • Assess the feasibility of supporting both SOCKS5 and HTTP(S) proxies as part of the outbound_proxy setting.
  • Evaluate the need for explicit override of global env-based proxy behavior on a per-model basis.
  • Consider the operational complexity reduction that a native per-model setting would bring compared to the current workaround of running multiple LiteLLM proxy instances.

Example

A potential implementation could involve adding an outbound_proxy field to the litellm_params section of each model's configuration in config.yaml, as shown in the issue's example:

model_list:
  - model_name: openai-via-socks5
    litellm_params:
      model: openai/gpt-4o
      api_key: os.environ/OPENAI_API_KEY
      outbound_proxy: socks5://127.0.0.1:1080

Notes

The implementation should ensure that the per-model outbound proxy setting takes precedence over global environment-based proxy settings when configured. Additionally, consider including validation for unsupported proxy schemes to prevent configuration errors.

Recommendation

Apply a workaround by running multiple LiteLLM proxy instances with different environment proxy settings until a native per-model outbound proxy configuration feature is implemented, as this allows for immediate mitigation of the operational complexity issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING