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

        version: string
        displayName: string
        description: string
        inputTokenLimit: number
        outputTokenLimit: number
        supportedGenerationMethods: string[]
        temperature: number
        topP: number
        topK: number
      }[]
    }
    const res = await this.dependencies.request.apiRequest({
      url: `${this.options.geminiAPIHost}/v1beta/models?key=${this.options.geminiAPIKey}`,
      method: 'GET',
      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))
  }
}

View on GitHub (pinned to 81571269ad)

Solutions

  1. Verify the Gemini API key is valid and the Generative Language API is enabled for the project.
  2. Check that geminiAPIHost is correct and reachable.
  3. Inspect the stringified response body for the upstream error message.
  4. Confirm the response contains a 'models' array; a proxy or captive portal may be returning something else.

Example fix

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

When it happens

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

Common situations: Occurs in src/shared/providers/definitions/models/gemini.ts when the Gemini API 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/995b4fc4077b044e. Report an issue: GitHub.