chatboxai/chatbox · error · ApiError

JSON.stringify(json)

Error message

JSON.stringify(json)

What it means

Error "JSON.stringify(json)" thrown in chatboxai/chatbox.

Source

Thrown at src/shared/providers/definitions/models/claude.ts:167

    }
    const url = `${this.options.claudeApiHost}/models?limit=990`
    const headers: Record<string, string> = {
      'anthropic-version': '2023-06-01',
      ...this.options.extraHeaders,
    }
    if (this.options.authToken) {
      headers['Authorization'] = `Bearer ${this.options.authToken}`
    } else if (this.options.claudeApiKey) {
      headers['x-api-key'] = this.options.claudeApiKey
    }
    const res = await this.dependencies.request.apiRequest({
      url: url,
      method: 'GET',
      headers,
    })
    const json: Response = await res.json()
    if (!json['data']) {
      throw new ApiError(JSON.stringify(json))
    }
    return json['data']
      .filter((item) => item.type === 'model')
      .map((item) => ({
        modelId: item.id,
        type: 'chat',
      }))
  }
}

function parseJsonObject(value: string): Record<string, unknown> | undefined {
  try {
    const parsed = JSON.parse(value)
    return isRecord(parsed) ? parsed : undefined
  } catch {
    return undefined
  }
}

View on GitHub (pinned to 81571269ad)

Solutions

  1. Check that the Claude API host is reachable and correct in provider settings.
  2. Verify the API key or OAuth token is valid and has not expired.
  3. Inspect the stringified response body for the upstream error message (e.g. authentication_error, permission_error).
  4. If using a custom relay or proxy, confirm it returns the standard Anthropic /models response shape with a 'data' array.

Example fix

const json: Response = await res.json()
if (!json['data']) {
  // json contains the upstream error; surface it and check credentials
  console.error('Claude listModels error:', json)
}

When it happens

Trigger: Thrown at src/shared/providers/definitions/models/claude.ts:167 when the library encounters an invalid state.

Common situations: Occurs in src/shared/providers/definitions/models/claude.ts when the Anthropic API returns a non-success response whose body is serialized with JSON.stringify and thrown as an ApiError.


AI-assisted analysis of chatboxai/chatbox@81571269ad (2026-08-12). Data as JSON: /api/errors/652906825cbecb89. Report an issue: GitHub.