Repository navigation
fix(py/openai): allow openai 3.x - #163
Closed
huangjeff5 wants to merge 1 commit into
Closed
huangjeff5 wants to merge 1 commit into
huangjeff5 wants to merge 1 commit into
Conversation
Widen genkit-openai to openai>=1.68.0,<4 and lock 3.55.1. - Read extra usage counts with getattr. openai 3.x declares PromptTokensDetails.image_tokens, so it left model_extra and imageTokens was dropped. getattr reads a declared field or a pydantic extra on every SDK in range. - openai 3.x wraps stream-read transport errors in APITimeoutError / APIConnectionError; the stream-cut test now accepts either cause depth. Classification is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
genkit-openai capped
openai<3, but openai 3.0 shipped 2026-08-12 (latest 3.55.1). Anyone already on openai 3.x couldn't install genkit-openai. This widens the range toopenai>=1.68.0,<4; the plugin and its tests now work on 1.x, 2.x and 3.x.Main Changes
<4, raised the floor to 1.68: openai 3.0's breaking changes are mostly transport (httpx2 by default, OS trust store). The plugin builds its client through the SDK, so nothing changes for users who don't pass a customhttp_client. The 1.68 floor matches fix(py): enforce dependency bounds policy and raise declared floors #154:_audio.pypassesinstructions, which arrived in 1.68.model_extra: Previously,image_tokens,num_sources_used,costandprompt_cache_hit_tokenswere read from pydantic'smodel_extra, which only holds fields the model doesn't declare. openai 3.x declaresimage_tokens, so it moved out ofmodel_extraandimageTokenssilently disappeared fromusage.custom.getattrreads a declared field or an extra, so this works on every SDK version and survives future promotions.APITimeoutError/APIConnectionError; earlier versions let raw httpx errors escapeasync for. Both paths still map to UNAVAILABLE / DEADLINE_EXCEEDED; the test now accepts the extra__cause__level.Verification
pytest packages/genkit-openai packages/genkit-vertexai: 550 passed at openai 1.68.0 (floor), 2.54.0 (latest 2.x) and 3.55.1 (lock).check_consistency.pyclean.Notes
httpx.AsyncClientviaclient_options={'http_client': ...}still work at runtime, but the SDK calls that temporary and type checkers reject it. They should build it fromhttpx2.audio.translations.createraises aDeprecationWarningon 3.x.openaispec line anduv.lock; both set the 1.68 floor.