Skip to main content

axio-responses

PyPI Python License: MIT

The OpenAI Responses API as axio speaks it: request items in, StreamEvents out.

Both halves live here rather than in a transport because two transports speak this API — the public /v1/responses endpoint and the ChatGPT backend Codex uses. It knows nothing about HTTP and opens no connection.

Installation

pip install axio-responses

Usage

Building the request

from axio.blocks import TextBlock
from axio.messages import Message
from axio_responses import convert_messages, convert_tools

messages, system, tools = [Message(role="user", content=[TextBlock(text="hi")])], "be brief", []

instructions, items = convert_messages(messages, system)
payload = {
    "model": "gpt-5.6",
    "instructions": instructions,
    "input": items,
    "stream": True,
    "tools": convert_tools(tools),
}
assert payload["instructions"] == "be brief"

convert_messages returns the system prompt separately, because this API takes it as instructions rather than as a message. Tool calls and their outputs become function_call and function_call_output items beside the messages, not blocks inside them.

Reading the stream

Responses is an axio_sse.Reader: one @on(...) method per event, dispatching on the payload's own type. Its class body names only the events it interprets. The API publishes one event family per tool it can run, so that set grows with the tools and not with the protocol; everything else is forwarded through unmatched() rather than dropped.

from collections.abc import AsyncIterator

import aiohttp
from axio.events import StreamEvent
from axio_responses import Responses


async def stream(resp: aiohttp.ClientResponse) -> AsyncIterator[StreamEvent]:
    turn = Responses()
    async for made in turn.over(resp.content.iter_any(), until="[DONE]"):
        yield made
    yield turn.finished()

Events axio has no type for — the API's own hosted tools, its audio, its bookkeeping — travel as ProviderEvent under the provider's own name rather than being dropped.

Holding it against the schema

from axio_responses import Responses

PUBLISHED_EVENTS = {"response.output_text.delta", "response.completed", "response.refusal.delta"}

# Every name the reader claims is one the schema publishes. A typo is a handler that never runs.
assert Responses.names() >= PUBLISHED_EVENTS

names() answers what the reader claims, so a test can hold it against the union OpenAI publishes. The check is <=, not ==: the reader deliberately names fewer events than the API sends. Reading with strict=True raises UnknownEvent on a name it does not claim, which is how a test fails on the day OpenAI adds one.

License

MIT

Metadata

Release files for axio-responses 0.11.1

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

Source distribution (sdist)

Source distribution for axio-responses 0.11.1
File Size Uploaded
axio_responses-0.11.1.tar.gz 18.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for axio-responses 0.11.1
File Interpreter ABI Platform
axio_responses-0.11.1-py3-none-any.whl Python 3 none any Details

Total release size: 30.2 kB

Release files / axio_responses-0.11.1.tar.gz

Download URL axio_responses-0.11.1.tar.gz
Size 18.5 kB
Tags Source
SHA-256 checksum
How to use checksums
aa23fb69ab26999687a55e406ffcad1d506fc06b8e0dfd84d36770cb804b0182
BLAKE2b-256 checksum
How to use checksums
ec9755708814ee2296ca897e7a53f6f1a0ef197be0b2b554b095123c1679db06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release files / axio_responses-0.11.1-py3-none-any.whl

Download URL axio_responses-0.11.1-py3-none-any.whl
Size 11.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0ec5d60c07f74493efc67fe9a6794e8fd637ce395a87e06c4775b7f4bd047fdc
BLAKE2b-256 checksum
How to use checksums
9cfd4a26164fb7501609e3aaf81b87a8d50afb767a2f2d8f1935e21f57ae7dec
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 29, 2026.

Transparency log

Release history Release notifications | RSS feed

0.11.3

2 release files

0.11.2

2 release files

This release

0.11.1 This release

2 release files

0.11.0

2 release files

0.1.0

1 release file

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