Skip to main content

Sync and async Python SDK for the Pantheon stream-proxy service.

Project description

ai-stream-proxy-sdk

Python SDK for the Pantheon stream-proxy service with aligned sync and async APIs.

Sync

from ai_stream_proxy import StreamProxyClient

with StreamProxyClient(server_url="http://127.0.0.1:3000") as client:
    client.create_stream(
        stream_id="example-sync",
        message_id="msg-sync",
        content_type="claude-code-stream-json+include-partial-messages",
    )

    with client.new_stream(stream_id="example-sync") as stream:
        stream.enqueue(b'{"type":"thread.started","thread_id":"thread-1"}\n')

Async

import asyncio

from ai_stream_proxy import AsyncStreamProxyClient


async def main() -> None:
    async with AsyncStreamProxyClient(server_url="http://127.0.0.1:3000") as client:
        await client.create_stream(
            stream_id="example-async",
            message_id="msg-async",
            content_type="codex-stream-json",
        )

        async with client.new_stream(stream_id="example-async") as stream:
            stream.enqueue(b'{"type":"thread.started","thread_id":"thread-1"}\n')


asyncio.run(main())

Delayed Stop Signal

If another service should send the terminal stop signal later, disable auto-finish on context exit:

async with client.new_stream(
    stream_id="example-async",
    auto_finish_on_exit=False,
) as stream:
    stream.enqueue(b"chunk")
    await stream.close_without_stop()

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

ai_stream_proxy_sdk-0.2.2.tar.gz (4.3 kB view details)

Uploaded Source

Built Distribution

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

ai_stream_proxy_sdk-0.2.2-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ai_stream_proxy_sdk-0.2.2.tar.gz
  • Upload date:
  • Size: 4.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for ai_stream_proxy_sdk-0.2.2.tar.gz
Algorithm Hash digest
SHA256 c7897a50d0532e9ed1f46fe8a20202c899207dce222ab47be04cc93eba79a456
MD5 a65cb076d66b21d69f515f36bf0c9d0b
BLAKE2b-256 467043aedc9c55e2e47347e1f5eb6fcade1b2feab56ae50f6f33b797fd7028df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ai_stream_proxy_sdk-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 357c6d5c2063a8e3d6b718c18b59e34c7a0ff191987e5b13b3cedb326250686f
MD5 53eaefef642bc3289c681ea4add089af
BLAKE2b-256 787a32fe827c5ce6d9125247581b3e32e5c7ed339b3e1c18e6f48714116d4901

See more details on using hashes here.

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