Official AI Stats Gateway SDK for Python.
Project description
AI Stats Python SDK
Asynchronous-first Python client for the AI Stats Gateway API. Built from the canonical OpenAPI spec and wrapped with helper methods that mirror the new generate/stream interface.
Installation
pip install ai-stats-py-sdk
Requires Python 3.9+.
Quick start
import asyncio
from ai_stats import AIStats
async def main():
client = AIStats(api_key="sk_test_xxx")
async with client:
completion = await client.generate_text(
{"model": "gpt-5-nano-2025-08-07", "messages": [{"role": "user", "content": "Say hi"}]}
)
print(completion.choices[0].message.content)
asyncio.run(main())
Streaming
async with AIStats(api_key="...") as client:
async for chunk in client.stream_text(
{"model": "gpt-5-nano-2025-08-07", "messages": [{"role": "user", "content": "Stream hi"}]}
):
print(chunk, end="", flush=True)
Models and other helpers
async with AIStats(api_key="...") as client:
models = await client.get_models()
print([m.id for m in models.data])
await client.generate_image({"model": "image-alpha", "prompt": "A purple nebula"})
await client.generate_embedding({"model": "text-embedding-alpha", "input": "hello"})
await client.generate_moderation({"model": "gpt-5-nano-2025-08-07", "input": "safe?"})
await client.generate_video({"model": "video-alpha", "prompt": "Ocean waves"})
await client.generate_speech({"model": "tts-alpha", "input": "Hello!"})
await client.generate_transcription({"model": "whisper-alpha", "file": "<base64 data>"})
Features
- Async and sync interfaces (
AIStats+AIStatsSync) - Typed models for requests/responses and errors
- Streaming helper that yields decoded SSE frames
- Customisable timeouts, headers, and base URL
Note: Provide the API key explicitly via the api_key parameter or by adding an Authorization header through headers. The SDK does not read environment variables.
Refer to the docstrings for each method to see accepted parameters and return values—everything is annotated for IntelliSense.
Versions are driven by Changesets and published via CI (see .github/workflows/ci.yml). You should not need to tag or upload artifacts manually.
Project details
Release history Release notifications | RSS feed
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 ai_stats_py_sdk-0.1.4.tar.gz.
File metadata
- Download URL: ai_stats_py_sdk-0.1.4.tar.gz
- Upload date:
- Size: 53.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
106bc8a515d65ecb9b94204e188e65809882eab4d599ac7b76a68758cd5a9678
|
|
| MD5 |
79e72f4cbceb574e5a68e05a2f149a13
|
|
| BLAKE2b-256 |
495ff7969b47ded6f57073fa53b3f8f9c3fdef583c6967af4fc73c80a5594424
|
Provenance
The following attestation bundles were made for ai_stats_py_sdk-0.1.4.tar.gz:
Publisher:
ci.yml on DanielButler1/AI-Stats
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_stats_py_sdk-0.1.4.tar.gz -
Subject digest:
106bc8a515d65ecb9b94204e188e65809882eab4d599ac7b76a68758cd5a9678 - Sigstore transparency entry: 746516974
- Sigstore integration time:
-
Permalink:
DanielButler1/AI-Stats@4322886327dde92030846969718c9131a2a30431 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/DanielButler1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@4322886327dde92030846969718c9131a2a30431 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ai_stats_py_sdk-0.1.4-py3-none-any.whl.
File metadata
- Download URL: ai_stats_py_sdk-0.1.4-py3-none-any.whl
- Upload date:
- Size: 137.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2d461634272eb0f3ab60588fa4d5da4ebf56735dd4067cf9c01230090f1c8a48
|
|
| MD5 |
247d308fb4a18ebd5fddefa667dc205f
|
|
| BLAKE2b-256 |
db4599c3c1bdf38cc13f4528fd468eaa09d471e8cfa6a18c17c2205898502274
|
Provenance
The following attestation bundles were made for ai_stats_py_sdk-0.1.4-py3-none-any.whl:
Publisher:
ci.yml on DanielButler1/AI-Stats
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ai_stats_py_sdk-0.1.4-py3-none-any.whl -
Subject digest:
2d461634272eb0f3ab60588fa4d5da4ebf56735dd4067cf9c01230090f1c8a48 - Sigstore transparency entry: 746517006
- Sigstore integration time:
-
Permalink:
DanielButler1/AI-Stats@4322886327dde92030846969718c9131a2a30431 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/DanielButler1
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
ci.yml@4322886327dde92030846969718c9131a2a30431 -
Trigger Event:
push
-
Statement type: