API Reference

Authentication

InferexAI uses JWT-based API keys. Every request must include a valid key in the Authorization header.

Authorization header

Pass your API key as a Bearer token in every request:

text
Authorization: Bearer sk-live-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Using with the OpenAI SDK

Set api_key to your InferexAI key. The SDK sends it as a Bearer token automatically.

Python
from openai import OpenAI

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

How API keys work

JWT-signed
Every key is an HS256 JWT signed with the server's JWT_SECRET. The payload contains your user ID, a unique key ID (jti), and an issue timestamp.
Stored securely
The full token is stored in the database so you can always view and copy it from your dashboard. There is no "only shown once" restriction.
Revocable
Any key can be revoked from Dashboard → API Keys. Revoked keys are rejected immediately, even if the JWT signature is still valid.
Key prefix
The prefix (e.g. sk-live-a1b2c3d4) is a human-readable identifier for the key. It appears in usage logs so you can identify which key made a request.

Creating a key via API

Keys are normally created through the dashboard UI. If you need to create them programmatically (e.g. for CI/CD), use the portal API:

bash
# Keys are created via the dashboard UI or the portal API
curl https://inferexapi.cloudvoice.in/portal/keys \
  -X POST \
  -H "Authorization: Bearer <your-session-token>" \
  -H "Content-Type: application/json" \
  -d '{"name": "my-app-key"}'
response.json
{
  "id": 42,
  "name": "my-app-key",
  "token": "sk-live-eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
  "prefix": "sk-live-a1b2c3d4",
  "created_at": "2026-05-20T10:00:00Z"
}

Best practices

Never commit API keys to source control. Use environment variables or a secrets manager.
Create separate keys per application or environment (dev, staging, prod).
Revoke compromised keys immediately from the dashboard.
Monitor per-key usage in Observability to detect unusual activity.
.env
# .env
INFEREXAI_API_KEY=sk-live-your-key-here
INFEREXAI_BASE_URL=https://inferexapi.cloudvoice.in/v1