Skip to content

[Frontend] Add cache_salt support to Anthropic Messages API - #49498

Merged
DarkLight1337 merged 4 commits into
vllm-project:mainfrom
aeon-x:feat/anthropic-cache-salt
Aug 1, 2026
Merged

DarkLight1337 merged 4 commits into
vllm-project:mainfrom
aeon-x:feat/anthropic-cache-salt

Conversation

@aeon-x

@aeon-x aeon-x commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Purpose

Closes #46688.

The OpenAI-compatible Chat Completions / Completions APIs accept a cache_salt
for explicit prefix-cache isolation in multi-user deployments. The Anthropic
Messages API (/v1/messages) did not expose it, so clients built on the
Anthropic schema had to switch API formats just to get deterministic
prefix-cache isolation.

Change

  • Add cache_salt: str | None to AnthropicMessagesRequest, with the same
    description as the OpenAI chat field.
  • Pass it through _build_base_request into the internal
    ChatCompletionRequest, which already owns the field and its
    check_cache_salt_support validator — so validation and engine behavior
    match the OpenAI routes exactly.

Only the Messages (generation) path is affected; AnthropicCountTokensRequest
is untouched (no generation, no prefix-cache isolation concern). Behavior is
unchanged when cache_salt is omitted (defaults to None).

Test

tests/entrypoints/anthropic/test_anthropic_messages_conversion.py::TestCacheSalt:

  • cache_salt on the Anthropic request reaches the converted
    ChatCompletionRequest.
  • omitting it leaves the field None (unchanged default).

Note: I was unable to run the suite locally (no CUDA/torch on my dev machine);
the files pass py_compile and the change mirrors the existing
kv_transfer_params pass-through — relying on CI to execute the tests.

The OpenAI-compatible Chat/Completions APIs accept a `cache_salt` for
explicit prefix-cache isolation in multi-user deployments, but the
Anthropic Messages API did not expose it, forcing clients on the
Anthropic schema to switch API formats to use it.

Add `cache_salt` to `AnthropicMessagesRequest` and thread it through
`_build_base_request` into the internal `ChatCompletionRequest` (which
already owns the field and its `check_cache_salt_support` validator),
mirroring the existing `kv_transfer_params` pass-through. Behavior is
unchanged when the field is omitted.

Fixes vllm-project#46688

Signed-off-by: aeon-x <talexcao@gmail.com>

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@mergify mergify Bot added the frontend label Jul 23, 2026
@aeon-x

aeon-x commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Hey @DarkLight1337 @robertgshaw2-redhat @aarnphm @NickLucche @AndreasKaratzas @mgoin

Can help take a look at this PR? Thanks a lot.

@AndreasKaratzas

Copy link
Copy Markdown
Member

PR looks alright, but since I dont see any comments on the RFC, I will wait for @DarkLight1337 to give the go/no-go.

@aeon-x

aeon-x commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

PR looks alright, but since I dont see any comments on the RFC, I will wait for @DarkLight1337 to give the go/no-go.

Thanks a lot for your review!

@DarkLight1337
DarkLight1337 enabled auto-merge (squash) August 1, 2026 04:33
@github-actions github-actions Bot added the ready ONLY add when PR is ready to merge/full CI is needed label Aug 1, 2026
@DarkLight1337
DarkLight1337 merged commit 81a42d3 into vllm-project:main Aug 1, 2026
62 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend ready ONLY add when PR is ready to merge/full CI is needed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add cache_salt support for Anthropic Messages API

3 participants