Skip to content

feat: support claude-opus-4-8 - #5177

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
hjxwz123:feat-claude-opus-4-8
May 31, 2026
Merged

feat: support claude-opus-4-8#5177
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
hjxwz123:feat-claude-opus-4-8

Conversation

@hjxwz123

@hjxwz123 hjxwz123 commented May 29, 2026

Copy link
Copy Markdown
Contributor

⚠️ PR Notice

Important

  • Please provide a concise, human-written summary. Avoid pasting unreviewed AI-generated output.

📝 Description

This PR adds support for claude-opus-4-8 by mirroring the existing claude-opus-4-7 adaptation.

Opus 4.8 uses the same request behavior as Opus 4.7, with only the model name changed. The update adds the Opus 4.8 base model and suffix variants to the Claude model list, reuses the adaptive thinking conversion for effort suffixes and -thinking, and adds matching AWS Bedrock, Vertex, model ratio, and cache ratio entries.

🚀 Type of change

  • 🐛 Bug fix - Please link the related issue. Do not classify design choices, expectation differences, or interpretation differences as bugs.
  • ✨ New feature - Major features should preferably be discussed through an issue first.
  • ⚡ Refactor / performance improvement
  • 📝 Documentation update

🔗 Related Issue

  • Closes # (if any)

✅ Checklist

  • Human confirmation: I have personally reviewed and written this description instead of pasting unreviewed generated output.
  • Not a duplicate: I have searched existing Issues and PRs and confirmed this is not a duplicate.
  • Bug fix note: If this PR is marked as a bug fix, I have submitted or linked the related issue and will not classify design choices, expectation differences, or interpretation differences directly as bugs.
  • Understanding: I understand how these changes work and their possible impact.
  • Focused scope: This PR does not include unrelated code changes.
  • Local validation: I have run local tests or manual validation so maintainers can verify the result.
  • Security and compliance: The code contains no sensitive credentials and follows the project coding conventions.

📸 Proof of Work

gofmt -w relay/claude_handler.go relay/channel/claude/relay-claude.go relay/channel/claude/constants.go relay/channel/aws/constants.go relay/channel/vertex/adaptor.go setting/ratio_setting/model_ratio.go setting/ratio_setting/cache_ratio.go relay/channel/claude/relay_claude_test.go

git diff --check
# passed

go test ./relay/channel/claude -run 'TestRequestOpenAI2ClaudeMessage_ClaudeOpus48' -count=1
# ok github.com/QuantumNous/new-api/relay/channel/claude

go test ./relay/channel/aws ./relay/channel/vertex ./setting/ratio_setting ./relay -count=1
# ok github.com/QuantumNous/new-api/relay/channel/aws
# ?  github.com/QuantumNous/new-api/relay/channel/vertex [no test files]
# ?  github.com/QuantumNous/new-api/setting/ratio_setting [no test files]
# ?  github.com/QuantumNous/new-api/relay [no test files]

Summary by CodeRabbit

  • New Features
    • Added support for Claude Opus 4.8 model and variants (thinking, max, xhigh, high, medium, low) across AWS, Claude, and Vertex channels.
    • Enabled adaptive thinking mode and high-effort output configuration for Opus 4.8.
    • Configured cache and token ratio defaults for new model variants.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 29, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5824bbca-7f1d-4dae-82f5-40fb0e6c10df

📥 Commits

Reviewing files that changed from the base of the PR and between 1588027 and 60e4cf1.

📒 Files selected for processing (8)
  • relay/channel/aws/constants.go
  • relay/channel/claude/constants.go
  • relay/channel/claude/relay-claude.go
  • relay/channel/claude/relay_claude_test.go
  • relay/channel/vertex/adaptor.go
  • relay/claude_handler.go
  • setting/ratio_setting/cache_ratio.go
  • setting/ratio_setting/model_ratio.go

Walkthrough

This PR extends Claude Opus 4.8 model support across the platform by adding model registrations, request conversion logic, thinking configuration, pricing ratios, and test coverage—following the same patterns previously implemented for Opus 4.7.

