From b1c73157e0202be80f6d769aa26f5717cb4ea3ac Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Thu, 20 Aug 2026 04:04:26 -0700 Subject: [PATCH 1/2] docs(anthropic_unified): document metadata.user_id to prompt_cache_key mapping The /v1/messages bridge now derives OpenAI's prompt_cache_key from metadata.user_id alongside user, capped at 64 characters. Adds the row to the Responses mapping table and a note on the chat-completions path, where the key is only set for providers that support it, plus the client-sent override --- docs/anthropic_unified/messages_to_responses_mapping.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/anthropic_unified/messages_to_responses_mapping.md b/docs/anthropic_unified/messages_to_responses_mapping.md index 87188c363b..c84de1ceaa 100644 --- a/docs/anthropic_unified/messages_to_responses_mapping.md +++ b/docs/anthropic_unified/messages_to_responses_mapping.md @@ -24,10 +24,13 @@ The transformation lives in `litellm/llms/anthropic/experimental_pass_through/re | `output_format` or `output_config.format` | `text` | Wrapped as `{"format": {"type": "json_schema", "name": "structured_output", "schema": ..., "strict": true}}` | | `context_management` | `context_management` | Converted from Anthropic dict to OpenAI array format — see the context_management section below | | `metadata.user_id` | `user` | Extracted from the metadata object and truncated to 64 characters | +| `metadata.user_id` | `prompt_cache_key` | Same value, truncated to 64 characters (OpenAI's key limit), so one user's requests keep hitting the same prompt cache. Not set when `user_id` is empty or null. A `prompt_cache_key` sent in the request body wins over the derived one | | `stop_sequences` | ❌ Not mapped | Dropped silently | | `top_k` | ❌ Not mapped | Dropped silently | | `speed` | ❌ Not mapped | Only used to set Anthropic beta headers on the native path | +The chat-completions path (`litellm_settings.use_chat_completions_url_for_anthropic_messages: true`, and every non-OpenAI provider) derives the same two parameters from `metadata.user_id`, with two differences: `user` is passed through untruncated, and `prompt_cache_key` is only set when the target provider's supported params include it. OpenAI, Azure OpenAI and other OpenAI-compatible providers do; Gemini, Vertex AI, Bedrock and Anthropic do not. + ### How messages get converted From dff3633a3f7c6601b54d32451095a32f6e15d341 Mon Sep 17 00:00:00 2001 From: mateo-berri <277851410+mateo-berri@users.noreply.github.com> Date: Thu, 20 Aug 2026 04:37:50 -0700 Subject: [PATCH 2/2] docs(anthropic_unified): note litellm_proxy deployments never get the derived prompt_cache_key --- docs/anthropic_unified/messages_to_responses_mapping.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/anthropic_unified/messages_to_responses_mapping.md b/docs/anthropic_unified/messages_to_responses_mapping.md index c84de1ceaa..d99f0c7da7 100644 --- a/docs/anthropic_unified/messages_to_responses_mapping.md +++ b/docs/anthropic_unified/messages_to_responses_mapping.md @@ -29,7 +29,7 @@ The transformation lives in `litellm/llms/anthropic/experimental_pass_through/re | `top_k` | ❌ Not mapped | Dropped silently | | `speed` | ❌ Not mapped | Only used to set Anthropic beta headers on the native path | -The chat-completions path (`litellm_settings.use_chat_completions_url_for_anthropic_messages: true`, and every non-OpenAI provider) derives the same two parameters from `metadata.user_id`, with two differences: `user` is passed through untruncated, and `prompt_cache_key` is only set when the target provider's supported params include it. OpenAI, Azure OpenAI and other OpenAI-compatible providers do; Gemini, Vertex AI, Bedrock and Anthropic do not. +The chat-completions path (`litellm_settings.use_chat_completions_url_for_anthropic_messages: true`, and every non-OpenAI provider) derives the same two parameters from `metadata.user_id`, with two differences: `user` is passed through untruncated, and `prompt_cache_key` is only set when the target provider's supported params include it. OpenAI, Azure OpenAI and other OpenAI-compatible providers do; Gemini, Vertex AI, Bedrock and Anthropic do not. `litellm_proxy/` deployments (one LiteLLM proxy in front of another) never get the derived key, because the downstream proxy's real provider is unknown and would reject it unless `drop_params` is set there. ### How messages get converted