Skip to content

Commit 36ef733

Browse files
author
Motta Kin
committed
Update documentation for LiteLLM; fix tests
1 parent 3a708e3 commit 36ef733

File tree

3 files changed

+11
-45
lines changed

3 files changed

+11
-45
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/models/cassettes/test_model_names/test_known_model_names.yaml

Lines changed: 7 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -99,53 +99,19 @@ interactions:
9999
alt-svc:
100100
- h3=":443"; ma=86400
101101
content-length:
102-
- '762'
102+
- '99'
103103
content-type:
104104
- application/json
105105
referrer-policy:
106106
- strict-origin-when-cross-origin
107107
strict-transport-security:
108108
- max-age=3600; includeSubDomains
109109
parsed_body:
110-
data:
111-
- created: 0
112-
id: llama-4-maverick-17b-128e-instruct
113-
object: model
114-
owned_by: Cerebras
115-
- created: 0
116-
id: qwen-3-32b
117-
object: model
118-
owned_by: Cerebras
119-
- created: 0
120-
id: qwen-3-235b-a22b-instruct-2507
121-
object: model
122-
owned_by: Cerebras
123-
- created: 0
124-
id: llama-4-scout-17b-16e-instruct
125-
object: model
126-
owned_by: Cerebras
127-
- created: 0
128-
id: gpt-oss-120b
129-
object: model
130-
owned_by: Cerebras
131-
- created: 0
132-
id: qwen-3-coder-480b
133-
object: model
134-
owned_by: Cerebras
135-
- created: 0
136-
id: llama-3.3-70b
137-
object: model
138-
owned_by: Cerebras
139-
- created: 0
140-
id: llama3.1-8b
141-
object: model
142-
owned_by: Cerebras
143-
- created: 0
144-
id: qwen-3-235b-a22b-thinking-2507
145-
object: model
146-
owned_by: Cerebras
147-
object: list
110+
code: wrong_api_key
111+
message: Wrong API Key
112+
param: api_key
113+
type: invalid_request_error
148114
status:
149-
code: 200
150-
message: OK
115+
code: 401
116+
message: Unauthorized
151117
version: 1

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)