Define + export `ServiceTiers` string literal
Confirm this is a feature request for the Python library and not the underlying OpenAI API.
- [x] This is a feature request for the Python library
Describe the feature or improvement you're requesting
If I want to annotate service_tier in my code, I have to hard-code a type like Literal["auto", "default", "flex", "scale", "priority", "fast"], and then the hard-coded type annotation breaks if I'm using anything other than the latest version of the sdk.
Additional context
No response
Hey, looks like we need a centralized ServiceTiers type, can I add that??
Proposed Plan to Define and Export ServiceTier String Literal
Problem Analysis
When configuring service_tier in OpenAI API completion/chat requests, developers currently have to hardcode string literal union types (e.g. Literal["auto", "default", "flex", "scale", "priority", "fast"]) in their applications. When new service tiers are introduced or when using type checkers, hardcoded type annotations break across SDK version upgrades.
Proposed Implementation
- Define ServiceTier Literal: In
src/openai/types/_shared_params.py(orsrc/openai/types/__init__.py), defineServiceTieras an exportedtyping_extensions.Literal:ServiceTier = Literal["auto", "default", "flex", "scale", "priority", "fast"] - Export Type Alias: Export
ServiceTierandServiceTiersinsrc/openai/types/__init__.pyso SDK consumers can importfrom openai.types import ServiceTier. - Type Annotation Usage: Wire
ServiceTierinto client completion parameters whereservice_tieris accepted. - Unit Test Verification: Add type verification tests in
tests/test_client.pychecking thatServiceTieris exported fromopenai.typesand type checks cleanly.
The other thing they should actually change is clarify “auto” is only an input tier and not an output tier, but god knows if any humans actually write this code anymore.