langchain - 💡(How to fix) Fix ProviderStrategy does not allow passing strict into the mistral ai JSON Schema response_format

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…
  • I'm trying to use the langchain-mistralai library to implement structured output using a Pydantic schema with a Mistral AI model (specifically mistral-medium-3-5).
  • I expect to see the model return a JSON response that adheres to my defined Pydantic schema, as the library should handle the parameter translation between LangChain's core logic and Mistral's API requirements.
  • Instead, it does throw a 422 Unprocessable Entity error from the Mistral API. The error message indicates that an extra parameter "strict": true is being passed in the request body, which Mistral's API does not permit ("type": "extra_forbidden", "loc": ["body", "strict"]). It seems the strict parameter, common in OpenAI's structured outputs, is being incorrectly propagated to the Mistral API call.

Error Message

Error Message and Stack Trace (if applicable)

Error response 422 while fetching https://api.mistral.ai/v1/chat/completions: {"object":"error","message":{"detail":[{"type":"extra_forbidden","loc":["body","strict"],"msg":"Extra inputs are not permitted","input":true}]},"type":"invalid_request_error","param":null,"code":null,"raw_status_code":422}

  • Instead, it does throw a 422 Unprocessable Entity error from the Mistral API. The error message indicates that an extra parameter "strict": true is being passed in the request body, which Mistral's API does not permit ("type": "extra_forbidden", "loc": ["body", "strict"]). It seems the strict parameter, common in OpenAI's structured outputs, is being incorrectly propagated to the Mistral API call.

Root Cause

  • I'm trying to use the langchain-mistralai library to implement structured output using a Pydantic schema with a Mistral AI model (specifically mistral-medium-3-5).
  • I expect to see the model return a JSON response that adheres to my defined Pydantic schema, as the library should handle the parameter translation between LangChain's core logic and Mistral's API requirements.
  • Instead, it does throw a 422 Unprocessable Entity error from the Mistral API. The error message indicates that an extra parameter "strict": true is being passed in the request body, which Mistral's API does not permit ("type": "extra_forbidden", "loc": ["body", "strict"]). It seems the strict parameter, common in OpenAI's structured outputs, is being incorrectly propagated to the Mistral API call.

Fix Action

Fix / Workaround

  • 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.

Code Example

from dotenv import load_dotenv

from pydantic import BaseModel, Field
from typing import Literal
from langchain.agents import create_agent
from langchain.agents.structured_output import ProviderStrategy


load_dotenv()


class MeetingAction(BaseModel):
    """Action items extracted from a meeting transcript."""
    task: str = Field(description="The specific task to be completed")
    assignee: str = Field(description="Person responsible for the task")
    priority: Literal["low", "medium", "high"] = Field(description="Priority level")


agent = create_agent("mistral-medium-3-5",response_format=ProviderStrategy(MeetingAction))

res = agent.invoke({
    "messages": [{"role": "user", "content": "From our meeting: Sarah needs to update the project timeline as soon as possible"}]
})


print(res['structured_response'])

---

Error response 422 while fetching https://api.mistral.ai/v1/chat/completions: {"object":"error","message":{"detail":[{"type":"extra_forbidden","loc":["body","strict"],"msg":"Extra inputs are not permitted","input":true}]},"type":"invalid_request_error","param":null,"code":null,"raw_status_code":422}
RAW_BUFFERClick to expand / collapse

Submission checklist

  • 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-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-openrouter
  • langchain-perplexity
  • langchain-qdrant
  • langchain-xai
  • Other / not sure / general

Related Issues / PRs

No response

Reproduction Steps / Example Code (Python)

from dotenv import load_dotenv

from pydantic import BaseModel, Field
from typing import Literal
from langchain.agents import create_agent
from langchain.agents.structured_output import ProviderStrategy


load_dotenv()


class MeetingAction(BaseModel):
    """Action items extracted from a meeting transcript."""
    task: str = Field(description="The specific task to be completed")
    assignee: str = Field(description="Person responsible for the task")
    priority: Literal["low", "medium", "high"] = Field(description="Priority level")


agent = create_agent("mistral-medium-3-5",response_format=ProviderStrategy(MeetingAction))

res = agent.invoke({
    "messages": [{"role": "user", "content": "From our meeting: Sarah needs to update the project timeline as soon as possible"}]
})


print(res['structured_response'])

Error Message and Stack Trace (if applicable)

Error response 422 while fetching https://api.mistral.ai/v1/chat/completions: {"object":"error","message":{"detail":[{"type":"extra_forbidden","loc":["body","strict"],"msg":"Extra inputs are not permitted","input":true}]},"type":"invalid_request_error","param":null,"code":null,"raw_status_code":422}

Description

  • I'm trying to use the langchain-mistralai library to implement structured output using a Pydantic schema with a Mistral AI model (specifically mistral-medium-3-5).
  • I expect to see the model return a JSON response that adheres to my defined Pydantic schema, as the library should handle the parameter translation between LangChain's core logic and Mistral's API requirements.
  • Instead, it does throw a 422 Unprocessable Entity error from the Mistral API. The error message indicates that an extra parameter "strict": true is being passed in the request body, which Mistral's API does not permit ("type": "extra_forbidden", "loc": ["body", "strict"]). It seems the strict parameter, common in OpenAI's structured outputs, is being incorrectly propagated to the Mistral API call.

System Info

System Information

OS: Windows OS Version: 10.0.26200 Python Version: 3.13.7 (tags/v3.13.7:bcee1c3, Aug 14 2025, 14:15:11) [MSC v.1944 64 bit (AMD64)]

Package Information

langchain_core: 1.3.3 langchain: 1.2.18 langchain_community: 0.4.1 langsmith: 0.7.33 langchain_anthropic: 1.4.3 langchain_classic: 1.0.4 langchain_cohere: 0.5.1 langchain_deepseek: 1.0.1 langchain_docling: 2.0.0 langchain_huggingface: 1.2.2 langchain_mistralai: 1.1.2 langchain_nvidia_ai_endpoints: 1.2.1 langchain_openai: 1.2.0 langchain_protocol: 0.0.15 langchain_text_splitters: 1.1.2 langchain_unstructured: 1.0.1 langgraph_sdk: 0.3.13

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