Skip to content

Add Anthropic Claude Opus 5 API support - #1026

Merged
PeterDaveHello merged 1 commit into
ChatGPTBox-dev:masterfrom
PeterDaveHello:add-claude-opus-5
Jul 26, 2026
Merged

Add Anthropic Claude Opus 5 API support#1026
PeterDaveHello merged 1 commit into
ChatGPTBox-dev:masterfrom
PeterDaveHello:add-claude-opus-5

Conversation

@PeterDaveHello

@PeterDaveHello PeterDaveHello commented Jul 25, 2026

Copy link
Copy Markdown
Member

Expose Claude Opus 5 through the Anthropic API model list using the official claude-opus-5 model identifier.

Changes

  • Register Claude Opus 5 and add its English display label.
  • Make Claude Opus 5 the default Opus-tier API option while keeping Claude Opus 4.8 selectable.
  • Preserve Claude Opus 5's default adaptive thinking behavior.
  • Omit the unsupported custom temperature parameter from Claude Opus 5 requests.
  • Extend the parameterized Claude API request-shaping test for Opus 5.

Validation

  • npm run lint
  • npm test (932 tests passed)
  • npm run build

References

Summary by CodeRabbit

  • New Features

    • Added support for the Anthropic Claude Opus 5 model.
    • Claude Opus 5 is now available as a default active model with localized labeling.
  • Bug Fixes

    • Requests to Claude Opus 5 no longer include unsupported custom temperature settings.
  • Tests

    • Added coverage verifying correct Claude Opus 5 request behavior.

@PeterDaveHello
PeterDaveHello requested a review from Copilot July 25, 2026 19:38
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Claude Opus 5 is added to the model registry, default API modes, English localization, and Claude API request handling. Temperature omission behavior is covered by a parameterized unit test.

Changes

Claude Opus 5 support

Layer / File(s) Summary
Register Claude Opus 5
src/config/index.mjs, src/_locales/en/main.json
Adds the claudeOpus5Api model key, provider identifier, default API mode, and English label.
Apply Claude request rules
src/services/apis/claude-api.mjs, tests/unit/services/apis/claude-api.test.mjs
Omits temperature for claude-opus-5 requests and adds corresponding test coverage.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

Suggested labels: Review effort 1/5

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding Anthropic Claude Opus 5 API support.
✨ 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.

@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Add Anthropic Claude Opus 5 API model with default + legacy migrations

✨ Enhancement 🧪 Tests ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Expose Claude Opus 5 in Anthropic model selection using the official model id.
• Make Opus 5 the default Opus-tier option and migrate legacy Opus keys automatically.
• Align Claude API request shaping and unit tests with Opus 5 thinking/temperature rules.
Diagram

graph TD
  A["Settings / Model Picker"] --> B["Config: Models + Defaults"] --> C(["Claude API Client"]) --> D{{"Anthropic API"}}
  B --> E["Model Key Migrations"]
  A --> F["en Locale Labels"]
  C --> G["Claude API Unit Tests"]

  subgraph Legend
    direction LR
    _ui["UI/Config"] ~~~ _svc(["Service"]) ~~~ _ext{{"External"}}
  end
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Capability-driven model metadata (no hardcoded model string checks)
  • ➕ Avoids scattering model-id string comparisons across request-building logic
  • ➕ Makes adding future Claude variants a data/config change instead of code edits
  • ➕ Reduces risk of forgetting to update behavior gates (temperature/thinking) when adding models
  • ➖ Requires a small refactor to define and plumb capabilities into the request builder
  • ➖ Slightly more up-front complexity than the current targeted change
2. Pattern-based gating by family/tier (e.g., opus-5/sonnet-5 rules)
  • ➕ Fewer explicit model ids to maintain in code
  • ➕ Quick to implement for closely related model families
  • ➖ Can accidentally capture models that don’t share the same API constraints
  • ➖ Harder to reason about than explicit capability flags

