{"record":{"id":"76456619a6d04150","repo":"xtekky/gpt4free","slug":"unexpected-content-type-mime-type","errorCode":null,"errorMessage":"Unexpected content type: {mime_type}","messagePattern":"Unexpected content type: (.+?)","errorType":"exception","errorClass":"ResponseError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/needs_auth/Puter.py","lineNumber":565,"sourceCode":"                                [\n                                    {\n                                        \"id\": tools_idx,\n                                        \"type\": \"function\",\n                                        \"id\": data.get(\"id\"),\n                                        \"function\": {\n                                            \"name\": data.get(\"name\"),\n                                            \"arguments\": data.get(\"input\"),\n                                        },\n                                    }\n                                ]\n                            )\n                            tools_idx += 1\n                        elif data.get(\"type\") == \"tool_calls\":\n                            yield ToolCalls(data.get(\"tool_calls\", []))\n                        elif data.get(\"type\") == \"usage\":\n                            yield Usage.from_dict(data.get(\"usage\", {}))\n                else:\n                    raise ResponseError(f\"Unexpected content type: {mime_type}\")\n","sourceCodeStart":547,"sourceCodeEnd":566,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/Puter.py#L547-L566","documentation":"Raised as ResponseError at the end of Puter's response handling when the HTTP content-type is none of text/plain, text/event-stream, or application/json. The provider only knows how to parse those three shapes; anything else (e.g. text/html from a proxy or WAF page) is rejected.","triggerScenarios":"Puter (or an intermediary proxy/CDN) responds with text/html — a login page, captcha, or error page — or a content type introduced by an upstream change.","commonSituations":"Requests routed through a corporate proxy that injects HTML block pages, Puter under maintenance returning an HTML error page, region-blocked access returning an HTML notice.","solutions":["Retry without a proxy or with a different proxy to rule out HTML injection by an intermediary","Check whether the Puter endpoint is reachable directly (curl the endpoint and inspect content-type)","Update g4f if a newer release handles the new content type"],"exampleFix":"# before\nresponse = client.chat.completions.create(model=..., messages=msgs)  # Unexpected content type: text/html\n\n# after\nclient = g4f.Client(proxies=None)  # bypass proxy that injects HTML\nresponse = client.chat.completions.create(model=..., messages=msgs)","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"from g4f.errors import ResponseError\ntry:\n    result = ...create(...)\nexcept ResponseError as e:\n    if 'Unexpected content type' in str(e):\n        result = retry_without_proxy()  # proxy likely injected HTML\n    else:\n        raise","preventionTips":["Test provider reachability from the deployment network before relying on it","Avoid proxies that rewrite/inject content for API traffic"],"tags":["http","content-type","proxy","puter","g4f"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}