{"record":{"id":"7f71be778d2a3baa","repo":"xtekky/gpt4free","slug":"result-error-get-message-result-error","errorCode":null,"errorMessage":"result[\"error\"].get(\"message\", result[\"error\"])","messagePattern":"result\\[\"error\"\\]\\.get\\(\"message\", result\\[\"error\"\\]\\)","errorType":"exception","errorClass":"ResponseError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/needs_auth/Puter.py","lineNumber":486,"sourceCode":"                        param: kwargs.get(param)\n                        for param in extra_parameters\n                        if param in kwargs\n                    },\n                },\n            }\n            async with session.post(\n                cls.api_endpoint, headers=headers, json=json_data, proxy=proxy\n            ) as response:\n                await raise_for_status(response)\n                mime_type = response.headers.get(\"content-type\", \"\")\n                if mime_type.startswith(\"text/plain\"):\n                    yield await response.text()\n                    return\n                elif mime_type.startswith(\"text/event-stream\"):\n                    reasoning = False\n                    async for result in sse_stream(response.content):\n                        if \"error\" in result:\n                            raise ResponseError(\n                                result[\"error\"].get(\"message\", result[\"error\"])\n                            )\n                        choices = result.get(\"choices\", [{}])\n                        choice = choices.pop() if choices else {}\n                        content = choice.get(\"delta\", {}).get(\"content\")\n                        reasoning_content = choice.get(\"delta\", {}).get(\n                            \"reasoning_content\"\n                        )\n                        if reasoning_content:\n                            reasoning = True\n                            yield Reasoning(reasoning_content)\n                        elif content:\n                            if reasoning:\n                                yield Reasoning(status=\"\")\n                                reasoning = False\n                            yield content\n                        if result.get(\"usage\") is not None:\n                            yield Usage(**result[\"usage\"])","sourceCodeStart":468,"sourceCodeEnd":504,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/Puter.py#L468-L504","documentation":"Raised as ResponseError while consuming Puter's text/event-stream response: an SSE event arrived whose JSON payload contains an 'error' key. The provider surfaces the upstream error message (or the raw error object) and terminates the stream.","triggerScenarios":"Streaming a completion from Puter when the upstream service returns an error event mid-stream: invalid model, quota exceeded, rate limit, or malformed request accepted late.","commonSituations":"Using a model name Puter no longer supports, hitting account rate limits partway through a long streaming session, transient upstream 5xx surfaced as SSE error events.","solutions":["Catch ResponseError and inspect the message; fix the model name or request payload it complains about","Check Puter account quota/usage if the message indicates rate or credit limits","Retry with backoff for transient upstream errors; fall back to another provider if persistent"],"exampleFix":"# before\nfor chunk in client.chat.completions.create(..., stream=True):\n    print(chunk.choices[0].delta.content)\n\n# after\ntry:\n    for chunk in client.chat.completions.create(..., stream=True):\n        print(chunk.choices[0].delta.content)\nexcept g4f.errors.ResponseError as e:\n    logging.error('Puter stream error: %s', e)\n    raise","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"from g4f.errors import ResponseError\ntry:\n    stream = ...create(..., stream=True)\n    for chunk in stream: process(chunk)\nexcept ResponseError as e:\n    if 'rate' in str(e).lower():\n        backoff_and_retry()\n    else:\n        raise","preventionTips":["Validate model names against the provider's supported list before streaming","Wrap streaming loops in ResponseError handling with retry/backoff","Monitor quota headers/messages from Puter to back off before hard errors"],"tags":["streaming","sse","upstream-error","puter","g4f"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}