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.agent import Agent
from axio.context import MemoryContextStore
from axio_transport_openai import OpenAITransport, OPENAI_MODELS

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

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)

from axio.models import ModelSpec, Capability

transport = OpenAITransport(
    api_key="ollama",                        # any non-empty string
    model=ModelSpec(id="llama3.2", capabilities=frozenset({Capability.text})),
    base_url="http://localhost:11434/v1",
)

Streaming events

import asyncio
from axio.agent import Agent
from axio.context import MemoryContextStore
from axio.testing import StubTransport, make_text_response
from axio.events import TextDelta, SessionEndEvent

agent = Agent(
    system="",
    tools=[],
    transport=StubTransport([make_text_response("Why did the chicken cross the road?")]),
)

async def main() -> None:
    ctx = MemoryContextStore()
    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]")

asyncio.run(main())

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-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.6.0.tar.gz (100.1 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.6.0-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for axio_transport_openai-0.6.0.tar.gz
Algorithm Hash digest
SHA256 057240e841dbeb1aed3d8aebda048aa5285705e9b96ff584f4d3369c77005f05
MD5 22a6ea11b36b9e693cb84d6577c20c59
BLAKE2b-256 8f155122c42c8301f84a269c634759b1e5ba915045da7d51184379a18a3cc751

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on axio-agent/monorepo

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.6.0-py3-none-any.whl.

File metadata

File hashes

Hashes for axio_transport_openai-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b6d2569c391d855dcbfcc4373c859ce706d949f40bc6909b668cfcac880c1b78
MD5 d78e5d585daf4d6c2e1a5f979e36c268
BLAKE2b-256 3c279554962339e6ef11bffeb360affa17d8113ea61c81d9bbf189ea3fc51296

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on axio-agent/monorepo

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