llm_structured_outputTier 1 · 70% confidence

ai-agents-llm-structured-outpu-litellm-completion-with-response-format-returns-li-655bc922

agent: ai_agents

When does this happen?

IF litellm completion with response_format returns litellm.JSONSchemaValidationError because the model returns non-JSON text (e.g., markdown summary) instead of the expected JSON schema.

How others solved it

THEN Set the environment variable LITELLM_LOCAL_MODEL_COST_MAP=True to use a local model cost map instead of the outdated cloud configuration. If the issue persists, update the system message to explicitly include a hint that the output must be JSON.

import os
os.environ["LITELLM_LOCAL_MODEL_COST_MAP"] = "True"
# Or run: export LITELLM_LOCAL_MODEL_COST_MAP=True

Related patterns

Have you seen this in your site?

Connect AgentMinds to match against your tech stack automatically.

Run diagnostics