From 576cccaade4395f1242f9c4de02dbd21a2d7a1d9 Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Sat, 20 Jul 2024 14:37:59 -0700 Subject: [PATCH] fix(main.py): check for ANTHROPIC_BASE_URL in environment Fixes https://github.com/BerriAI/litellm/issues/4803 --- docs/my-website/docs/providers/anthropic.md | 1 + litellm/main.py | 2 ++ 2 files changed, 3 insertions(+) diff --git a/docs/my-website/docs/providers/anthropic.md b/docs/my-website/docs/providers/anthropic.md index 8d1d02fa4..deb640b17 100644 --- a/docs/my-website/docs/providers/anthropic.md +++ b/docs/my-website/docs/providers/anthropic.md @@ -22,6 +22,7 @@ Anthropic API fails requests when `max_tokens` are not passed. Due to this litel import os os.environ["ANTHROPIC_API_KEY"] = "your-api-key" +# os.environ["ANTHROPIC_API_BASE"] = "" # [OPTIONAL] or 'ANTHROPIC_BASE_URL' ``` ## Usage diff --git a/litellm/main.py b/litellm/main.py index 628349d09..7e0e534ad 100644 --- a/litellm/main.py +++ b/litellm/main.py @@ -1487,6 +1487,7 @@ def completion( api_base or litellm.api_base or get_secret("ANTHROPIC_API_BASE") + or get_secret("ANTHROPIC_BASE_URL") or "https://api.anthropic.com/v1/complete" ) response = anthropic_text_completions.completion( @@ -1512,6 +1513,7 @@ def completion( api_base or litellm.api_base or get_secret("ANTHROPIC_API_BASE") + or get_secret("ANTHROPIC_BASE_URL") or "https://api.anthropic.com/v1/messages" ) response = anthropic_chat_completions.completion(