{"record":{"id":"372e8dfd2ade07db","repo":"xtekky/gpt4free","slug":"invalid-response-result","errorCode":null,"errorMessage":"Invalid response: {result}","messagePattern":"Invalid response: (.+?)","errorType":"exception","errorClass":"ResponseError","httpStatus":null,"severity":"error","filePath":"g4f/Provider/needs_auth/Replicate.py","lineNumber":71,"sourceCode":"                    \"prompt\": format_prompt(messages),\n                    **filter_none(\n                        system_prompt=system_prompt,\n                        max_new_tokens=max_tokens,\n                        temperature=temperature,\n                        top_p=top_p,\n                        top_k=top_k,\n                        stop_sequences=\",\".join(stop) if stop else None,\n                    ),\n                    **extra_body,\n                },\n            }\n            url = f\"{base_url.rstrip('/')}/{model}/predictions\"\n            async with session.post(url, json=data) as response:\n                message = \"Model not found\" if response.status == 404 else None\n                await raise_for_status(response, message)\n                result = await response.json()\n                if \"id\" not in result:\n                    raise ResponseError(f\"Invalid response: {result}\")\n                async with session.get(\n                    result[\"urls\"][\"stream\"], headers={\"Accept\": \"text/event-stream\"}\n                ) as response:\n                    await raise_for_status(response)\n                    event = None\n                    async for line in response.iter_lines():\n                        if line.startswith(b\"event: \"):\n                            event = line[7:]\n                            if event == b\"done\":\n                                break\n                        elif event == b\"output\":\n                            if line.startswith(b\"data: \"):\n                                new_text = line[6:].decode()\n                                if new_text:\n                                    yield new_text\n                                else:\n                                    yield \"\\n\"\n","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/xtekky/gpt4free/blob/973504e1770928ed5fb82f43da528f441ad9ddc3/g4f/Provider/needs_auth/Replicate.py#L53-L89","documentation":"Raised as ResponseError after POSTing to {base_url}/{model}/predictions when the returned JSON has no 'id' key. Replicate normally returns a prediction object with an id used to open the streaming URL; anything else means the creation call did not produce a usable prediction.","triggerScenarios":"The prediction-creation endpoint returns an error object (missing/invalid token with 200-style handling, model not deployable, malformed input) so the response JSON lacks 'id'.","commonSituations":"Replicate API token invalid so the POST returns an auth error document, model slug typo handled as JSON error, upstream schema change.","solutions":["Inspect the raised message — it contains the full JSON body returned by Replicate","Verify the api_key is a valid Replicate token (starts with r8_)","Verify the model slug exists and is hosted on api.replicate.com when using a key"],"exampleFix":"# before\nresponse = client.chat.completions.create(model='owner/model', provider=g4f.Provider.Replicate, api_key=key)\n\n# after\ntry:\n    response = client.chat.completions.create(model='owner/model', provider=g4f.Provider.Replicate, api_key=key)\nexcept g4f.errors.ResponseError as e:\n    logging.error('Replicate prediction creation failed: %s', e)\n    raise","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from g4f.errors import ResponseError\ntry:\n    result = ...create(provider=g4f.Provider.Replicate)\nexcept ResponseError as e:\n    logging.error('Replicate body: %s', e)\n    if 'auth' in str(e).lower():\n        rotate_replicate_token()\n    else:\n        raise","preventionTips":["Log the raw response body carried in the error — it names the real cause","Validate model slugs (owner/name) against Replicate's catalog before calling"],"tags":["api","response-parsing","replicate","g4f"],"backgroundTag":null,"analyzedSha":"973504e1770928ed5fb82f43da528f441ad9ddc3","analyzedAt":"2026-08-14T23:45:32.408Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}