litellm - 💡(How to fix) Fix [Feature]: Add a typed exception for (This model isn't mapped yet) [provider=mistral] [1 pull requests]

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…

Error Message

Currently, when a model (with mistral provider) is requested but not mapped in LiteLLM, the system throws a generic Exception with a message similar to: Using a generic exception type makes it difficult for client code to: Implement targeted error handling or retries class ModelNotMappedError(Exception):

  • Improved error handling: Consumers can catch this specific exception instead of relying on string matching

Fix Action

Fixed

RAW_BUFFERClick to expand / collapse

Check for existing issues

  • I have searched the existing issues and checked that my issue is not a duplicate.

The Feature

Problem Statement

Currently, when a model (with mistral provider) is requested but not mapped in LiteLLM, the system throws a generic Exception with a message similar to:

"This model isn't mapped yet"

Using a generic exception type makes it difficult for client code to:

Reliably detect this specific failure scenario Implement targeted error handling or retries Differentiate it from other runtime or configuration errors

To reproduce

prompt_tokens_cost_usd, completion_tokens_cost_usd = litellm.cost_per_token( "mistral-medium-3.5-128b", 100, 100 custom_llm_provider="mistral" )

By the time this issue is being taken care of it could be that "mistral-medium-3.5-128b" is mapped, so you can put any unsupported model instead.

Possible Enhancements

class ModelNotMappedError(Exception): """Raised when a requested model is not mapped in LiteLLM.""" pass

raise ModelNotMappedError("This model isn't mapped yet. model={}, custom_llm_provider={}. Add it here - https://github.com/BerriAI/litellm/blob/main/model_prices_and_context_window.json.".format( model, custom_llm_provider)

Motivation, pitch

  • Improved error handling: Consumers can catch this specific exception instead of relying on string matching
  • Cleaner integrations: Downstream services can implement fallback logic (e.g., auto-mapping, alternative models)
  • Better observability: Easier to track and categorize configuration issues
  • Consistency: Aligns with best practices of using typed exceptions instead of generic ones

What part of LiteLLM is this about?

SDK (litellm Python package)

LiteLLM is hiring a founding backend engineer, are you interested in joining us and shipping to all our users?

No

Twitter / LinkedIn details

https://www.linkedin.com/in/amir-ben-khadda-4938b3127/?locale=en

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