Skip to main content

Installation

Install the SDK using pip:
pip install ai-stats-py-sdk

Requirements

  • Python 3.9+
  • httpx (automatically installed as dependency)

Setup

API Key

You’ll need an AI Stats API key to use the SDK. Get one from the AI Stats Dashboard.

Environment Variables

Set your API key as an environment variable:
export AI_STATS_API_KEY="your-api-key-here"

Basic Usage (Async)

import asyncio
from ai_stats import AIStats

async def main():
    async with AIStats(api_key="your-api-key") as client:
        response = await client.chat_completions(
            model="openai/gpt-4o-mini",
            messages=[{"role": "user", "content": "Hello!"}]
        )
        print(response["choices"][0]["message"]["content"])

asyncio.run(main())

Basic Usage (Sync)

from ai_stats import AIStatsSync

with AIStatsSync(api_key="your-api-key") as client:
    response = client.chat_completions(
        model="openai/gpt-4o-mini",
        messages=[{"role": "user", "content": "Hello!"}]
    )
    print(response["choices"][0]["message"]["content"])

Next Steps