inferexai
Official Python SDK for InferexAI — an OpenAI-compatible LLM gateway with prepaid billing, multi-provider fallback routing, and real-time usage analytics.
Installation
pip install inferexai
Quick start
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:
# 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
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
balance = client.wallet.balance()
print(f"Balance: ₹{balance['balance_inr']}")
API Keys
# 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
# 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
# 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
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
client = InferexAI(
api_key="sk-live-your-key-here",
base_url="https://inferexapi.cloudvoice.in", # default
)
Requirements
- Python 3.8+
openai >= 1.0.0httpx >= 0.24.0
Links
License
Metadata
Release files for inferexai 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| inferexai-0.1.0.tar.gz | 4.8 kB | Without provenance | Details for inferexai-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| inferexai-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for inferexai-0.1.0-py3-none-any.whl |
Total release size: 12.4 kB
Release files / inferexai-0.1.0.tar.gz
| Download URL | inferexai-0.1.0.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1bce0c8dac0e720250bcfd88d9ed12dd480974a95fc2668bd6becca6e93faea6
|
|
BLAKE2b-256 checksum How to use checksums |
ff05b7584e9f49e542c77dcccd2d143b0b8515e3dfc7579e83fa4c6b136303f4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.7
|
Release files / inferexai-0.1.0-py3-none-any.whl
| Download URL | inferexai-0.1.0-py3-none-any.whl |
|---|---|
| Size | 7.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c6e1977a213a480d50be9ea60f8758177ac46862d0900c446b50de8e9a6e4c23
|
|
BLAKE2b-256 checksum How to use checksums |
32920f37090688f7973e10bc7217b856d3db536cd76373eebce9302df22e5f91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.7
|
Security for inferexai 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.