fix: align Anthropic API base URL logic with OpenAI API by Soulter · Pull Request #9802 · AstrBotDevs/AstrBot · GitHub
Skip to content

fix: align Anthropic API base URL logic with OpenAI API - #9802

Merged
Soulter merged 1 commit into
masterfrom
codex/fix-anthropic-api-base-v1
Aug 25, 2026
Merged

Soulter merged 1 commit into
masterfrom
codex/fix-anthropic-api-base-v1

Conversation

@Soulter

@Soulter Soulter commented Aug 25, 2026 •

Copy link
Copy Markdown
Member

Summary

  • strip a trailing /v1 from Anthropic-compatible API base URLs before passing them to the Anthropic SDK
  • update the default Anthropic API base URL to omit /v1
  • add regression coverage for versioned, unversioned, and gateway-prefixed base URLs

Testing

  • uv run pytest tests/test_anthropic_kimi_code_provider.py -q
  • uv run ruff format .
  • uv run ruff check .

Summary by Sourcery

Normalize Anthropic API base URLs to ensure compatible endpoint configuration across standard and gateway deployments.

Bug Fixes:

  • Normalize Anthropic-compatible API base URLs before passing them to the Anthropic SDK, including removing trailing /v1 segments.

Enhancements:

  • Update the default Anthropic API base URL to omit the version suffix.

Tests:

  • Add regression coverage for versioned, unversioned, trailing-slash, and gateway-prefixed Anthropic API base URLs.

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. labels Aug 25, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@Soulter Soulter changed the title fix: normalize Anthropic API base URLs fix: align Anthropic API base URL logic with OpenAI API Aug 25, 2026
@Soulter
Soulter merged commit 828412d into master Aug 25, 2026
21 of 22 checks passed
BegoniaHe pushed a commit to Xero-Team/AstrBot that referenced this pull request Aug 25, 2026
…9802)

Upstream-Commit: 828412d
Upstream-Author: Soulter <37870767+Soulter@users.noreply.github.com>
Upstream-PR: AstrBotDevs#9802
Sync-Disposition: adapt
Fork-Adaptation: Apply api_base /v1 stripping on the current Anthropic source and add coverage in the relocated unit test module.
Tested: uv run pytest tests/unit/provider/test_anthropic_kimi_code_provider.py -q
@Soulter
Soulter deleted the codex/fix-anthropic-api-base-v1 branch August 26, 2026 13:35
murphys7017 pushed a commit to murphys7017/AstrBot that referenced this pull request Sep 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:provider The bug / feature is about AI Provider, Models, LLM Agent, LLM Agent Runner. size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant