Commit 761be76c

stainless-app[bot] <142633134+stainless-app[bot]@users.noreply.github.com>
2025-04-24 06:08:18
chore: broadly detect json family of content-type headers
1 parent c9cedd8
Changed files (2)
src/openai/_legacy_response.py
@@ -304,7 +304,7 @@ class LegacyAPIResponse(Generic[R]):
         # split is required to handle cases where additional information is included
         # in the response, e.g. application/json; charset=utf-8
         content_type, *_ = response.headers.get("content-type", "*").split(";")
-        if content_type != "application/json":
+        if not content_type.endswith("json"):
             if is_basemodel(cast_to):
                 try:
                     data = response.json()
src/openai/_response.py
@@ -237,7 +237,7 @@ class BaseAPIResponse(Generic[R]):
         # split is required to handle cases where additional information is included
         # in the response, e.g. application/json; charset=utf-8
         content_type, *_ = response.headers.get("content-type", "*").split(";")
-        if content_type != "application/json":
+        if not content_type.endswith("json"):
             if is_basemodel(cast_to):
                 try:
                     data = response.json()