Skip to main content

Official AI Stats Gateway SDK for Python.

Project description

AI Stats Python SDK

Official Python SDK for AI Stats Gateway.

Installation

pip install ai-stats-py-sdk

Requires Python 3.10+.

Quick start

from ai_stats import AIStats

client = AIStats()  # Uses AI_STATS_API_KEY from environment

response = client.responses.create(
    {
        "model": "google/gemma-3-27b:free",
        "input": "Reply with: Python SDK works",
    }
)

print(response.get("output_text"))

Streaming example

from ai_stats import AIStats

client = AIStats()

for chunk in client.stream_text(
    {
        "model": "google/gemma-3-27b:free",
        "messages": [{"role": "user", "content": "Stream hi"}],
    }
):
    print(chunk, end="", flush=True)

Common methods

  • client.responses.create(...)
  • client.chat.completions.create(...)
  • client.models.list(...)
  • client.models.get_deprecation_info(model_id)
  • client.models.validate(model_id)

Free and paid models

  • Models with :free in the model ID can be called with zero deposited credits.
  • Paid models require available wallet balance.

Model lifecycle warnings

from ai_stats import AIStats

client = AIStats(
    enable_deprecation_warnings=True,
    warnings_as_errors=False,
    logger=lambda level, message, meta: print(level, message, meta),
)

Environment variables

  • AI_STATS_API_KEY (required unless passed in code)
  • AI_STATS_BASE_URL (optional, defaults to https://api.phaseo.app/v1)

Devtools

from ai_stats import AIStats, create_ai_stats_devtools

client = AIStats(
    devtools=create_ai_stats_devtools(
        directory=".ai-stats-devtools",
        capture_headers=False,
    )
)

Regeneration and local checks

  • Regenerate generated client: pnpm openapi:gen:py
  • Run tests: pnpm test:sdk-py
  • Smoke checks:
    • pnpm --filter @ai-stats/py-sdk run smoke:chat
    • pnpm --filter @ai-stats/py-sdk run smoke:responses

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_stats_py_sdk-2.0.0.tar.gz (44.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_stats_py_sdk-2.0.0-py3-none-any.whl (50.8 kB view details)

Uploaded Python 3

File details

Details for the file ai_stats_py_sdk-2.0.0.tar.gz.

File metadata

  • Download URL: ai_stats_py_sdk-2.0.0.tar.gz
  • Upload date:
  • Size: 44.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ai_stats_py_sdk-2.0.0.tar.gz
Algorithm Hash digest
SHA256 43b2b49a7bbf66a2e9f2380bee0a3653de61b1472b7699573813bcd36253fca4
MD5 6203b6dc68e95ff3d441c3fda27f54a6
BLAKE2b-256 0eb8f3d761f02f080e6a62f556757d40c9193956ceac25e365abcefb37182868

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_stats_py_sdk-2.0.0.tar.gz:

Publisher: ci.yml on AI-Stats/AI-Stats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ai_stats_py_sdk-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: ai_stats_py_sdk-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 50.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for ai_stats_py_sdk-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 23d9c19c9b764896065c90e85501211bf60a443490ebdb288be568dab04d96a9
MD5 72284564b44a7063cf6ff95d54680656
BLAKE2b-256 d33cbaa3908be24f050315b91705a7e0c35221cce2b00242cbdd8fae4404840c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ai_stats_py_sdk-2.0.0-py3-none-any.whl:

Publisher: ci.yml on AI-Stats/AI-Stats

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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