Improve detection accuracy for non-OpenAI providers#1
Open
jimbb wants to merge 1 commit into
Open
Conversation
Fixes false negatives when detecting OpenAI-compatible APIs:
1. Parse JSON regardless of Content-Type header
- Some providers (e.g., Alibaba Bailian) return JSON without
setting the proper Content-Type header
- Now attempts JSON.parse on all responses
2. Detect "model not supported" errors as valid API detection
- When probing with gpt-4o-mini fails because the provider uses
different model names (e.g., glm-5), report as "API detected but
model not available" instead of "not detected"
- New errorType: 'model_not_found'
3. Detect payment/credit errors as valid API detection
- 402/403/429 errors with payment-related keywords now report as
"API detected but payment issue" instead of "not detected"
- New errorType: 'payment'
- Supports English and Chinese payment error messages
4. Provide model hints in error messages
- When model not found, suggests checking /v1/models or lists
available models
Tested with:
- OpenAI (working)
- Alibaba Bailian (was false negative, now correctly detected)
- OpenRouter (payment issue, now correctly detected)
- NavaClaude (account expired, correctly detected)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes false negatives when detecting OpenAI-compatible APIs from non-OpenAI providers.
Changes
1. Parse JSON regardless of Content-Type header
Some providers (e.g., Alibaba Bailian) return valid JSON responses without setting
Content-Type: application/json. The tool now attempts to parse JSON on all responses.2. Detect "model not supported" errors as valid API detection
When the probe model (
gpt-4o-mini) is not available on the provider but the API is otherwise working, the tool now reports:supported: trueerrorType: "model_not_found"/v1/modelsendpointBefore:
{"supported": false, "message": "Chat Completions API was not detected."}After:
{"supported": true, "confidence": "medium", "errorType": "model_not_found", "message": "API detected, but model 'gpt-4o-mini' not available. Check /v1/models for available models."}3. Detect payment/credit errors as valid API detection
402/403/429 errors with payment-related keywords now report as API detected with payment issue, rather than "not detected".
Before:
{"supported": false, "message": "Chat Completions API was not detected."}After:
{"supported": true, "confidence": "medium", "errorType": "payment", "message": "Insufficient credits. Add more using https://openrouter.ai/settings/credits"}New Error Types
model_not_found- API exists but probed model not availablepayment- API exists but payment/credit issueTesting