❱ API Reference

Base URL:

https://inference-api-611798501438.us-central1.run.app

The Majestix AI Inference Hub API is a multi-model AI gateway that provides unified access to models from OpenAI, Anthropic, Google Vertex AI, and OpenRouter through a single credits-based billing system.


Authentication

All endpoints require authentication via one of two methods:

Method
Header(s)
Use Case

API Key

X-Api-Key: inf_...

VSCode extension, CLI tools, programmatic access

Firebase Auth + App Check

Authorization: Bearer <id_token> and X-Firebase-AppCheck: <token>

Browser-based web applications

API keys are issued through the /api-keys endpoint and use the inf_ prefix. Firebase authentication is handled through the web SDK and is intended exclusively for browser clients.


Streaming Protocol (SSE)

Streaming endpoints (/chat, /code) return Server-Sent Events (SSE) with the following event types:

Event Type
Description

chunk

Incremental text content: {"type": "chunk", "content": "..."}

tool_use

Tool call from the model: {"type": "tool_use", "id": "...", "name": "...", "input": {...}}

done

Stream complete: {"type": "done", "model": "...", "session_id": "...", "credits_used": 42}

error

Error during generation: {"type": "error", "message": "..."}

Each SSE message is formatted as:


Endpoints

Method
Path
Description

POST

Chat completions (streaming and non-streaming)

POST

Agentic tool-use endpoint for coding assistants

GET

List available models and capabilities

GET

Retrieve conversation history

DELETE

Delete a session

GET

Credit usage and plan information

POST

Generate a new API key

GET

List existing API keys

DELETE

Revoke an API key

POST

Create Stripe subscription checkout

POST

One-time credit top-up purchase

POST

Open Stripe customer portal

POST

Force credit balance cache refresh

GET

Platform-wide analytics (admin only)

GET

Per-model cost and revenue breakdown (admin only)


Credits

All API usage is billed in credits. 1 credit equals $0.001 USD. A 1.4x margin is applied to raw provider costs. Credits are reserved at the worst-case estimate before generation begins and reconciled to the actual amount when the response completes.

Plan
Monthly Price
Credits Included

Free

$0

500

Guru

$10/mo

10,000

Pro

$50/mo

55,000

Additional credits can be purchased as one-time top-ups through the /billing/topup endpoint.


Error Responses

All endpoints return errors in a consistent JSON format:

Status Code
Meaning

400

Bad request (invalid parameters)

401

Authentication failed or missing

403

Forbidden (insufficient permissions or credits)

404

Resource not found

429

Rate limit exceeded

500

Internal server error

Last updated