Recommendation: For this PR’s scope, the explicit gating for 'claude-opus-5' alongside existing Sonnet 5 behavior is reasonable and low-risk, especially with tests. If more Claude 5.* variants are expected, consider migrating to a capability-driven model metadata table so request shaping (temperature/thinking) is declarative and centralized.

Files changed (5) +20 / -6

Enhancement (2) +8 / -2
main.jsonAdd English display label for Claude Opus 5 +1/-0

Add English display label for Claude Opus 5

• Introduces the 'Anthropic (Claude Opus 5)' localized label so the new model renders consistently in the UI.

src/_locales/en/main.json

claude-api.mjsApply Opus 5 request constraints (omit temperature, disable default thinking) +7/-2

Apply Opus 5 request constraints (omit temperature, disable default thinking)

• Extends request-shaping rules to treat 'claude-opus-5' like Sonnet 5: omit custom temperature and disable default thinking behavior where required.

src/services/apis/claude-api.mjs

Tests (1) +2 / -1
claude-api.test.mjsAdd Opus 5 coverage to temperature/thinking request tests +2/-1

Add Opus 5 coverage to temperature/thinking request tests

• Expands the unit test matrix to include claudeOpus5Api and asserts the expected payload behavior for Opus 5 (no temperature, thinking disabled).

tests/unit/services/apis/claude-api.test.mjs

Other (2) +10 / -3
index.mjsRegister claudeOpus5Api and make it the default Opus-tier model +6/-1

Register claudeOpus5Api and make it the default Opus-tier model

• Adds 'claudeOpus5Api' to the Claude API model key list and registers its official Anthropic model identifier 'claude-opus-5'. Updates the default API model ids to prefer Opus 5 over Opus 4.8.

src/config/index.mjs

model-key-migrations.mjsMigrate legacy Opus model keys to claudeOpus5Api +4/-2

Migrate legacy Opus model keys to claudeOpus5Api

• Updates legacy model key migrations so older Opus keys (including claudeOpus48Api) map to claudeOpus5Api. Ensures the new key is treated as part of the claudeApiModelKeys group for consistent handling.

src/config/model-key-migrations.mjs

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds Anthropic Claude Opus 5 as a selectable Anthropic API model in the extension’s model registry, aligning request-shaping behavior with existing Claude Sonnet 5 handling and updating defaults/migrations so existing users move to the new Opus-tier model smoothly.

Changes:

  • Register claudeOpus5Api (claude-opus-5) in the Claude API model key list and Models, and switch the default Opus-tier API mode to Opus 5.
  • Update Claude API request construction to omit temperature and explicitly disable thinking for Opus 5 (matching Sonnet 5 behavior).
  • Add legacy migration mapping so claudeOpus48Api (and older Opus legacy keys) canonicalize to claudeOpus5Api, plus add the display label to the English locale.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
tests/unit/services/apis/claude-api.test.mjs Extends coverage to ensure Opus 5 omits temperature and applies the same thinking-disable behavior as Sonnet 5.
src/services/apis/claude-api.mjs Adds Opus 5 to the model-based rules for omitting temperature and disabling default thinking in Anthropic API requests.
src/config/model-key-migrations.mjs Migrates legacy Opus keys (including claudeOpus48Api) to Opus 5 and ensures the model key group stays consistent.
src/config/index.mjs Registers claudeOpus5Api in available Claude API models, adds the model preset, and updates the default API mode selection from Opus 4.8 to Opus 5.
src/_locales/en/main.json Adds the English label for “Anthropic (Claude Opus 5)” so it renders consistently in the UI.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@qodo-code-review

qodo-code-review Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 5 rules

Grey Divider


Action required

1. Opus 4.8 auto-migrated ✓ Resolved 🐞 Bug ≡ Correctness
Description
The migration map treats the still-supported model key 'claudeOpus48Api' as legacy and rewrites it
to 'claudeOpus5Api'. Since canonicalization runs when reading config and when loading/persisting
sessions, users cannot persistently select Opus 4.8 and existing Opus 4.8 sessions/configs will be
silently changed to Opus 5.
Code

src/config/model-key-migrations.mjs[31]

