{
  "id": "llm/invalid-api-key-format",
  "signature": "openai.AuthenticationError: Incorrect API key provided: sk-... You can find your API key at https://platform.openai.com/account/api-keys.",
  "signature_zh": "openai.AuthenticationError: 提供的API密钥格式不正确：sk-... 您可以在https://platform.openai.com/account/api-keys找到您的API密钥。",
  "regex": "openai\\.AuthenticationError: Incorrect API key provided",
  "domain": "llm",
  "category": "auth_error",
  "subcategory": null,
  "root_cause": "The API key string is malformed, expired, or belongs to a different organization/project than the one being used for the request.",
  "root_cause_type": "generic",
  "root_cause_zh": "API密钥字符串格式错误、已过期，或属于与当前请求不同的组织/项目。",
  "versions": [
    {
      "version": "openai>=1.0.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    },
    {
      "version": "openai==0.28.0",
      "introduced": null,
      "deprecated": null,
      "removed": null,
      "behavior_change": null,
      "status": "active"
    }
  ],
  "os_specific": {},
  "dead_ends": [
    {
      "action": "",
      "why_fails": "The root cause is often a copy-paste error or whitespace, not the key itself.",
      "fail_rate": 0.6,
      "condition": "",
      "sources": []
    },
    {
      "action": "",
      "why_fails": "The key may be revoked by the provider after exposure, or the code leaks secrets.",
      "fail_rate": 0.8,
      "condition": "",
      "sources": []
    }
  ],
  "workarounds": [
    {
      "action": "Verify the API key by testing it directly with curl:\ncurl -H 'Authorization: Bearer YOUR_API_KEY' https://api.openai.com/v1/models\nIf this fails, the key is invalid. Check for trailing newlines or spaces in your .env file.",
      "success_rate": 0.95,
      "how": "Verify the API key by testing it directly with curl:\ncurl -H 'Authorization: Bearer YOUR_API_KEY' https://api.openai.com/v1/models\nIf this fails, the key is invalid. Check for trailing newlines or spaces in your .env file.",
      "condition": "",
      "sources": []
    },
    {
      "action": "Ensure the API key is loaded correctly from environment variables without quotes:\nimport os\nimport openai\nopenai.api_key = os.getenv('OPENAI_API_KEY').strip()\nprint(repr(openai.api_key))  # Should show 'sk-...' without extra spaces",
      "success_rate": 0.9,
      "how": "Ensure the API key is loaded correctly from environment variables without quotes:\nimport os\nimport openai\nopenai.api_key = os.getenv('OPENAI_API_KEY').strip()\nprint(repr(openai.api_key))  # Should show 'sk-...' without extra spaces",
      "condition": "",
      "sources": []
    }
  ],
  "workarounds_zh": [
    "通过curl直接测试API密钥：\ncurl -H 'Authorization: Bearer YOUR_API_KEY' https://api.openai.com/v1/models\n如果失败，则密钥无效。检查.env文件中是否有尾随换行符或空格。",
    "确保从环境变量正确加载API密钥，不带引号：\nimport os\nimport openai\nopenai.api_key = os.getenv('OPENAI_API_KEY').strip()\nprint(repr(openai.api_key))  # 应显示'sk-...'，无多余空格"
  ],
  "transition_graph": {
    "leads_to": [],
    "preceded_by": [],
    "frequently_confused_with": []
  },
  "official_doc_url": "https://platform.openai.com/docs/guides/error-codes/api-errors",
  "official_doc_section": null,
  "error_code": null,
  "verification_tier": "ai_generated",
  "confidence": 0.9,
  "fix_success_rate": 0.95,
  "resolvable": "true",
  "first_seen": "2023-03-01",
  "last_confirmed": "2024-06-01",
  "last_updated": "2024-06-01",
  "evidence_count": 1,
  "tags": [],
  "locale": "en",
  "aliases": []
}