Merge pull request #1779 from dnnspaul/main

Enable usage of OpenAI like APIs
This commit is contained in:
Tal
2025-05-16 16:59:18 +03:00
committed by GitHub
2 changed files with 18 additions and 0 deletions

View File

@ -16,6 +16,23 @@ You can give parameters via a configuration file, or from environment variables.
See [litellm documentation](https://litellm.vercel.app/docs/proxy/quick_start#supported-llms) for the environment variables needed per model, as they may vary and change over time. Our documentation per-model may not always be up-to-date with the latest changes.
Failing to set the needed keys of a specific model will usually result in litellm not identifying the model type, and failing to utilize it.
### OpenAI like API
To use an OpenAI like API, set the following in your `.secrets.toml` file:
```toml
[openai]
api_base = "https://api.openai.com/v1"
api_key = "sk-..."
```
or use the environment variables (make sure to use double underscores `__`):
```bash
OPENAI__API_BASE=https://api.openai.com/v1
OPENAI__KEY=sk-...
```
### Azure
To use Azure, set in your `.secrets.toml` (working from CLI), or in the GitHub `Settings > Secrets and variables` (working from GitHub App or GitHub Action):

View File

@ -59,6 +59,7 @@ class LiteLLMAIHandler(BaseAiHandler):
litellm.api_version = get_settings().openai.api_version
if get_settings().get("OPENAI.API_BASE", None):
litellm.api_base = get_settings().openai.api_base
self.api_base = get_settings().openai.api_base
if get_settings().get("ANTHROPIC.KEY", None):
litellm.anthropic_key = get_settings().anthropic.key
if get_settings().get("COHERE.KEY", None):