Skip to main content

OpenAI connector for Python

Install with pip install dex-connector-openai==0.2.2. The package requires dex-connectors-sdk==0.12.0 and dex-python-sdk>=1.28.0, and implements the manifest operations createResponse (Mutation) and retrieveResponse (Query) with the same branches, defaults, and failure classification as the Go module.

Operations

Operation Factory Happy branch Optional branches
createResponse new_create_response_step completed failed, providerRejected, uncertain, defect
retrieveResponse new_retrieve_response_step found notFound, providerRejected, invalidResponse, defect

createResponse retries

The Responses API does not deduplicate create requests, so createResponse fences every retry with its own Dex heartbeat checkpoint. Keep the Step's manifest sync Execute durability, and record no other heartbeats in that Step.

  • An attempt that observed a response ID reads that response back instead of creating another one, polling queued and in_progress until five seconds before the Execute deadline.
  • Each checkpoint carries sendCount, the possibly billed creates so far. 503, 429, a connection refused before sending, and a definite refusal add none; a cancelled response counts, since it may be billed.
  • Every other unconfirmed outcome without a response ID (408, 409, a 3xx, another 4xx, a 5xx other than 503, or an ambiguous transport failure) retries and resends while possible creates stay below the send cap of 3, and selects uncertain at the cap. A read-back that cannot confirm a known response selects uncertain.
  • A 2xx answer created a response: when it yields no readable response ID (an unreadable, oversized, or cut-off body, or a stream that ends before naming the response), the operation selects uncertain at once and never resends.

The manifest retry policy allows eight attempts within fifteen minutes; the send cap still allows at most three billed creates.

Streaming and structured output

Passing progress_stream or text_stream to new_create_response_step makes OpenAI stream the response. Lifecycle events become progress, text deltas are appended to the text Stream best effort, and the terminal event selects the branch. maxResponseBytes bounds the whole stream and maxSseEventBytes one event; after either limit the connector drains the stream and reads the stored response back when its ID was observed.

StructuredOutput sends a JSON Schema text.format; the completed output_text is then the JSON value.

Authorization and configuration

Create a Dex Web connection as described in the connector README. The API key travels only in the Authorization header. The modelPicker configuration UI unit (UI_UNIT_MODEL_PICKER, port UI_MODEL_PICKER_PORT_MODEL) lets Dex Web store a per-Step model; a blank model uses the connection's model.

Example

examples/summarize_text records the request, creates a summary with streamed text and a model picker, and records the outcome. Run the Worker with uv run python -m examples.summarize_text.worker after dexcli dev has loaded a project containing the openai-api connection.

Tests

openaimock.Mock scripts both operations and defaults to the manifest's default answers. Run uv run pytest tests for fencing, streaming, read-back, and manifest contract checks. With dexcli dev running, run DEX_FLOW_SERVICE_ADDRESS=127.0.0.1:34701 uv run pytest integration to drive the example through a real Dex Worker with a scripted provider transport. The Python mock checks create requests and strict structured answers with the SDK text generation validator, matching the Go connector's mock contract.

uv run pytest tests/test_conformance.py replays the Go-recorded provider scenarios for both operations. Live OpenAI authorization and provider behavior have not been verified.

Metadata

Release files for dex-connector-openai 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dex-connector-openai 0.2.2
File Size Uploaded Provenance Actions
dex_connector_openai-0.2.2.tar.gz 93.7 kB Without provenance Details for dex_connector_openai-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dex-connector-openai 0.2.2
File Interpreter ABI Platform Actions
dex_connector_openai-0.2.2-py3-none-any.whl Python 3 none any Details for dex_connector_openai-0.2.2-py3-none-any.whl

Total release size: 123.9 kB

Release files / dex_connector_openai-0.2.2.tar.gz

Download URL dex_connector_openai-0.2.2.tar.gz
Size 93.7 kB
Tags Source
SHA-256 checksum
How to use checksums
b1c213e207cd78340fb5d9ba61ec79398c4e0af9bdce132e2d2b62b36ece7742
BLAKE2b-256 checksum
How to use checksums
d9f3c303af81a852247df162600123402da9081da3ae1274ce55a45d3788f3a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / dex_connector_openai-0.2.2-py3-none-any.whl

Download URL dex_connector_openai-0.2.2-py3-none-any.whl
Size 30.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
efe253789ce0acf292a9297602b3853d3d4ac42e41f79908663239228dc17d22
BLAKE2b-256 checksum
How to use checksums
5b6bb427bd6e50d1ea0666bd6b11c8e2c0a6250b1914c0797c4b751c0fd7474b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.9 {"installer":{"name":"uv","version":"0.13.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for dex-connector-openai 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page