aimarket-streaming
Documentation
| Document | Description |
|---|---|
| User guide | Install, configure, verify plugin is loaded |
| User cases | Personas and cross-plugin workflows |
| SDK integration | Code 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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file aimarket_streaming-2.0.0.tar.gz.
File metadata
- Download URL: aimarket_streaming-2.0.0.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5421daea483aee220189cbe6d03de9435ecfaf0a1173785403770d5134b2340
|
|
| MD5 |
25755a0d93a2e8c1dd2fd346e82304a3
|
|
| BLAKE2b-256 |
15e4183405fa4a404dc902e90b46468c78fe1b29eb4b0adcfa5c9d899f0c683a
|
File details
Details for the file aimarket_streaming-2.0.0-py3-none-any.whl.
File metadata
- Download URL: aimarket_streaming-2.0.0-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
153237818926f5eab9b9c58bacc9a1921dd1b4202d424d4b8be22bbc290b7496
|
|
| MD5 |
29880f00d1c91d3b08aa0235b695ef7a
|
|
| BLAKE2b-256 |
17e86f6a05efed7bcc3deb56e281766fc2d3b7a93afb14333974cc86e53ac741
|