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.1.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.1-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ai_stream_proxy_sdk-0.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 bd232ef5cb4d419f4409e354b5349ace3b0c1cad15f9865a101a2e90c44e7a84
MD5 8b2e81c51f9d5fee52063d9408b3af55
BLAKE2b-256 e9cd2583cb89e825e12f051e08b0c2f0272553559fcd74872652e3457d62b5d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for ai_stream_proxy_sdk-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1c40fe606e6d31c684df42d925f7c6d29b7344bfb6f67fc6b33d58640d0885fe
MD5 0e243be685eb0c9f0b4b49a6835b5435
BLAKE2b-256 e78ccb69c005b9199e91b6ed6f54a1f6b98770daf5ebc3254992cab436c963e9

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