Skip to content

Fix StreamService key detection after free quota is used (#1080)#1081

Merged
tisfeng merged 1 commit intotisfeng:devfrom
ihciah:fix-stream-api-key-quota
Feb 2, 2026
Merged

Fix StreamService key detection after free quota is used (#1080)#1081
tisfeng merged 1 commit intotisfeng:devfrom
ihciah:fix-stream-api-key-quota

Conversation

@ihciah
Copy link
Copy Markdown
Contributor

@ihciah ihciah commented Feb 2, 2026

What’s the issue?

QueryService blocks requests when a service requires a user-
provided API key, hasPrivateAPIKey() returns false, and the local
free quota is exhausted.
For StreamService-based providers, apiKeyRequirement() defaults
to .userProvided, but hasPrivateAPIKey() was never overridden, so
it always returned false even when users entered a key. This
triggers the “please register and apply for a personal API key”
error after free quota is used.

Impacted cases

Any service inheriting from StreamService (including
OpenAIService / BaseOpenAIService) can be affected, e.g.:

  • Custom OpenAI
  • DeepSeek
  • Groq
  • Zhipu
  • GitHub Models
  • Gemini
  • OpenAI

Root cause

StreamService inherits hasPrivateAPIKey() from QueryService, which
returns false by default, while the API key requirement
is .userProvided.

Fix

Override hasPrivateAPIKey() in StreamService to return !
apiKey.isEmpty, so user-supplied keys are recognized and the quota
guard no longer misfires.

Fixes #1080

StreamService defaults apiKeyRequirement to .userProvided but inherits
hasPrivateAPIKey() returning false. When local free quota is exhausted,
services like CustomOpenAI/DeepSeek/Groq/Zhipu/GitHub/Gemini/OpenAI
incorrectly report a missing key even if the user set one.

Override hasPrivateAPIKey() in StreamService to return !apiKey.isEmpty
so user-supplied keys are recognized and quota checks don't misfire.
Copy link
Copy Markdown

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello ihciah, Thank you for your first PR contribution 🎉 ihciah

@tisfeng
Copy link
Copy Markdown
Owner

tisfeng commented Feb 2, 2026

Thanks your PR, looks good

@tisfeng tisfeng merged commit 246a654 into tisfeng:dev Feb 2, 2026
4 checks passed
tisfeng pushed a commit that referenced this pull request Feb 2, 2026
StreamService defaults apiKeyRequirement to .userProvided but inherits
hasPrivateAPIKey() returning false. When local free quota is exhausted,
services like CustomOpenAI/DeepSeek/Groq/Zhipu/GitHub/Gemini/OpenAI
incorrectly report a missing key even if the user set one.

Override hasPrivateAPIKey() in StreamService to return !apiKey.isEmpty
so user-supplied keys are recognized and quota checks don't misfire.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐞 更新到2.17.0后自定义的AI接口无法翻译

2 participants