Skip to content

mistral alias to mistralai not computing the proper model name #34007

@eric-burel

Description

@eric-burel

Checked other resources

  • This is a bug, not a usage question.
  • I added a clear and descriptive title that summarizes this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • This is not related to the langchain-community package.
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Package (Required)

  • langchain
  • langchain-openai
  • langchain-anthropic
  • langchain-classic
  • langchain-core
  • langchain-cli
  • langchain-model-profiles
  • langchain-tests
  • langchain-text-splitters
  • langchain-chroma
  • langchain-deepseek
  • langchain-exa
  • langchain-fireworks
  • langchain-groq
  • langchain-huggingface
  • langchain-mistralai
  • langchain-nomic
  • langchain-ollama
  • langchain-perplexity
  • langchain-prompty
  • langchain-qdrant
  • langchain-xai
  • Other / not sure / general

Example Code (Python)

from langchain.agents import create_agent

agent = create_agent(
    model="mistral:ministral-8b-latest",
    system_prompt="Say hello")


for chunk in agent.stream({"messages": "Hello"}):
    print(chunk)

Error Message and Stack Trace (if applicable)

File "/home/eric-burel/code/lbke-ai-tools/.venv/lib/python3.13/site-packages/langchain_mistralai/chat_models.py", line 172, in _raise_on_error
    raise httpx.HTTPStatusError(
    ...<3 lines>...
    )
httpx.HTTPStatusError: Error response 400 while fetching https://api.mistral.ai/v1/chat/completions: {"object":"error","message":"Invalid model: mistral:ministral-8b-latest","type":"invalid_model","param":null,"code":"1500"}

Description

  • Provider name "mistral" is recognized as Mistral provider (this can be verified by not installing the proper package, LangChain will detect it and propose to installa langchain_mistralai)
  • But it's not properly removed from the model name which ends up being "mistral:mistral-small-latest" for instance instead of just "mistral-small-latest"
  • I suspect this will happen with all aliased package, listed in "/home/eric-burel/code/github-various/langchain/libs/langchain_v1/langchain/chat_models/base.py"

I guess aliases should be applied earlier in the process as soon as create_agent is called so the aliased provider name doesn't leak in other parts of langchain.

System Info

openai: 2.8.1
orjson: 3.11.4
packaging: 25.0
pydantic: 2.12.4
pyyaml: 6.0.3
requests: 2.32.5
requests-toolbelt: 1.0.0
tenacity: 9.1.2
tiktoken: 0.12.0
tokenizers: 0.22.1
typing-extensions: 4.15.0
zstandard: 0.25.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugRelated to a bug, vulnerability, unexpected error with an existing featurelangchainRelated to the package `langchain`mistralai

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions