ruvnet/ruflo · error · Error

Anthropic API error: ${response.status}

Error message

Anthropic API error: ${response.status}

What it means

The Anthropic messages API returned a non-2xx status for the sampling call. The HTTP status is surfaced (rate limit, auth failure, overloaded, etc.) so the caller can distinguish provider-side failures from local validation issues.

Source

Thrown at v3/@claude-flow/mcp/src/sampling.ts:344

        headers: {
          'Content-Type': 'application/json',
          'x-api-key': apiKey,
          'anthropic-version': '2023-06-01',
        },
        body: JSON.stringify({
          model: 'claude-3-haiku-20240307',
          max_tokens: request.maxTokens,
          temperature: request.temperature,
          system: request.systemPrompt,
          messages: request.messages.map((m) => ({
            role: m.role,
            content: m.content.type === 'text' ? (m.content as any).text : m.content,
          })),
        }),
      });

      if (!response.ok) {
        throw new Error(`Anthropic API error: ${response.status}`);
      }

      const data = await response.json() as any;

      return {
        role: 'assistant',
        content: {
          type: 'text',
          text: data.content[0]?.text || '',
        },
        model: data.model,
        stopReason: data.stop_reason === 'end_turn' ? 'endTurn' : 'maxTokens',
      };
    },
    async isAvailable(): Promise<boolean> {
      return !!apiKey;
    },
  };

View on GitHub (pinned to fa13ee4ad6)

Solutions

  1. Read the response body for the API error detail and include it in the thrown error.
  2. Verify ANTHROPIC_API_KEY is valid and has quota.
  3. Retry with exponential backoff on 429/5xx statuses.
Defensive patterns

Strategy: retry

When it happens

Trigger: The Anthropic API returns a non-2xx HTTP status during a sampling request.

Common situations: Invalid or expired API key (401), rate limiting (429), overloaded API (529), or malformed request body (400).


AI-assisted analysis of ruvnet/ruflo@fa13ee4ad6 (2026-08-18). Data as JSON: /api/errors/f2b649a8b84b07a0. Report an issue: GitHub.