forked from phoenix/litellm-mirror
feat: added support for OPENAI_API_BASE
This commit is contained in:
parent
2096f9c3bf
commit
ae52856a62
3 changed files with 7 additions and 5 deletions
|
@ -1,5 +1,6 @@
|
||||||
# OpenAI
|
# OpenAI
|
||||||
OPENAI_API_KEY = ""
|
OPENAI_API_KEY = ""
|
||||||
|
OPENAI_API_BASE = ""
|
||||||
# Cohere
|
# Cohere
|
||||||
COHERE_API_KEY = ""
|
COHERE_API_KEY = ""
|
||||||
# OpenRouter
|
# OpenRouter
|
||||||
|
@ -18,4 +19,4 @@ REPLICATE_API_TOKEN = ""
|
||||||
# Anthropic
|
# Anthropic
|
||||||
ANTHROPIC_API_KEY = ""
|
ANTHROPIC_API_KEY = ""
|
||||||
# Infisical
|
# Infisical
|
||||||
INFISICAL_TOKEN = ""
|
INFISICAL_TOKEN = ""
|
||||||
|
|
|
@ -17,6 +17,8 @@ liteLLM reads key naming, all keys should be named in the following format:
|
||||||
| gpt-3.5-turbo-16k-0613 | `completion('gpt-3.5-turbo-16k-0613', messages)` | `os.environ['OPENAI_API_KEY']` |
|
| gpt-3.5-turbo-16k-0613 | `completion('gpt-3.5-turbo-16k-0613', messages)` | `os.environ['OPENAI_API_KEY']` |
|
||||||
| gpt-4 | `completion('gpt-4', messages)` | `os.environ['OPENAI_API_KEY']` |
|
| gpt-4 | `completion('gpt-4', messages)` | `os.environ['OPENAI_API_KEY']` |
|
||||||
|
|
||||||
|
These also support the `OPENAI_API_BASE` environment variable, which can be used to specify a custom API endpoint.
|
||||||
|
|
||||||
### Azure OpenAI Chat Completion Models
|
### Azure OpenAI Chat Completion Models
|
||||||
|
|
||||||
| Model Name | Function Call | Required OS Variables |
|
| Model Name | Function Call | Required OS Variables |
|
||||||
|
|
|
@ -210,12 +210,11 @@ def completion(
|
||||||
): # allow user to make an openai call with a custom base
|
): # allow user to make an openai call with a custom base
|
||||||
openai.api_type = "openai"
|
openai.api_type = "openai"
|
||||||
# note: if a user sets a custom base - we should ensure this works
|
# note: if a user sets a custom base - we should ensure this works
|
||||||
|
# allow for the setting of dynamic and stateful api-bases
|
||||||
api_base = (
|
api_base = (
|
||||||
custom_api_base if custom_api_base is not None else litellm.api_base
|
custom_api_base or litellm.api_base or get_secret("OPENAI_API_BASE")
|
||||||
) # allow for the setting of dynamic and stateful api-bases
|
|
||||||
openai.api_base = (
|
|
||||||
api_base if api_base is not None else "https://api.openai.com/v1"
|
|
||||||
)
|
)
|
||||||
|
openai.api_base = api_base or "https://api.openai.com/v1"
|
||||||
openai.api_version = None
|
openai.api_version = None
|
||||||
if litellm.organization:
|
if litellm.organization:
|
||||||
openai.organization = litellm.organization
|
openai.organization = litellm.organization
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue