{"record":{"id":"1287e5ce8c189441","repo":"xtekky/gpt4free","slug":"unexpected-content-type-content-type","errorCode":null,"errorMessage":"Unexpected content type: {content_type}","messagePattern":"Unexpected content type: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"g4f/Provider/template/OpenaiTemplate.py","lineNumber":281,"sourceCode":"                                or data.startswith(\"https://\")\n                            ]\n                        ),\n                        None,\n                    )\n                async with session.post(\n                    f\"{base_url.rstrip('/')}/images/generations\", json=data, ssl=cls.ssl\n                ) as response:\n                    content_type = response.headers.get(\"content-type\", \"\")\n                    if content_type.startswith(\"application/json\"):\n                        data = await response.json()\n                        cls.raise_error(data, response.status)\n                        model = data.get(\"model\")\n                        if model:\n                            yield ProviderInfo(**cls.get_dict(), model=model)\n                    elif content_type.startswith(\"text/plain\"):\n                        raise Exception(\"Unexpected response: \" + await response.text())\n                    else:\n                        raise Exception(\"Unexpected content type: \" + content_type)\n                    await raise_for_status(response)\n                    yield ImageResponse(\n                        [\n                            f\"data:image/png;base64,{image['b64_json']}\"\n                            if image.get(\"url\") is None\n                            else image[\"url\"]\n                            for image in data[\"data\"]\n                        ],\n                        prompt,\n                    )\n                return\n\n            if stream or stream is None:\n                kwargs.setdefault(\"stream_options\", {\"include_usage\": True})\n            extra_parameters = {\n                key: kwargs[key] for key in extra_parameters if key in kwargs\n            }\n            if extra_body is None:","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/template/OpenaiTemplate.py#L263-L299","documentation":"Error \"Unexpected content type: {content_type}\" thrown in xtekky/gpt4free.","triggerScenarios":"Thrown at g4f/Provider/template/OpenaiTemplate.py:281 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Confirm base_url points to an API endpoint that returns JSON, not an HTML page.","Verify the request path and headers (Accept: application/json)."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}