Changes

Claude Opus 4.8 Model Support

Layer / File(s) Summary
Model Registry and Channel Integration
relay/channel/aws/constants.go, relay/channel/claude/constants.go, relay/channel/vertex/adaptor.go
Registered claude-opus-4-8 model identifier in AWS channel (with cross-region support for us, ap, eu), added seven claude-opus-4-8* variants to Claude ModelList, and mapped claude-opus-4-8 in Vertex adaptor.
Request Conversion and Thinking Logic
relay/channel/claude/relay-claude.go, relay/claude_handler.go
Extended effort-suffix trimming and thinking-adapter branches to treat claude-opus-4-8 identically to claude-opus-4-7: normalizes model to trimmed base, sets Thinking to adaptive/summarized, clears sampling parameters (Temperature, TopP, TopK), and applies OutputConfig effort configuration.
Pricing and Capacity Configuration
setting/ratio_setting/cache_ratio.go, setting/ratio_setting/model_ratio.go
Added cache ratio (0.1), create-cache ratio (1.25), and model ratio (2.5) entries for all claude-opus-4-8 variants to support cost and token-usage calculations.
Test Cases for Model Conversion
relay/channel/claude/relay_claude_test.go
Added generic pointer helper and two test cases validating claude-opus-4-8-high and claude-opus-4-8-thinking request conversion: model normalization, adaptive thinking config, effort-based OutputConfig, and parameter clearing.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related issues

  • QuantumNous/new-api#4335: Extends the same Opus 4.7 parameter-sanitization and thinking-type adjustments to Opus 4.8 in the same functions and files.

Possibly related PRs

  • QuantumNous/new-api#4293: Original Opus 4.7 thinking and effort suffix handling implementation; this PR applies the same patterns to Opus 4.8.
  • QuantumNous/new-api#2863: Extended Claude model-normalization and thinking adapter logic for prior Opus variants; this PR follows the same architectural approach.
  • QuantumNous/new-api#2375: Extended Claude model support with pricing and cache ratio maps; this PR adds analogous entries for Opus 4.8 variants.

Suggested reviewers

  • seefs001

Poem

🐰 A new Claude hops into the pasture,
Opus 4.8, swift and faster!
With thinking refined and efforts all clear,
Cross-region and priced—let's give a cheer! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: support claude-opus-4-8' clearly and specifically describes the main change: adding support for a new Claude model variant. It directly matches the changeset's primary objective of extending support to the claude-opus-4-8 model family.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Calcium-Ion
Calcium-Ion merged commit 0c7aceb into QuantumNous:main May 31, 2026
2 checks passed
isboyjc added a commit to isboyjc/amux-api that referenced this pull request May 31, 2026
Sync upstream QuantumNous/new-api 0c7aceb (clean cherry-pick).
Add claude-opus-4-8 (+ -max/-xhigh/-high/-medium/-low/-thinking variants)
to the claude model list, aws model-id + cross-region maps, vertex claude
model map, and default model/cache ratios; extend the opus-4-6/4-7
adaptive-thinking and effort-suffix handling in relay-claude.go and
claude_handler.go to also match opus-4-8 (which likewise rejects
non-default temperature/top_p/top_k and thinking.type=enabled).
Ember-Moth pushed a commit to Ember-Moth/new-api that referenced this pull request Jun 7, 2026
SamuelSxy pushed a commit to SamuelSxy/new-api-rh that referenced this pull request Jun 7, 2026
ljdzxx pushed a commit to ljdzxx/new-api that referenced this pull request Jun 13, 2026
OuYang-HX pushed a commit to OuYang-HX/new-api that referenced this pull request Jun 13, 2026
ruanhangjian pushed a commit to ruanhangjian/new-api that referenced this pull request Jul 11, 2026
330079598 pushed a commit to 330079598/new-api that referenced this pull request Aug 19, 2026
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 participants