Skip to content

Commit 6df3018

Browse files
authored
Bump openai to v2.9.0 (#3708)
1 parent ba58119 commit 6df3018

File tree

5 files changed

+21
-24
lines changed

5 files changed

+21
-24
lines changed

pydantic_ai_slim/pydantic_ai/models/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@
314314
'gateway/openai:gpt-5.1-chat-latest',
315315
'gateway/openai:gpt-5.1-codex',
316316
'gateway/openai:gpt-5.1-mini',
317+
'gateway/openai:gpt-5.1-codex-max',
317318
'gateway/openai:o1',
318319
'gateway/openai:o1-2024-12-17',
319320
'gateway/openai:o1-mini',
@@ -489,6 +490,7 @@
489490
'openai:gpt-5.1-chat-latest',
490491
'openai:gpt-5.1-codex',
491492
'openai:gpt-5.1-mini',
493+
'openai:gpt-5.1-codex-max',
492494
'openai:o1',
493495
'openai:o1-2024-12-17',
494496
'openai:o1-mini',

pydantic_ai_slim/pydantic_ai/models/openai.py

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from contextlib import asynccontextmanager
99
from dataclasses import dataclass, field, replace
1010
from datetime import datetime
11-
from typing import TYPE_CHECKING, Any, Literal, cast, overload
11+
from typing import Any, Literal, cast, overload
1212

1313
from pydantic import ValidationError
1414
from pydantic_core import to_json
@@ -55,7 +55,7 @@
5555
from . import Model, ModelRequestParameters, StreamedResponse, check_allow_model_requests, download_item, get_user_agent
5656

5757
try:
58-
from openai import NOT_GIVEN, APIConnectionError, APIStatusError, AsyncOpenAI, AsyncStream
58+
from openai import NOT_GIVEN, APIConnectionError, APIStatusError, AsyncOpenAI, AsyncStream, Omit, omit
5959
from openai.types import AllModels, chat, responses
6060
from openai.types.chat import (
6161
ChatCompletionChunk,
@@ -90,28 +90,14 @@
9090
from openai.types.responses.response_status import ResponseStatus
9191
from openai.types.shared import ReasoningEffort
9292
from openai.types.shared_params import Reasoning
93+
94+
OMIT = omit
9395
except ImportError as _import_error:
9496
raise ImportError(
9597
'Please install `openai` to use the OpenAI model, '
9698
'you can use the `openai` optional group — `pip install "pydantic-ai-slim[openai]"`'
9799
) from _import_error
98100

99-
if TYPE_CHECKING:
100-
from openai import Omit, omit
101-
102-
OMIT = omit
103-
else:
104-
# Backward compatibility with openai<2
105-
try:
106-
from openai import Omit, omit
107-
108-
OMIT = omit
109-
except ImportError: # pragma: lax no cover
110-
from openai import NOT_GIVEN, NotGiven
111-
112-
OMIT = NOT_GIVEN
113-
Omit = NotGiven
114-
115101

116102
__all__ = (
117103
'OpenAIModel',

pydantic_ai_slim/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ dependencies = [
6767
# WARNING if you add optional groups, please update docs/install.md
6868
logfire = ["logfire[httpx]>=3.14.1"]
6969
# Models
70-
openai = ["openai>=1.107.2"]
70+
openai = ["openai>=2.9.0"]
7171
cohere = ["cohere>=5.18.0; platform_system != 'Emscripten'"]
7272
vertexai = ["google-auth>=2.36.0", "requests>=2.32.2"]
7373
google = ["google-genai>=1.51.0"]

tests/models/test_model_names.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,16 @@ def get_model_names(model_name_type: Any) -> Iterator[str]:
9595
generated_names = sorted(all_generated_names + gateway_names + heroku_names + cerebras_names + extra_names)
9696

9797
known_model_names = sorted(get_args(KnownModelName.__value__))
98-
assert generated_names == known_model_names
98+
99+
if generated_names != known_model_names:
100+
errors: list[str] = []
101+
missing_names = set(generated_names) - set(known_model_names)
102+
if missing_names:
103+
errors.append(f'Missing names: {missing_names}')
104+
extra_names = set(known_model_names) - set(generated_names)
105+
if extra_names:
106+
errors.append(f'Extra names: {extra_names}')
107+
raise AssertionError('\n'.join(errors))
99108

100109

101110
class HerokuModel(TypedDict):

uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)