Skip to main content

OpenAI-compatible transport for Axio

Project description

axio-transport-openai

PyPI Python License: MIT

OpenAI-compatible streaming transport for axio.

Works with any API that speaks the OpenAI chat completions format — OpenAI itself, Azure OpenAI, local models via Ollama/vLLM/LM Studio, and compatible cloud providers.

Features

  • Full SSE streaming — parses data: chunks incrementally; no waiting for full responses
  • Automatic retry — configurable backoff on transient HTTP errors
  • Tool calling — streams tool-use JSON fragments as ToolInputDelta events
  • aiohttp-based — zero blocking I/O
  • Optional TUI settings screen — install with [tui] extra for a Textual configuration UI

Installation

pip install axio-transport-openai

With TUI settings screen:

pip install "axio-transport-openai[tui]"

Usage

from axio import Agent
from axio.context import MemoryContextStore
from axio_transport_openai import OpenAITransport

transport = OpenAITransport(
    api_key="sk-...",
    model="gpt-4o-mini",
    base_url="https://api.openai.com/v1",  # default; override for local models
    max_tokens=4096,
)

agent = Agent(system="You are a helpful assistant.", tools=[], transport=transport)

async def main() -> None:
    ctx = MemoryContextStore()
    result = await agent.run("What is 2 + 2?", ctx)
    print(result)

Local models (Ollama, vLLM, LM Studio)

transport = OpenAITransport(
    api_key="ollama",                        # any non-empty string
    model="llama3.2",
    base_url="http://localhost:11434/v1",
)

Streaming events

from axio.events import TextDelta, SessionEndEvent

async for event in agent.run_stream("Tell me a joke", ctx):
    match event:
        case TextDelta(delta=text):
            print(text, end="", flush=True)
        case SessionEndEvent(total_usage=usage):
            print(f"\n[{usage.input_tokens}in / {usage.output_tokens}out tokens]")

Plugin registration

When installed, this package registers itself via entry points so axio-tui discovers it automatically:

[project.entry-points."axio.transport"]
openai = "axio_transport_openai:OpenAITransport"

Part of the axio ecosystem

axio · axio-transport-nebius · axio-transport-codex · axio-tui

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

axio_transport_openai-0.2.2.tar.gz (89.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

axio_transport_openai-0.2.2-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file axio_transport_openai-0.2.2.tar.gz.

File metadata

  • Download URL: axio_transport_openai-0.2.2.tar.gz
  • Upload date:
  • Size: 89.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for axio_transport_openai-0.2.2.tar.gz
Algorithm Hash digest
SHA256 3ba8c6c7ce2c44afe3cd7f2cf55f2984dde3dc1d368fbc5eb86e8de630495d33
MD5 e7e836fe0d2915bbdbaf739d9d95a0e2
BLAKE2b-256 489a952b860c079d051f72cec15abf1d81720b7b17c1b703a7e940bbcfdf15d3

See more details on using hashes here.

Provenance

The following attestation bundles were made for axio_transport_openai-0.2.2.tar.gz:

Publisher: publish.yml on axio-agent/axio-transport-openai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file axio_transport_openai-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for axio_transport_openai-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 744d57bbc89661ffaceb5864e625c7c2d9e15823d64d2f1438539834b439e521
MD5 1880dd47f5910dd7af8ba5dd1a4cdc4b
BLAKE2b-256 08dc33295fcee7178b8e2c71f8a7767b405ba0f6b69521efc4aec77b75d01fb7

See more details on using hashes here.

Provenance

The following attestation bundles were made for axio_transport_openai-0.2.2-py3-none-any.whl:

Publisher: publish.yml on axio-agent/axio-transport-openai

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page