Skip to content

Commit bee95f5

Browse files
hrahmadi71Kludex
andauthored
fix: Update OpenAIProvider to use environment variable for base URL (#1117)
Co-authored-by: Marcelo Trylesinski <[email protected]>
1 parent 56d28a7 commit bee95f5

File tree

1 file changed

+1
-1
lines changed
  • pydantic_ai_slim/pydantic_ai/providers

1 file changed

+1
-1
lines changed

pydantic_ai_slim/pydantic_ai/providers/openai.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def __init__(
5555
client to use. If provided, `base_url`, `api_key`, and `http_client` must be `None`.
5656
http_client: An existing `httpx.AsyncClient` to use for making HTTP requests.
5757
"""
58-
self._base_url = base_url or 'https://api.openai.com/v1'
58+
self._base_url = base_url or os.getenv('OPENAI_BASE_URL', 'https://api.openai.com/v1')
5959
# This is a workaround for the OpenAI client requiring an API key, whilst locally served,
6060
# openai compatible models do not always need an API key, but a placeholder (non-empty) key is required.
6161
if api_key is None and 'OPENAI_API_KEY' not in os.environ and openai_client is None:

0 commit comments

Comments
 (0)