Skip to content

Commit dc5650e

Browse files
authored
Revert "fix: remove anthropic-beta header for Vertex AI requests with prompt caching" (#14421)
1 parent f3c5a59 commit dc5650e

File tree

3 files changed

+3
-144
lines changed

3 files changed

+3
-144
lines changed

litellm/llms/anthropic/common_utils.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,8 @@ def get_anthropic_headers(
107107
user_anthropic_beta_headers: Optional[List[str]] = None,
108108
) -> dict:
109109
betas = set()
110-
# Note: prompt-caching-2024-07-31 header is no longer required for prompt caching
111-
# as per current Anthropic documentation. It's now generally available.
112-
# if prompt_caching_set:
113-
# betas.add("prompt-caching-2024-07-31")
110+
if prompt_caching_set:
111+
betas.add("prompt-caching-2024-07-31")
114112
if computer_tool_used:
115113
betas.add("computer-use-2024-10-22")
116114
# if pdf_used:
@@ -178,11 +176,6 @@ def validate_environment(
178176
mcp_server_used=mcp_server_used,
179177
)
180178

181-
# For Vertex AI requests, remove any user-provided anthropic-beta headers
182-
# since Vertex AI rejects them and they're no longer required for prompt caching
183-
if optional_params.get("is_vertex_request", False):
184-
headers = {k: v for k, v in headers.items() if k != "anthropic-beta"}
185-
186179
headers = {**headers, **anthropic_headers}
187180

188181
return headers

tests/litellm/llms/anthropic/test_vertex_ai_prompt_caching_fix.py

Lines changed: 0 additions & 134 deletions
This file was deleted.

tests/test_litellm/llms/vertex_ai/test_vertex.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import litellm.litellm_core_utils.prompt_templates.factory
1111

1212
load_dotenv()
13-
from unittest.mock import MagicMock, patch
13+
from unittest.mock import MagicMock
1414

1515
sys.path.insert(
1616
0, os.path.abspath("../..")

0 commit comments

Comments
 (0)