Skip to content

Commit 6b2eb48

Browse files
author
Motta Kin
committed
Update documentation for LiteLLM; fix tests
1 parent 000d367 commit 6b2eb48

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

docs/models/openai.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ print(result.output)
566566

567567
### LiteLLM
568568

569-
To use [LiteLLM](https://www.litellm.ai/), set the configs as outlined in the [doc](https://docs.litellm.ai/docs/set_keys). What specific configs you need to set depends on your setup. For example, if you are using a LiteLLM proxy server, then you need to set the `api_base` and `api_key` configs.
569+
To use [LiteLLM](https://www.litellm.ai/), set the configs as outlined in the [doc](https://docs.litellm.ai/docs/set_keys). In `LiteLLMProvider`, you can pass `api_base` and `api_key`. The value of these configs will depend on your setup. For example, if you are using OpenAI models, then you need to pass `https://api.openai.com/v1` as the `api_base` and your OpenAI API key as the `api_key`. If you are using a LiteLLM proxy server running on your local machine, then you need to pass `http://localhost:<port>` as the `api_base` and your LiteLLM API key as the `api_key`.
570570

571571
Once you have the configs, use the [`LiteLLMProvider`][pydantic_ai.providers.litellm.LiteLLMProvider] as follows:
572572

@@ -578,13 +578,14 @@ from pydantic_ai.providers.litellm import LiteLLMProvider
578578
model = OpenAIChatModel(
579579
'openai/gpt-3.5-turbo',
580580
provider=LiteLLMProvider(
581-
api_base='<litellm-api-base-url>',
582-
api_key='<litellm-api-key>'
581+
api_base='<api-base-url>',
582+
api_key='<api-key>'
583583
)
584584
)
585585
agent = Agent(model)
586586

587587
result = agent.run_sync('What is the capital of France?')
588588
print(result.output)
589+
#> The capital of France is Paris.
589590
...
590591
```

tests/providers/test_litellm.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def test_init_with_custom_llm_provider():
3030
def test_init_without_api_key():
3131
provider = LiteLLMProvider()
3232
assert provider.name == 'litellm'
33-
assert provider.base_url == 'https://api.litellm.ai/v1/'
3433
assert provider.client.api_key == 'litellm-placeholder'
3534

3635

0 commit comments

Comments
 (0)