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/custom-gemini.ts:180

        supportedGenerationMethods: string[]
        temperature: number
        topP: number
        topK: number
      }[]
    }

    try {
      const { apiHost } = normalizeGeminiHost(this.options.apiHost)
      const res = await this.dependencies.request.apiRequest({
        url: `${apiHost}/models?key=${this.options.apiKey}`,
        method: 'GET',
        useProxy: this.options.useProxy,
        headers: {},
      })
      const json: Response = await res.json()

      if (!json.models) {
        throw new ApiError(JSON.stringify(json))
      }

      return json.models
        .filter((m) => m.supportedGenerationMethods.some((method) => method.includes('generate')))
        .filter((m) => m.name.includes('gemini'))
        .map((m) => ({
          modelId: m.name.replace('models/', ''),
          nickname: m.displayName,
          type: 'chat' as const,
          contextWindow: m.inputTokenLimit,
          maxOutput: m.outputTokenLimit,
        }))
        .sort((a, b) => a.modelId.localeCompare(b.modelId))
    } catch (error) {
      console.error('Failed to fetch Gemini models:', error)
      return []
    }
  }

View on GitHub (pinned to 81571269ad)

Solutions

  1. Check that the custom Gemini API host is correct and reachable.
  2. Verify the API key passed in the /models?key= query is valid and has Generative Language API access.
  3. Inspect the stringified response body for the upstream error (e.g. API_KEY_INVALID).
  4. Confirm the endpoint returns the standard Gemini list-models shape with a 'models' array.

Example fix

const json: Response = await res.json()
if (!json.models) {
  console.error('Custom Gemini listModels error:', json)
}

When it happens

Trigger: Thrown at src/shared/providers/definitions/models/custom-gemini.ts:180 when the library encounters an invalid state.

Common situations: Occurs in src/shared/providers/definitions/models/custom-gemini.ts when the custom Gemini endpoint returns an error response whose JSON body is thrown as an ApiError.


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