FoundationAgents/MetaGPT · error · RuntimeError

Request failed, msg: {resp}, please ref to `https://open.big

Error message

Request failed, msg: {resp}, please ref to `https://open.bigmodel.cn/dev/api#error-code-v3`

What it means

ZhipuModelAPI.acreate (non-streaming async invocation) decodes the JSON response and checks for an 'error' key; if present it raises RuntimeError with the whole response payload plus a reference to BigModel's error-code page. This is the generic wrapper for any application-level API error ZhipuAI returns (auth, quota, invalid params, content policy).

Source

Thrown at metagpt/provider/zhipuai/zhipu_model_api.py:46

        requester = GeneralAPIRequestor(base_url=base_url)
        result, _, api_key = await requester.arequest(
            method=method,
            url=url,
            headers=headers,
            stream=stream,
            params=kwargs,
            request_timeout=ZHIPUAI_DEFAULT_TIMEOUT.read,
        )
        return result

    async def acreate(self, **kwargs) -> dict:
        """async invoke different from raw method `async_invoke` which get the final result by task_id"""
        headers = self._default_headers
        resp = await self.arequest(stream=False, method="post", headers=headers, kwargs=kwargs)
        resp = resp.data.decode("utf-8")
        resp = json.loads(resp)
        if "error" in resp:
            raise RuntimeError(
                f"Request failed, msg: {resp}, please ref to `https://open.bigmodel.cn/dev/api#error-code-v3`"
            )
        return resp

    async def acreate_stream(self, **kwargs) -> AsyncSSEClient:
        """async sse_invoke"""
        headers = self._default_headers
        return AsyncSSEClient(await self.arequest(stream=True, method="post", headers=headers, kwargs=kwargs))

View on GitHub (pinned to 11cdf466d0)

Solutions

  1. Parse the error object inside the exception text for the official errCode and act on it (429 -> backoff, 1001/1002 -> fix key, 1113 -> rework prompt).
  2. For rate limits, retry with exponential backoff and jitter.
  3. Verify API key and that the model name (e.g. glm-4) is still supported.
  4. Upgrade the metagpt zhipuai vendored client if error schemas changed.
Defensive patterns

Strategy: retry

Try / catch

import asyncio

for attempt in range(3):
    try:
        resp = await api.acreate(**kwargs)
        break
    except RuntimeError as e:
        if "error-code-v3" not in str(e) or not is_retryable(str(e)):
            raise  # auth/content errors are not retryable
        await asyncio.sleep(2 ** attempt)

Prevention

When it happens

Trigger: Any await of acreate with bad input: wrong API key, exceeding rate limits, unknown model, malformed messages, or disallowed content; the response body is a JSON object containing "error".

Common situations: Invalid/expired ZHIPUAI_API_KEY, free-tier quota exhaustion, parameter mismatches after SDK upgrades, or prompt content flagged by Zhipu's moderation.

Related errors


AI-assisted analysis of FoundationAgents/MetaGPT@11cdf466d0 (2026-08-14). Data as JSON: /api/errors/ca1a34334aa8d988. Report an issue: GitHub.