ServeLLMServeLLM
Start Building
API Reference

Documentation

ServeLLM is a region-local LLM inference platform. It exposes an OpenAI-compatible REST API so you can drop it into any existing codebase with a one-line change — just swap the base URL and use your ServeLLM API key. Models run on infrastructure close to your users, billed per token in your local currency (PKR).

OpenAI-compatible

Same request / response shape as the OpenAI Chat Completions API.

Region-local

Choose a region to route requests to the nearest inference node.

Pay in PKR

Pre-purchase credits in Pakistani Rupees via JazzCash.

Authentication#

All API requests must include your API key in the Authorization header using the Bearer scheme. API keys are created in the dashboard.

bash
Authorization: Bearer sk-servellm-<your-key>

Keys are prefixed sk-servellm- and hashed server-side — ServeLLM never stores the raw key. You will only see the full key once at creation time, so copy it immediately.

Keep your key secret. Never expose it in client-side code or commit it to a repository. If a key is compromised, revoke it immediately from the dashboard.

Quick Start#

The base URL for the API is your region's inference endpoint. You can find the base URL for each region in the Regions section. Replace BASE_URL with the appropriate endpoint for your region.

cURL

bash
curl https://<BASE_URL>/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer sk-servellm-<your-key>" \
  -d '{
    "model": "qwen3:0.6b",
    "messages": [
      { "role": "user", "content": "Hello! What can you do?" }
    ]
  }'

Python

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-servellm-<your-key>",
    base_url="https://<BASE_URL>/v1",
)

response = client.chat.completions.create(
    model="qwen3:0.6b",
    messages=[
        {"role": "user", "content": "Hello! What can you do?"}
    ],
)

print(response.choices[0].message.content)

JavaScript / TypeScript

typescript
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "sk-servellm-<your-key>",
  baseURL: "https://<BASE_URL>/v1",
});

const response = await client.chat.completions.create({
  model: "qwen3:0.6b",
  messages: [{ role: "user", content: "Hello! What can you do?" }],
});

console.log(response.choices[0].message.content);

Chat Completions#

The primary endpoint is POST /v1/chat/completions. It is fully compatible with the OpenAI Chat Completions API.

http
POST https://<BASE_URL>/v1/chat/completions

Request body

Parameters
modelstringrequired

The model identifier to use, e.g. qwen3:0.6b or llama3.2:3b. See the Models section for available IDs.

messagesarrayrequired

Array of message objects. Each message has a role (system, user, or assistant) and a content string.

streamboolean

If true, the response is streamed back as server-sent events (SSE). Defaults to false.

temperaturenumber

Sampling temperature between 0 and 2. Higher values make output more random. Defaults to 1.

max_tokensinteger

Maximum number of tokens to generate. Model-specific limits apply.

top_pnumber

Nucleus sampling parameter. Defaults to 1.

Example response

json
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1749400000,
  "model": "qwen3:0.6b",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "I am Qwen, a large language model. I can help with ..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 14,
    "completion_tokens": 52,
    "total_tokens": 66
  }
}

Streaming#

Set "stream": true to receive tokens as they are generated via server-sent events. The stream ends with a [DONE] marker.

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-servellm-<your-key>",
    base_url="https://<BASE_URL>/v1",
)

stream = client.chat.completions.create(
    model="qwen3:0.6b",
    messages=[{"role": "user", "content": "Count to 10."}],
    stream=True,
)

for chunk in stream:
    delta = chunk.choices[0].delta.content or ""
    print(delta, end="", flush=True)

Models#

Available models are managed by the ServeLLM team and vary by region. You can list available models via the dashboard or by querying the management API once authenticated. All prices are in PKR per 1 million tokens.

Model IDNameInput / Output
qwen3:0.6bQwen 3 0.6BPKR 10 / PKR 30
qwen3:4bQwen 3 4BPKR 40 / PKR 120
llama3.2:3bLlama 3.2 3BPKR 30 / PKR 90
llama3.1:8bLlama 3.1 8BPKR 80 / PKR 240
The exact model list and pricing are set by admins and may differ from the table above. For live pricing, check the Models page in your dashboard.

Regions#

ServeLLM runs inference nodes in multiple regions. Each region has its own base URL. When you create an API key in the dashboard you can assign it to a specific region, or set your preferred region in account settings.

Region keyLocationStatus
pkPakistanActive

The selected region determines which inference node handles your request. You can pass a region preference when creating API keys. More regions will be added — check the dashboard for the latest list.

Credits & Billing#

ServeLLM uses a pre-paid credits model. Your organization holds a PKR credits balance that is debited after each successful request based on actual token usage.

Top up via JazzCash

Add credits from the Billing page using JazzCash redirect or mWallet. Payments are reflected instantly on success.

Per-token billing

Cost = (prompt tokens / 1M × input rate) + (completion tokens / 1M × output rate). Rates are in PKR and set per model.

Low balance alert

The dashboard shows a warning when your balance drops below PKR 50 so you can top up before requests are blocked.

Zero-balance blocking

When credits reach PKR 0, new requests return a 402 error. Top up to resume. Superadmin accounts are never blocked.

Error Codes#

Errors follow a standard JSON structure. Non-2xx responses include a message field describing the problem.

json
{
  "success": false,
  "message": "Invalid API key"
}
StatusMeaning
400Bad request — malformed JSON or missing required fields.
401Unauthorized — missing or invalid API key.
402Payment required — your organization has no credits remaining.
403Forbidden — your key does not have access to this resource.
404Not found — the requested model or resource does not exist.
429Too many requests — rate limit exceeded. Retry after a short delay.
500Internal server error — something went wrong on our end.
503Service unavailable — the inference node is temporarily unreachable.

Ready to start building?

Create a free account, grab an API key, and make your first request in minutes.

Get your API key