+  claudeOpus48Api: 'clau********pi',
Evidence
The migration table explicitly rewrites claudeOpus48Api to claudeOpus5Api, while the
configuration still defines claudeOpus48Api as an available Anthropic model and includes it in the
Anthropic model key list. The app then applies canonicalization during config migration and while
loading sessions, meaning any stored/selected claudeOpus48Api will be replaced and persisted as
Opus 5.

src/config/model-key-migrations.mjs[1-33]
src/config/index.mjs[88-99]
src/config/index.mjs[347-387]
src/config/index.mjs[1197-1228]
src/config/model-key-migrations.mjs[141-156]
src/services/local-session.mjs[71-79]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
`LEGACY_MODEL_KEY_MIGRATIONS` maps `claudeOpus48Api` to `claudeOpus5Api`, but `claudeOpus48Api` is still a supported, selectable model (it exists in `Models` and `claudeApiModelKeys`). Because the app canonicalizes model keys on config/session load, this effectively prevents users from keeping Opus 4.8 selected and rewrites existing sessions.

### Issue Context
Canonicalization is applied broadly (user config modelName/activeApiModes and stored sessions), so this is not a one-time migration; it will continually “correct” `claudeOpus48Api` to Opus 5.

### Fix Focus Areas
- src/config/model-key-migrations.mjs[1-53]
- src/config/index.mjs[88-99]
- src/config/index.mjs[347-387]
- src/config/index.mjs[1197-1228]
- src/services/local-session.mjs[71-79]

### Suggested fix
- Remove `claudeOpus48Api: 'clau********pi'` from `LEGACY_MODEL_KEY_MIGRATIONS` **if Opus 4.8 should remain selectable**.
- If Opus 4.8 must be deprecated, remove it from `Models` / `claudeApiModelKeys` (and UI labels) so the migration is consistent.
- Add/adjust a regression test to ensure selecting `claudeOpus48Api` remains stable across config reads (and sessions if applicable).

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment thread src/config/model-key-migrations.mjs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 7637455e0f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/config/model-key-migrations.mjs Outdated
Comment thread src/_locales/en/main.json
"Anthropic (Claude Opus 4.5)": "Anthropic (Claude Opus 4.5)",
"Anthropic (Claude Opus 4.6)": "Anthropic (Claude Opus 4.6)",
"Anthropic (Claude Opus 4.8)": "Anthropic (Claude Opus 4.8)",
"Anthropic (Claude Opus 5)": "Anthropic (Claude Opus 5)",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Propagate the new model label to every locale

When any of the 12 non-English locales is active, this new key is absent from that locale's catalog and only renders through the English fallback. Add the label to each existing locale as required for newly introduced English strings.

AGENTS.md reference: AGENTS.md:L209-L215

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

No change needed. Commit 1c976a3 intentionally removed redundant model labels from non-English locales because i18next falls back to English. Only labels with actual localization differences are kept, so the English entry is sufficient here.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/services/apis/claude-api.mjs`:
- Around line 17-18: Update shouldDisableDefaultThinking so claude-opus-5 is not
treated as disabled-thinking; send thinking type adaptive while preserving
claude-sonnet-5 behavior. Update the matching assertion in
tests/unit/services/apis/claude-api.test.mjs at line 163 to expect adaptive
thinking for claude-opus-5.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5a91ff7c-169f-4056-96d4-3d685a392f2b

📥 Commits

Reviewing files that changed from the base of the PR and between 0437980 and 5b2d6b3.

📒 Files selected for processing (5)
  • src/_locales/en/main.json
  • src/config/index.mjs
  • src/config/model-key-migrations.mjs
  • src/services/apis/claude-api.mjs
  • tests/unit/services/apis/claude-api.test.mjs

Comment thread src/services/apis/claude-api.mjs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 657a1d77ab

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/_locales/en/main.json Outdated

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/unit/config/migrate-user-config.test.mjs`:
- Around line 36-42: Update LEGACY_MODEL_KEY_MIGRATIONS so claudeOpus48Api
canonicalizes to claudeOpus5Api, then revise the canonicalizeModelKey test to
assert that migration and that claudeOpus5Api remains unchanged while preserving
the existing legacy migration assertions.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 957137ef-b629-43e7-8a67-fd8bc0086df1

