{
  "id": "llm/logprobs-request-fails-on-structured-output",
  "signature": "openai.BadRequestError: logprobs is not supported when using response_format parameter",
  "signature_zh": "openai.BadRequestError: 使用 response_format 参数时不支持 logprobs",
  "regex": "logprobs is not supported when using response_format parameter",
  "domain": "llm",
  "category": "api_error",
  "subcategory": null,
  "root_cause": "OpenAI API does not allow requesting logprobs when structured output (response_format) is enabled, as the constrained decoding mechanism cannot produce token-level probabilities.",
  "root_cause_type": "generic",
  "root_cause_zh": "OpenAI API 不允许在启用结构化输出（response_format）时请求 logprobs，因为约束解码机制无法生成 token 级别的概率。",
  "versions": [
    {
      "version": "openai-python>=1.30.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "gpt-4o-2024-08-06",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "gpt-4o-mini-2024-07-18",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The error occurs when logprobs is present at all, even if set to false; the API still validates the field presence.",
      "fail_rate": 0.7,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "Older API versions may not support structured output at all, or have different bugs; the restriction is intentional and consistent across versions.",
      "fail_rate": 0.9,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "This works functionally but defeats the purpose of using structured output for guaranteed JSON.",
      "fail_rate": 0.5,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Remove logprobs from the request entirely when using response_format. Example: `response = client.chat.completions.create(model=\"gpt-4o\", messages=messages, response_format={ \"type\": \"json_object\" })` without `logprobs`.",
      "success_rate": 0.95,
      "how": "Remove logprobs from the request entirely when using response_format. Example: `response = client.chat.completions.create(model=\"gpt-4o\", messages=messages, response_format={ \"type\": \"json_object\" })` without `logprobs`.",
      "condition": "",
      "sources": []
    },
    {
      "action": "If logprobs are needed, use a separate API call without response_format and parse JSON manually with error handling.",
      "success_rate": 0.8,
      "how": "If logprobs are needed, use a separate API call without response_format and parse JSON manually with error handling.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Switch to a model or provider that supports both features simultaneously (e.g., some open-source models with guided decoding).",
      "success_rate": 0.6,
      "how": "Switch to a model or provider that supports both features simultaneously (e.g., some open-source models with guided decoding).",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "Remove logprobs from the request entirely when using response_format. Example: `response = client.chat.completions.create(model=\"gpt-4o\", messages=messages, response_format={ \"type\": \"json_object\" })` without `logprobs`.",
    "If logprobs are needed, use a separate API call without response_format and parse JSON manually with error handling.",
    "Switch to a model or provider that supports both features simultaneously (e.g., some open-source models with guided decoding)."
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://platform.openai.com/docs/guides/structured-outputs/supported-models",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.88,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2024-10-15",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}