litellm - 💡(How to fix) Fix [Bug]: Model alias not working with team/virtual key access (permission denied before alias resolution) [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#25281Fetched 2026-04-08 03:02:13
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Author
Participants
Timeline (top)
labeled ×1

Error Message

"error": {

Root Cause

  • I have searched the existing issues and checked that this is not a duplicate.
  • Related issues: #15228, #21665
  • This appears distinct from #15228 because it is reproducible via direct proxy API calls and points to alias resolution happening after team/virtual-key authorization.

Fix Action

Fix / Workaround

main-v1.82.3-stable.patch.2 (self-hosted Docker Compose deployment)

Code Example

curl -X POST "https://<proxy>/v1/chat/completions" \
  -H "Authorization: Bearer <API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "AgentX-LLM",
    "messages": [
      { "role": "user", "content": "say ping" }
    ]
  }'

---

{
  "error": {
    "message": "team not allowed to access model...",
    "code": "401"
  }
}

Tried to access AgentX-LLM
RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that this is not a duplicate.
  • Related issues: #15228, #21665
  • This appears distinct from #15228 because it is reproducible via direct proxy API calls and points to alias resolution happening after team/virtual-key authorization.

What happened?

When using LiteLLM Proxy with a model alias configured via the UI, the alias cannot be used in API calls if access is restricted by team / virtual key allowed models.

Example setup:

  • Model alias in UI:
    • AgentX-LLM -> openrouter/qwen/qwen3.5-flash-02-23
  • Team / API key has access to:
    • openrouter/qwen/qwen3.5-flash-02-23

Request:

curl -X POST "https://<proxy>/v1/chat/completions" \
  -H "Authorization: Bearer <API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "AgentX-LLM",
    "messages": [
      { "role": "user", "content": "say ping" }
    ]
  }'

Actual behavior:

  • Request returns 401 team_model_access_denied
  • Logs show LiteLLM checked the alias name directly:
    • Tried to access AgentX-LLM

Expected behavior:

  • LiteLLM should resolve the alias first:
    • AgentX-LLM -> openrouter/qwen/qwen3.5-flash-02-23
  • Then apply permission checks against the resolved model
  • Since the resolved model is allowed, the request should succeed

Suspected root cause:

Current auth flow appears to be:

  1. Receive model = AgentX-LLM
  2. Check team / key allowed models
  3. Reject because alias name is not in allowed_models
  4. Alias is never resolved

Expected flow:

  1. Receive model = AgentX-LLM
  2. Resolve alias -> real model
  3. Check permissions on resolved model
  4. Forward request

Steps to Reproduce

  1. Deploy LiteLLM Proxy with team-based access control and virtual keys enabled
  2. Configure a real model such as openrouter/qwen/qwen3.5-flash-02-23
  3. Create a model alias in the UI:
    • AgentX-LLM -> openrouter/qwen/qwen3.5-flash-02-23
  4. Create a team / virtual key whose allowed models include only openrouter/qwen/qwen3.5-flash-02-23
  5. Call /v1/chat/completions with model: "AgentX-LLM"
  6. Observe 401 team_model_access_denied
  7. Check logs and observe Tried to access AgentX-LLM

Relevant log output

{
  "error": {
    "message": "team not allowed to access model...",
    "code": "401"
  }
}

Tried to access AgentX-LLM

What part of LiteLLM is this about?

Proxy

What LiteLLM version are you on ?

main-v1.82.3-stable.patch.2 (self-hosted Docker Compose deployment)

Twitter / LinkedIn details

No response

extent analysis

TL;DR

  • Resolve the model alias to its actual model before performing team and virtual key-based access control checks.

Guidance

  • Verify that the alias resolution is correctly configured and functional by checking the UI settings and logs for any errors related to alias resolution.
  • Modify the authentication flow to resolve the model alias before checking team and virtual key allowed models, ensuring that the resolved model is used for permission checks.
  • Review the logs to confirm that the alias is being resolved correctly and that the permission checks are being applied to the resolved model.
  • Test the API call with the model alias and verify that it succeeds when the resolved model is in the allowed models list.

Example

  • No explicit code changes are implied in the issue, but the authentication flow should be updated to include alias resolution before permission checks, similar to:

Pseudo-code example, actual implementation may vary

def authenticate_model_access(model_alias, team_allowed_models):

Resolve model alias

resolved_model = resolve_alias(model_alias)

Check if resolved model is in allowed models

if resolved_model in team_allowed_models: # Proceed with request return True else: # Return access denied return False


## Notes
- The issue seems specific to the `main-v1.82.3-stable.patch.2` version of LiteLLM, and the fix may involve updating the authentication flow to correctly handle model aliases.
- The provided example and guidance are based on the information given in the issue and may require adjustments based on the actual implementation of LiteLLM.

## Recommendation
- Apply workaround: Modify the authentication flow to resolve model aliases before performing team and virtual key-based access control checks, as this directly addresses the identified issue and should resolve the `401 team_model_access_denied` error.

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