Skip to content

feat: support OpenAI 2 in Python client#806

Open
scale-ballen wants to merge 3 commits intomainfrom
codex/openai2-client-compat
Open

feat: support OpenAI 2 in Python client#806
scale-ballen wants to merge 3 commits intomainfrom
codex/openai2-client-compat

Conversation

@scale-ballen
Copy link
Copy Markdown
Contributor

@scale-ballen scale-ballen commented Apr 13, 2026

Summary

  • update the Python client to require Python 3.9+ and pin openai==2.8.0
  • regenerate the Poetry lockfile for the new dependency set
  • fix generated OpenAI Pydantic schemas so the client imports cleanly under the upgraded stack

What changed

  • clients/python/pyproject.toml
    • python: ^3.8 -> >=3.9,<4.0
    • openai: ^1.30.0 -> ==2.8.0
  • clients/python/setup.py
    • python_requires: >=3.8 -> >=3.9
  • clients/python/poetry.lock
    • relocked against openai 2.8.0
  • clients/python/llmengine/data_types/gen/openai.py
    • remove invalid min_items constraints from __root__ fields on Prompt1Item, Input2Item, QueryItem, and SearchQueryItem
    • remove the discriminator from InputItem's root union field

Why

egp-api-backend needs litellm==1.83.0, which in turn requires openai 2.x. The local blocker was this Python client package still constraining openai to 1.x. After widening the client dependency, the generated schema layer also needed cleanup before the package would import successfully.

Verification

  • PYENV_VERSION=3.11.14 poetry install
  • PYENV_VERSION=3.11.14 poetry run python -c "import llmengine; from llmengine import Completion, Model, FineTune; from llmengine.api_engine import APIEngine; print("ok")"
    • passed
  • import smoke confirmed Completion, Model, FineTune, and APIEngine import cleanly with the upgraded dependency set

Notes

  • This PR is intentionally limited to the Python client package.
  • I did not change the generated client surface beyond the schema fixes required to restore importability under the upgraded dependency stack.

Greptile Summary

This PR migrates the Python client from openai ^1.30 to openai >=2.8,<3.0, bumps the Python floor to 3.9, and repairs four generated schema classes in openai.py that were causing import failures under the upgraded stack. The previous concern about the exact-version pin has been addressed — the dependency is now expressed as a compatible range.

Confidence Score: 5/5

Safe to merge — all changes are minimal, correct, and verified by the import smoke test; no P0/P1 issues found.

The schema fixes are mechanically correct (validator replaces invalid Field constraint, min_items removed from non-list types, broken discriminator dropped with an explanatory comment). The dependency range is properly expressed. The prior concern about the exact-version pin has been resolved. All remaining findings are P2 or lower.

No files require special attention.

Important Files Changed

Filename Overview
clients/python/llmengine/data_types/gen/openai.py Fixes four schema models to be compatible with openai v2: replaces invalid min_items on __root__ list fields with @validator, removes min_items from two str root-fields where it was always a no-op, and removes an unworkable discriminator from InputItem; all changes are correct under pydantic v1 / v1-compat.
clients/python/pyproject.toml Widens Python floor to 3.9 and replaces the exact openai==2.8.0 pin with the range >=2.8.0,<3.0.0, which is appropriate for a library dependency.
clients/python/setup.py Aligns python_requires with pyproject.toml by bumping to >=3.9; straightforward and consistent.
clients/python/poetry.lock Lockfile regenerated to resolve against openai 2.x; no manual edits, machine-generated output.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["Prompt1Item / Input2Item\n__root__: List[int]"] --> B["Field() — no min_items"]
    B --> C["@validator('__root__')\nvalidate_non_empty"]
    C -->|empty list| D["ValueError raised"]
    C -->|non-empty list| E["value returned"]

    F["QueryItem / SearchQueryItem\n__root__: str"] --> G["Field() — min_items removed\n(was always a no-op on str)"]

    H["InputItem\n__root__: Union[EasyInputMessage, Item, ItemReferenceParam]"] --> I["Plain union matching\n(discriminator removed — Item is itself\na __root__ union, so discriminator\nwas non-functional)"]
Loading

Reviews (3): Last reviewed commit: "Merge branch 'main' into codex/openai2-c..." | Re-trigger Greptile

@socket-security
Copy link
Copy Markdown

socket-security bot commented Apr 13, 2026

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatedopenai@​1.41.1 ⏵ 2.8.096100100100100
Updatedjiter@​0.5.0 ⏵ 0.14.0100 +1100100100100

View full report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant