Skip to content

fix: improve third-party API compatibility#108

Open
litunan wants to merge 1 commit intoGCWing:mainfrom
litunan:fix/third-party-api-compatibility
Open

fix: improve third-party API compatibility#108
litunan wants to merge 1 commit intoGCWing:mainfrom
litunan:fix/third-party-api-compatibility

Conversation

@litunan
Copy link

@litunan litunan commented Mar 10, 2026

Summary

  • fix: don't send 'thinking' parameter when disabled to prevent 400 errors from APIs that don't recognize this field
  • fix: make tool_calls.index optional with serde(default) for APIs that omit this field in streaming responses
  • fix: add serde alias 'output_tokens' for completion_tokens and defaults for usage fields to support APIs using different field names

Why

Third-party APIs (non-OpenAI/Anthropic) may not recognize the "thinking" parameter and return 400 errors. This PR ensures compatibility with a wider range of AI providers.

Fixes #75

- fix: don't send 'thinking' parameter when disabled to prevent 400 errors
  from APIs that don't recognize this field
- fix: make tool_calls.index optional with serde(default) for APIs that
  omit this field in streaming responses
- fix: add serde alias 'output_tokens' for completion_tokens and defaults
  for usage fields to support APIs using different field names

Fixes GCWing#75

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@litunan litunan force-pushed the fix/third-party-api-compatibility branch from e6f0f4e to 7a17025 Compare March 10, 2026 12:26
@GCWing
Copy link
Owner

GCWing commented Mar 10, 2026

@wsp1911 review

@GCWing GCWing requested a review from wsp1911 March 10, 2026 12:28
@wsp1911
Copy link
Collaborator

wsp1911 commented Mar 10, 2026

有些API(如智谱GLM-5),默认(不传思考字段)启用思考,不显式设置thinking=disabled会导致无法关闭思考。建议查阅报错API文档了解如何控制思考设置,若无相关设置,可先根据url特判

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.

Third-party API incompatibility

3 participants