Metadata-Version: 2.4
Name: inferexai
Version: 0.1.0
Summary: Official Python SDK for InferexAI — OpenAI-compatible LLM gateway
Project-URL: Homepage, https://inferexai.cloudvoice.in
Project-URL: Documentation, https://inferexdocs.cloudvoice.in
Project-URL: Repository, https://github.com/covideoin/inferexai
Project-URL: Bug Tracker, https://github.com/covideoin/inferexai/issues
Author-email: Enterux Solutions Pvt Ltd <support@inferexai.cloudvoice.in>
License: MIT
Keywords: ai,gateway,inferexai,llm,openai,sdk
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Requires-Dist: httpx>=0.24.0
Requires-Dist: openai>=1.0.0
Description-Content-Type: text/markdown

# inferexai

Official Python SDK for [InferexAI](https://inferexai.cloudvoice.in) — an OpenAI-compatible LLM gateway with prepaid billing, multi-provider fallback routing, and real-time usage analytics.

## Installation

```bash
pip install inferexai
```

## Quick start

```python
from inferexai import InferexAI

client = InferexAI(api_key="sk-live-your-key-here")

response = client.chat.completions.create(
    model="my-chat-model",
    messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
```

## OpenAI-compatible

`InferexAI` extends `openai.OpenAI` — all existing methods work out of the box:

```python
# Chat completions
response = client.chat.completions.create(model=..., messages=..., stream=True)

# Speech-to-Text
with open("audio.wav", "rb") as f:
    transcript = client.audio.transcriptions.create(model="whisper-stt", file=f)

# Text-to-Speech
audio = client.audio.speech.create(model="tts-voice", input="Hello!", voice="Karan")

# List models
models = client.models.list()
```

## Streaming

```python
stream = client.chat.completions.create(
    model="my-chat-model",
    messages=[{"role": "user", "content": "Tell me a story."}],
    stream=True,
)
for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)
```

## InferexAI-specific features

### Wallet

```python
balance = client.wallet.balance()
print(f"Balance: ₹{balance['balance_inr']}")
```

### API Keys

```python
# List keys
keys = client.keys.list()

# Create a key
result = client.keys.create(
    name="production",
    expires_at="2027-01-01T00:00:00Z",
    scopes=["chat", "embeddings"],
)
print(result["key"])  # shown once — store securely

# Revoke a key
client.keys.revoke(key_id=42)
```

### Usage

```python
# List recent events
events = client.usage.list(from_date="2024-01-01", model="my-chat-model")

# Export as CSV
csv_data = client.usage.export(format="csv", from_date="2024-01-01")
with open("usage.csv", "w") as f:
    f.write(csv_data)

# Export as JSON
json_data = client.usage.export(format="json")
```

### Organisation

```python
# Get org
org = client.org.get()  # returns None if not in an org

# Create org
org = client.org.create("Acme Corp")

# Members
members = client.org.members.list()
client.org.members.invite(email="dev@acme.com", role="member")
client.org.members.remove(user_id=7)
```

## Error handling

```python
from inferexai import InferexAI, InferexAIError

try:
    response = client.chat.completions.create(model=..., messages=...)
except InferexAIError as e:
    print(e.status, str(e))  # e.g. 402 "insufficient wallet balance"
```

## Configuration

```python
client = InferexAI(
    api_key="sk-live-your-key-here",
    base_url="https://inferexapi.cloudvoice.in",  # default
)
```

## Requirements

- Python 3.8+
- `openai >= 1.0.0`
- `httpx >= 0.24.0`

## Links

- [Dashboard](https://inferexai.cloudvoice.in)
- [Documentation](https://inferexdocs.cloudvoice.in)

## License

MIT © [Enterux Solutions Pvt Ltd](https://enterux.com)
