Closed
Description
Initial Checks
- I confirm that I'm using the latest version of Pydantic AI
Description
When creating a new instance of OpenAIProvider
like this:
provider = OpenAIProvider()
If the OPENAI_BASE_URL
environment variable is set, it is expected that provider.base_url
should reflect that value. However, it is not being read from the environment variables, and instead, provider.base_url
defaults to 'https://api.openai.com/v1'
.
Example Code
import os
from pydantic_ai.providers.openai import OpenAIProvider
# Set the environment variable
custom_openai_base_url = "https://custom-openai.com/v1"
os.environ["OPENAI_BASE_URL"] = custom_openai_base_url
# Create an instance of OpenAIProvider
provider = OpenAIProvider()
# Check if the base_url is set correctly
print(f"Expected: {custom_openai_base_url}")
print(f"Actual: {provider.base_url}")
Python, Pydantic AI & LLM client version
0.0.39