From e7b28526aa737c9000a7da542f38c1bd246e5285 Mon Sep 17 00:00:00 2001 From: Xiaohan Wang Date: Sun, 4 Feb 2024 00:26:02 +0000 Subject: [PATCH] add required header anthropic-version for AnthropicProvider Signed-off-by: Xiaohan Wang --- mlflow/gateway/providers/anthropic.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mlflow/gateway/providers/anthropic.py b/mlflow/gateway/providers/anthropic.py index 808e4fb14470c..1a240ceac6313 100644 --- a/mlflow/gateway/providers/anthropic.py +++ b/mlflow/gateway/providers/anthropic.py @@ -104,7 +104,10 @@ def __init__(self, config: RouteConfig) -> None: if config.model.config is None or not isinstance(config.model.config, AnthropicConfig): raise TypeError(f"Invalid config type {config.model.config}") self.anthropic_config: AnthropicConfig = config.model.config - self.headers = {"x-api-key": self.anthropic_config.anthropic_api_key} + self.headers = { + "x-api-key": self.anthropic_config.anthropic_api_key, + "anthropic-version": "2023-06-01", + } self.base_url = "https://api.anthropic.com/v1/" async def completions(self, payload: completions.RequestPayload) -> completions.ResponsePayload: