{"record":{"id":"7329a860c8baa6ce","repo":"browser-use/browser-use","slug":"str-e-7329a8","errorCode":null,"errorMessage":"str(e)","messagePattern":"str\\(e\\)","errorType":"exception","errorClass":"ModelRateLimitError","httpStatus":null,"severity":"warning","filePath":"browser_use/llm/cerebras/chat.py","lineNumber":129,"sourceCode":"\t\t\tcommon['top_p'] = self.top_p\n\t\tif self.seed is not None:\n\t\t\tcommon['seed'] = self.seed\n\n\t\t# ① Regular multi-turn conversation/text output\n\t\tif output_format is None:\n\t\t\ttry:\n\t\t\t\tresp = await client.chat.completions.create(  # type: ignore\n\t\t\t\t\tmodel=self.model,\n\t\t\t\t\tmessages=cerebras_messages,  # type: ignore\n\t\t\t\t\t**common,\n\t\t\t\t)\n\t\t\t\tusage = self._get_usage(resp)\n\t\t\t\treturn ChatInvokeCompletion(\n\t\t\t\t\tcompletion=resp.choices[0].message.content or '',\n\t\t\t\t\tusage=usage,\n\t\t\t\t)\n\t\t\texcept RateLimitError as e:\n\t\t\t\traise ModelRateLimitError(str(e), model=self.name) from e\n\t\t\texcept (APIError, APIConnectionError, APITimeoutError, APIStatusError) as e:\n\t\t\t\traise ModelProviderError(str(e), model=self.name) from e\n\t\t\texcept Exception as e:\n\t\t\t\traise ModelProviderError(str(e), model=self.name) from e\n\n\t\t# ② JSON Output path (response_format)\n\t\tif output_format is not None and hasattr(output_format, 'model_json_schema'):\n\t\t\ttry:\n\t\t\t\t# For Cerebras, we'll use a simpler approach without response_format\n\t\t\t\t# Instead, we'll ask the model to return JSON and parse it\n\t\t\t\timport json\n\n\t\t\t\t# Get the schema to guide the model\n\t\t\t\tschema = output_format.model_json_schema()\n\t\t\t\tschema_str = json.dumps(schema, indent=2)\n\n\t\t\t\t# Create a prompt that asks for the specific JSON structure\n\t\t\t\tjson_prompt = f\"\"\"","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/browser-use/browser-use/blob/6c73fced2f6d45a11d88622fe56365a5fe18f28b/browser_use/llm/cerebras/chat.py#L111-L147","documentation":"In ChatCerebras.ainvoke's plain-text path (output_format is None), an openai.RateLimitError from client.chat.completions.create is re-raised as ModelRateLimitError with the SDK's message. Cerebras is accessed through the OpenAI-compatible SDK, so a 429 from Cerebras surfaces as RateLimitError and is normalized here so callers get one retryable error type.","triggerScenarios":"Calling ainvoke without output_format while exceeding Cerebras free-tier rate limits (requests per minute/hour or tokens per minute); bursty agent steps issuing many completions in sequence; concurrent agents sharing one CEREBRAS_API_KEY.","commonSituations":"Cerebras free tier is generous in tokens but strict on requests-per-minute, so step-heavy browser agents trip it easily; CI parallelism; a retry loop amplifying request frequency after a slow response.","solutions":["Retry with exponential backoff on ModelRateLimitError and cap concurrency (semaphore) across agents","Check which limit was hit (RPM vs TPM) in the message text and pace requests accordingly — add small delays between agent steps if RPM-bound","Cache or reuse extraction results to cut request volume; use page_extraction_llm on a separate provider","Move to a paid Cerebras tier or higher limit if the workload is legitimate"],"exampleFix":"# before\nresp = await llm.ainvoke(messages)  # 429 -> ModelRateLimitError\n\n# after\nasync def invoke_backoff(llm, messages, attempts=5):\n    for i in range(attempts):\n        try:\n            return await llm.ainvoke(messages)\n        except ModelRateLimitError:\n            if i == attempts - 1:\n                raise\n            await asyncio.sleep(2 ** i)","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"from browser_use.exceptions import ModelRateLimitError\n\ntry:\n    out = await llm.ainvoke(messages)\nexcept ModelRateLimitError:\n    await asyncio.sleep(30)\n    out = await llm.ainvoke(messages)  # single bounded retry","preventionTips":["Track requests-per-minute against your Cerebras tier; pad delays between agent steps","Separate keys or providers for main llm vs page_extraction_llm to split quotas","Backoff on ModelRateLimitError uniformly across providers — the library normalizes the type for this purpose"],"tags":["rate-limit","cerebras","retry","http-429","openai-sdk"],"backgroundTag":null,"analyzedSha":"6c73fced2f6d45a11d88622fe56365a5fe18f28b","analyzedAt":"2026-08-14T19:42:40.557Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}