cayu.providers.openai_subscription
Public Cayu API. Definitions are grouped by their public source module, and definitions from private implementation modules appear on their package’s page; adding a symbol does not move existing links. The import shown at each entry is a supported public namespace. Read the Python API overview and install the required extra.
DEFAULT_OPENAI_SUBSCRIPTION_BASE_URL
Section titled “DEFAULT_OPENAI_SUBSCRIPTION_BASE_URL”from cayu.providers import DEFAULT_OPENAI_SUBSCRIPTION_BASE_URLDEFAULT_OPENAI_SUBSCRIPTION_BASE_URL = 'https://chatgpt.com/backend-api/codex'Release source · Runtime guarantees · Capability guides
HttpxOpenAISubscriptionOAuthTransport
Section titled “HttpxOpenAISubscriptionOAuthTransport”from cayu.providers import HttpxOpenAISubscriptionOAuthTransportHTTP transport for OpenAI’s public Codex OAuth client.
init (method)
Section titled “init (method)”HttpxOpenAISubscriptionOAuthTransport.__init__(*, issuer: str=DEFAULT_OPENAI_SUBSCRIPTION_OAUTH_ISSUER, timeout_s: float=30.0) -> Nonerefresh (method)
Section titled “refresh (method)”HttpxOpenAISubscriptionOAuthTransport.refresh(refresh_token: str) -> Mapping[str, Any]exchange_authorization_code (method)
Section titled “exchange_authorization_code (method)”HttpxOpenAISubscriptionOAuthTransport.exchange_authorization_code(*, code: str, redirect_uri: str, code_verifier: str) -> Mapping[str, Any]request_device_authorization (method)
Section titled “request_device_authorization (method)”HttpxOpenAISubscriptionOAuthTransport.request_device_authorization() -> Mapping[str, Any]poll_device_authorization (method)
Section titled “poll_device_authorization (method)”HttpxOpenAISubscriptionOAuthTransport.poll_device_authorization(*, device_auth_id: str, user_code: str) -> Mapping[str, Any] | Noneexchange_device_authorization (method)
Section titled “exchange_device_authorization (method)”HttpxOpenAISubscriptionOAuthTransport.exchange_device_authorization(*, authorization_code: str, code_verifier: str) -> Mapping[str, Any]Release source · Runtime guarantees · Capability guides
OpenAISubscriptionAuth
Section titled “OpenAISubscriptionAuth”from cayu.providers import OpenAISubscriptionAuthLoad and refresh one user’s ChatGPT subscription credentials.
init (method)
Section titled “init (method)”OpenAISubscriptionAuth.__init__(*, store: OpenAISubscriptionAuthStore | None=None, oauth_transport: OpenAISubscriptionOAuthTransport | None=None, refresh_skew_seconds: float=DEFAULT_OPENAI_SUBSCRIPTION_REFRESH_SKEW_SECONDS, now: Callable[[], float]=time.time) -> Nonecredentials (method)
Section titled “credentials (method)”async OpenAISubscriptionAuth.credentials() -> OpenAISubscriptionCredentialsRelease source · Runtime guarantees · Capability guides
OpenAISubscriptionAuthError
Section titled “OpenAISubscriptionAuthError”from cayu.providers import OpenAISubscriptionAuthErrorRaised when subscription credentials are unavailable or cannot refresh.
Bases: RuntimeError.
This type’s implementation and inherited behavior are available in the linked release source.
Release source · Runtime guarantees · Capability guides
OpenAISubscriptionAuthStore
Section titled “OpenAISubscriptionAuthStore”from cayu.providers import OpenAISubscriptionAuthStorePrivate local JSON store for a user’s ChatGPT OAuth credentials.
init (method)
Section titled “init (method)”OpenAISubscriptionAuthStore.__init__(path: str | Path | None=None) -> Noneload (method)
Section titled “load (method)”OpenAISubscriptionAuthStore.load() -> OpenAISubscriptionCredentials | Nonesave (method)
Section titled “save (method)”OpenAISubscriptionAuthStore.save(credentials: OpenAISubscriptionCredentials) -> Nonedelete (method)
Section titled “delete (method)”OpenAISubscriptionAuthStore.delete() -> boolRelease source · Runtime guarantees · Capability guides
OpenAISubscriptionCredentials
Section titled “OpenAISubscriptionCredentials”from cayu.providers import OpenAISubscriptionCredentialsRefreshable credentials issued by OpenAI’s ChatGPT OAuth flow.
Decorators: @dataclass(frozen=True, slots=True).
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
access_token |
str |
field(repr=False) |
refresh_token |
str |
field(repr=False) |
expires_at |
float |
required |
account_id |
str | None |
field(default=None, repr=False) |
Release source · Runtime guarantees · Capability guides
OpenAISubscriptionProvider
Section titled “OpenAISubscriptionProvider”from cayu.providers import OpenAISubscriptionProviderExperimental Responses adapter backed by a user’s ChatGPT subscription.
OpenAI does not currently document the raw Codex backend as a third-party
provider API. Cayu therefore sends an honest originator: cayu identity
and treats upstream rejection as a hard compatibility boundary.
Bases: ModelProvider.
Fields and attributes
Section titled “Fields and attributes”Defaults below are source expressions; Field(...) includes schema/validation settings and default_factory creates a fresh value. Inherited declarations are included. Constructor behavior follows the model or dataclass shown in the bases/decorators.
| Name | Type | Default |
|---|---|---|
name |
class attribute |
'openai_subscription' |
billing_provider_name |
class attribute |
'openai' |
usage_dialect |
class attribute |
UsageDialect.OPENAI |
supports_native_structured_output |
class attribute |
True |
prepare_auxiliary_request (method)
Section titled “prepare_auxiliary_request (method)”OpenAISubscriptionProvider.prepare_auxiliary_request(request: ModelRequest, *, max_output_tokens: int) -> ModelRequeststream_deadlines (property)
Section titled “stream_deadlines (property)”OpenAISubscriptionProvider.stream_deadlines() -> ProviderStreamDeadlinesruntime_stream (method)
Section titled “runtime_stream (method)”OpenAISubscriptionProvider.runtime_stream(request: ModelRequest) -> AsyncIterator[ModelStreamEvent]Open the governed model-attempt stream.
Runtime, application, example, and conformance callers must use this
entrance so normalized semantic and absolute deadlines also guard
opaque custom providers. Transparent provider wrappers must override
this entrance and delegate to the wrapped provider’s runtime_stream;
forwarding only the raw stream hook would add an opaque outer guard
that cannot trust terminal evidence accepted by the wrapped adapter.
execution_profile_identity (property)
Section titled “execution_profile_identity (property)”OpenAISubscriptionProvider.execution_profile_identity() -> ExecutionProfileBehaviorIdentity | NoneOptional application-versioned identity for opaque adapter behavior.
provider_operation_mode (property)
Section titled “provider_operation_mode (property)”OpenAISubscriptionProvider.provider_operation_mode() -> ProviderOperationModeExplicit dispatch mode; capability support alone never enables it.
provider_operations (property)
Section titled “provider_operations (property)”OpenAISubscriptionProvider.provider_operations() -> ProviderOperationAdapter | NoneOptional reconnectable-operation adapter.
Returning None preserves the ordinary synchronous stream path.
Providers opt in explicitly by returning a composed adapter.
context_pressure_profile (property)
Section titled “context_pressure_profile (property)”OpenAISubscriptionProvider.context_pressure_profile() -> ModelContextPressureProfilerequest_cache_policy (method)
Section titled “request_cache_policy (method)”OpenAISubscriptionProvider.request_cache_policy(request: ModelRequest) -> CachePolicy | NoneDescribe the effective provider-visible cache breakpoints, when known.
Implementations must be deterministic, side-effect free, and perform no I/O.
request_cache_projection (method)
Section titled “request_cache_projection (method)”OpenAISubscriptionProvider.request_cache_projection(request: ModelRequest) -> RequestCacheProjection | NoneProject the effective cache policy and provider-selected prefix.
Providers whose message preparation can filter or normalize content should override this hook and return the exact ephemeral prefix through the marker they applied. The default preserves compatibility with policy-only provider extensions and lets the runtime derive a provider-neutral prefix. Implementations must be deterministic, side-effect free, and perform no I/O.
request_footprint_options (method)
Section titled “request_footprint_options (method)”OpenAISubscriptionProvider.request_footprint_options(request: ModelRequest) -> dict[str, Any]request_fingerprint_options (method)
Section titled “request_fingerprint_options (method)”OpenAISubscriptionProvider.request_fingerprint_options(request: ModelRequest) -> dict[str, Any]preflight_model_target (method)
Section titled “preflight_model_target (method)”OpenAISubscriptionProvider.preflight_model_target(*, model: str) -> NoneReject an unavailable provider/model target before runtime mutation.
This side-effect-free hook is called during initial-run admission before the session is created and again immediately before provider dispatch. Ordinary providers need no override. Applications may use it for credential-free inspection placeholders whose live execution must fail with a concrete setup diagnostic.
preflight_thinking (method)
Section titled “preflight_thinking (method)”OpenAISubscriptionProvider.preflight_thinking(*, model: str, thinking: ThinkingConfig | None) -> Nonepreflight_portable_messages (method)
Section titled “preflight_portable_messages (method)”OpenAISubscriptionProvider.preflight_portable_messages(*, model: str, messages: list[Message], tools: list[dict[str, Any]]) -> Nonepreflight_hosted_tools (method)
Section titled “preflight_hosted_tools (method)”OpenAISubscriptionProvider.preflight_hosted_tools(*, model: str, hosted_tools: tuple[OpenAIWebSearch, ...], options: dict[str, Any]) -> Nonesupports_targeted_tool_projection (method)
Section titled “supports_targeted_tool_projection (method)”OpenAISubscriptionProvider.supports_targeted_tool_projection(*, model: str, protocol: str) -> boolReport an explicitly established provider/model projection capability.
The conservative default is unsupported. Implementations must not infer support from a model-name pattern because provider aliases and compatible endpoints can expose different wire contracts under the same model name.
preflight_targeted_tool_projection (method)
Section titled “preflight_targeted_tool_projection (method)”OpenAISubscriptionProvider.preflight_targeted_tool_projection(*, model: str, protocol: str) -> NoneReject targeted-tool authority that this provider cannot project.
supports_tool_discovery_projection (method)
Section titled “supports_tool_discovery_projection (method)”OpenAISubscriptionProvider.supports_tool_discovery_projection(*, model: str, protocol: str) -> boolReport an explicitly established provider/model discovery capability.
preflight_tool_discovery_projection (method)
Section titled “preflight_tool_discovery_projection (method)”OpenAISubscriptionProvider.preflight_tool_discovery_projection(*, model: str, protocol: str) -> NoneReject discovery authority that this provider cannot project.
billing_identity_for_request (method)
Section titled “billing_identity_for_request (method)”async OpenAISubscriptionProvider.billing_identity_for_request(request: ModelRequest) -> BillingIdentitybilling_identity_for_completion (method)
Section titled “billing_identity_for_completion (method)”OpenAISubscriptionProvider.billing_identity_for_completion(identity: BillingIdentity | None, payload: dict[str, Any]) -> BillingIdentity | NoneMerge provider-reported completion facts into a request identity.
preflight_native_structured_output_schema (method)
Section titled “preflight_native_structured_output_schema (method)”OpenAISubscriptionProvider.preflight_native_structured_output_schema(json_schema: dict[str, Any]) -> Nonecount_input_tokens (method)
Section titled “count_input_tokens (method)”async OpenAISubscriptionProvider.count_input_tokens(request: ModelRequest) -> InputTokenCountResult | Nonestream (method)
Section titled “stream (method)”async OpenAISubscriptionProvider.stream(request: ModelRequest)init (method)
Section titled “init (method)”OpenAISubscriptionProvider.__init__(*, auth: OpenAISubscriptionCredentialProvider | None=None, name: str='openai_subscription', base_url: str=DEFAULT_OPENAI_SUBSCRIPTION_BASE_URL, timeout_s: float=DEFAULT_OPENAI_TIMEOUT_SECONDS, stream_deadlines: ProviderStreamDeadlines | None=None, transport: OpenAITransport | None=None, extra_headers: Mapping[str, str] | None=None, hosted_web_search_supported: bool | None=None, model_catalog: ModelCatalog | None=None) -> Noneaclose (method)
Section titled “aclose (method)”async OpenAISubscriptionProvider.aclose() -> None