Skip to content

Commit 8fcf8c9

Browse files
Add placeholder API key for OpenAI compatible models (#929)
Co-authored-by: David Montague <[email protected]>
1 parent df68932 commit 8fcf8c9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pydantic_ai_slim/pydantic_ai/models/openai.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ def __init__(
119119
"""
120120
self._model_name = model_name
121121
# This is a workaround for the OpenAI client requiring an API key, whilst locally served,
122-
# openai compatible models do not always need an API key.
122+
# openai compatible models do not always need an API key, but a placeholder (non-empty) key is required.
123123
if api_key is None and 'OPENAI_API_KEY' not in os.environ and base_url is not None and openai_client is None:
124-
api_key = ''
124+
api_key = 'api-key-not-set'
125125

126126
if openai_client is not None:
127127
assert http_client is None, 'Cannot provide both `openai_client` and `http_client`'

0 commit comments

Comments
 (0)