fix(main.py): check for ANTHROPIC_BASE_URL in environment

Fixes https://github.com/BerriAI/litellm/issues/4803
This commit is contained in:
Krrish Dholakia 2024-07-20 14:37:59 -07:00
parent 9dc10f97a6
commit 576cccaade
2 changed files with 3 additions and 0 deletions

View file

@ -22,6 +22,7 @@ Anthropic API fails requests when `max_tokens` are not passed. Due to this litel
import os import os
os.environ["ANTHROPIC_API_KEY"] = "your-api-key" os.environ["ANTHROPIC_API_KEY"] = "your-api-key"
# os.environ["ANTHROPIC_API_BASE"] = "" # [OPTIONAL] or 'ANTHROPIC_BASE_URL'
``` ```
## Usage ## Usage

View file

@ -1487,6 +1487,7 @@ def completion(
api_base api_base
or litellm.api_base or litellm.api_base
or get_secret("ANTHROPIC_API_BASE") or get_secret("ANTHROPIC_API_BASE")
or get_secret("ANTHROPIC_BASE_URL")
or "https://api.anthropic.com/v1/complete" or "https://api.anthropic.com/v1/complete"
) )
response = anthropic_text_completions.completion( response = anthropic_text_completions.completion(
@ -1512,6 +1513,7 @@ def completion(
api_base api_base
or litellm.api_base or litellm.api_base
or get_secret("ANTHROPIC_API_BASE") or get_secret("ANTHROPIC_API_BASE")
or get_secret("ANTHROPIC_BASE_URL")
or "https://api.anthropic.com/v1/messages" or "https://api.anthropic.com/v1/messages"
) )
response = anthropic_chat_completions.completion( response = anthropic_chat_completions.completion(