Catalog PyPI
Back to packageRELEASE DETAILS

2.0.1

PyPI

aimarket-streaming

SSE/WS streaming + per-chunk billing with micro-receipts

Published16 Oct 2026
Direct dependencies2
Transitive dependenciesNot calculated

README

Version 2.0.1 documentation

aimarket-streaming

Documentation

DocumentDescription
User guideInstall, configure, verify plugin is loaded
User casesPersonas and cross-plugin workflows
SDK integrationCode examples and hook behavior

SSE/WS streaming + per-chunk billing with micro-receipts. Capability streams tokens. Every N tokens → signed micro-receipt. Consumer can cancel mid-stream — pays only for what was received. Channel balance debited incrementally.

When to Use

  • LLM text generation (tokens streamed → billed per 10 tokens)
  • Long-running AI tasks where consumer wants partial results
  • Budget-sensitive consumers who want to cancel mid-stream
  • Audit: every chunk has a signed receipt for compliance

Installation

pip install aimarket-streaming

Example

from aimarket_hub.signing import Signer
from aimarket_streaming.streaming import StreamingBiller

signer = Signer()
biller = StreamingBiller(signer)

session = biller.open_session(
    capability_id="text.generate@v1", product_id="prod-gpt",
    channel_id="ch_abc123", price_per_token_usd=0.001,
    tokens_per_chunk=10
)

async def token_stream():
    for word in ["The", "quick", "brown", "fox", "jumps", "over", "the", "lazy", "dog", ".", "..."]:
        yield word  # In production: yield actual LLM tokens

import asyncio
async def main():
    async for chunk in biller.stream_tokens(session, token_stream()):
        print(f"Chunk {chunk['chunk_receipt']['chunk_index']}: "
              f"${chunk['cumulative_price_usd']:.6f} "
              f"({chunk['cumulative_tokens']} tokens)")

asyncio.run(main())

# Cancel mid-stream — pays only for received
result = biller.cancel_session(session.session_id)
print(f"Cancelled. Total paid: ${result['total_price_usd']:.6f}")

Per-Chunk Billing

  • price_per_token_usd: 0.001 (0.1 cent per token)
  • tokens_per_chunk: 10 (micro-receipt every 10 tokens)
  • Each chunk receipt is Ed25519-signed — verifiable audit trail

License

MIT · Maintained by AI-Factory

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 2

Native requirements
2 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
aimarket-hub
Environment
{
  "extras": "",
  "marker": null,
  "requires_python": ">=3.11",
  "evaluation": "NOT_EVALUATED"
}
aimarket-hub>=2.0.0runtime
pytest
Environment
{
  "extras": "",
  "marker": "extra == \"dev\"",
  "requires_python": ">=3.11",
  "evaluation": "NOT_EVALUATED"
}
pytest>=8; extra == "dev"runtime

Distribution files

2 collected
aimarket_streaming-2.0.1-py3-none-any.whl

bdist_wheel · 4.55 KB · Python py3

Source file
aimarket_streaming-2.0.1.tar.gz

sdist · 4.14 KB · Python source

Source file

Repository

PENDING
alexar76/aimarket-plugins

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 11:15 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:4a2c6f87bcddcf41fbc2c288e4e19f0251e4cd38366a55b0aeea833e427adb92

Other collected versions

View all collected versions →