Return True if *err* is the OpenAI "unsupported_parameter" error for *param*.
(err: BadRequestError, param: str)
| 213 | |
| 214 | |
| 215 | def _is_unsupported_token_param_error(err: BadRequestError, param: str) -> bool: |
| 216 | """Return True if *err* is the OpenAI "unsupported_parameter" error for *param*.""" |
| 217 | body = getattr(err, "body", None) or {} |
| 218 | if isinstance(body, dict): |
| 219 | error = body.get("error") or {} |
| 220 | if isinstance(error, dict): |
| 221 | if error.get("param") == param and error.get("code") == "unsupported_parameter": |
| 222 | return True |
| 223 | # Fallback: message-based sniff for proxies that don't preserve structure |
| 224 | msg = str(err).lower() |
| 225 | return "unsupported parameter" in msg and param in msg |
| 226 | |
| 227 | |
| 228 | def _call_llm_via_litellm( |