📥 Commits

Reviewing files that changed from the base of the PR and between 5b2d6b3 and 657a1d7.

📒 Files selected for processing (5)
  • src/_locales/en/main.json
  • src/config/index.mjs
  • src/services/apis/claude-api.mjs
  • tests/unit/config/migrate-user-config.test.mjs
  • tests/unit/services/apis/claude-api.test.mjs

Comment thread tests/unit/config/migrate-user-config.test.mjs Outdated
Register `claude-opus-5` as the default Opus API preset while keeping
Claude Opus 4.8 available as a separate selectable model.

Let Opus 5 use its default adaptive thinking behavior and omit the
unsupported custom temperature parameter.

Add request-shaping regression coverage.

References:
- https://www.anthropic.com/claude-opus-5-system-card
- https://www.anthropic.com/news/claude-opus-5
- https://platform.claude.com/docs/en/about-claude/models/overview
- https://platform.claude.com/docs/en/about-claude/models/whats-new-opus-5

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 37aabfd409

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

model === 'claude-opus-4-7' ||
model === 'claude-opus-4-8' ||
model === 'claude-sonnet-5' ||
model === 'claude-opus-5'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Report Opus 5 token-budget exhaustion

When Opus 5's always-on adaptive thinking consumes max_tokens before emitting text—particularly with the default 2,000-token limit—the API reports stop_reason: "max_tokens" in a message_delta and then sends message_stop. The current handler ignores that stop reason, records an empty answer, and reports successful completion, leaving the user with no explanation or useful retry path. The current tree no longer contains the token-limit handling referenced by the earlier localization review comment, so this remains a runtime issue for the newly exposed model.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This is valid, but the handling is not specific to Opus 5. It affects Claude streaming responses generally and requires broader stop-reason and error-propagation coverage. It will be addressed in a focused follow-up change rather than expanding this model-registration PR.

@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 37aabfd

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@PeterDaveHello
PeterDaveHello merged commit 10172ed into ChatGPTBox-dev:master Jul 26, 2026
4 checks passed
@PeterDaveHello
PeterDaveHello deleted the add-claude-opus-5 branch July 26, 2026 16:22
PeterDaveHello added a commit to PeterDaveHello/chatGPTBox that referenced this pull request Jul 27, 2026
Report token-limit and refusal stop reasons instead of treating
incomplete responses as successful completions. Require message_stop
before accepting a stream while preserving explicit abort behavior.

Add localized errors and regression coverage for completion,
transport, callback, and abort edge cases.

Follow-up to ChatGPTBox-dev#1026.
PeterDaveHello added a commit to PeterDaveHello/chatGPTBox that referenced this pull request Jul 28, 2026
Report token-limit, context-window, and refusal stop reasons instead of
treating incomplete responses as successful completions. Require
`message_stop` before accepting a stream and preserve abort behavior.

Add localized errors and regression coverage for completion, transport,
callback, and abort edge cases.

Follow-up to ChatGPTBox-dev#1026.
PeterDaveHello added a commit to PeterDaveHello/chatGPTBox that referenced this pull request Jul 30, 2026
Reject token, context, refusal, and nonterminal stop conditions instead
of treating incomplete Claude responses as successful completions. Stop
processing once a response completes and surface streamed API errors
without undoing completed responses.

Add localized completion errors and regression coverage for stop
reasons, provider errors, transport failures, callbacks, and aborts.

Follow-up to ChatGPTBox-dev#1026.
PeterDaveHello added a commit to PeterDaveHello/chatGPTBox that referenced this pull request Jul 30, 2026
Reject token, context, refusal, and nonterminal stop conditions instead
of treating incomplete Claude responses as successful completions. Stop
processing once a response completes and surface streamed API errors
without undoing completed responses.

Add localized completion errors and regression coverage for stop
reasons, provider errors, transport failures, callbacks, and aborts.

Follow-up to ChatGPTBox-dev#1026.
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