Developer Reference v1.0

Developer API & Webhooks Documentation

Integrate sovereign Pakistani language intelligence, Nastaliq tokenization, Voice AI, and real-time event webhooks into your enterprise software, CRM, mobile applications, or WhatsApp bots.

1

Authentication & Base URL

All requests to the Pak-LLM API require a secret Bearer API key generated from the Developer Panel (/developer) or Admin Dashboard. Keys are prefixed with pak_live_....

# Base API Gateway URL
https://pak-llm.com/api/v1
# Required HTTP Header
Authorization: Bearer pak_live_your_api_key_here
# Alternative Header
x-api-key: pak_live_your_api_key_here
2

Chat Completions API

POST/api/v1/chat/completions

Generates conversational completions with native Nastaliq subword compression. Supports real-time Server-Sent Events (SSE) streaming and deterministic tool calling.

FieldTypeRequiredDescription
modelstringYese.g. pak-llm-awam-v2 or pak-llm-awam-instruct-v1
messagesarrayYesArray of message objects ({ role: "system"|"user"|"assistant", content: string })
streambooleanOptionalWhen true, returns SSE stream (text/event-stream)
temperaturenumberOptionalSampling temperature (0.0 to 1.0, default: 0.7)
max_tokensnumberOptionalMaximum generation token cutoff (default: 4096)
Request Body (JSON)
{
  "model": "pak-llm-awam-v2",
  "messages": [
    {
      "role": "user",
      "content": "پاکستان میں آئی ٹی کمپنیوں پر ٹیکس استثنیٰ کی تفصیل بتائیں۔"
    }
  ],
  "temperature": 0.3
}
Response (JSON)
{
  "id": "chatcmpl_9f821a7c",
  "object": "chat.completion",
  "created": 1789456200,
  "model": "pak-llm-awam-v2",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "پاکستان میں PSEB کے ساتھ رجسٹرڈ 100% آئی ٹی برآمدی ترسیلات پر..."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 18,
    "completion_tokens": 74,
    "total_tokens": 92
  }
}
3

Models & Embeddings Registry

List available foundation models and generate semantic multilingual vector embeddings:

GET/api/v1/models

Returns active sovereign model IDs, context window sizes, and regional script capabilities.

POST/api/v1/embeddings

Generates 768-dimensional normalized dense vectors optimized for Urdu, Sindhi, and Pashto hybrid semantic search.

4

Outbound Webhook Subscriptions

Webhooks push real-time JSON events to your specified HTTPS destination endpoint as soon as operations complete in Pak-LLM.

Event KeyTrigger ConditionKey Payload Data
chat.completedAn AI inference stream or query completes{ thread_id, prompt_tokens, response_text }
workflow.completedAn automated Pak-Workflow finishes execution{ workflow_id, execution_id, step_results }
courier.dispatchedTrax or TCS consignment booked with tracking ID{ tracking_number, courier, consignee }
voice.call_endedSpoken Voice AI session terminates{ duration_seconds, persona_id, language }
5

HMAC-SHA256 Signature Verification

Every webhook payload is dispatched with cryptographic signature headers to ensure message authenticity and prevent tampering:

  • x-pakllm-signature-256: sha256=HEX_DIGEST
  • x-pakllm-timestamp: Unix epoch timestamp in milliseconds
  • x-pakllm-delivery-id: Unique delivery trace identifier
# Node.js Verification Implementation (Express/Next.js)
import crypto from "crypto";

export function verifyPakLlmWebhook(rawBody: string, signatureHeader: string, secret: string): boolean {
  if (!signatureHeader || !signatureHeader.startsWith("sha256=")) return false;
  
  const expectedSignature = "sha256=" + crypto
    .createHmac("sha256", secret)
    .update(rawBody)
    .digest("hex");

  return crypto.timingSafeEqual(
    Buffer.from(signatureHeader),
    Buffer.from(expectedSignature)
  );
}
6

Client SDK Integration (Python & Node.js)

Because Pak-LLM follows standard OpenAI REST specifications, you can use official client libraries by overriding the baseURL parameter:

# Python (pip install openai)
from openai import OpenAI

client = OpenAI(
    api_key="pak_live_your_key_here",
    base_url="https://pak-llm.com/api/v1",
)

response = client.chat.completions.create(
    model="pak-llm-awam-v2",
    messages=[{"role": "user", "content": "How are you?"}]
)
print(response.choices[0].message.content)
# TypeScript / Node.js (npm i openai)
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "pak_live_your_key_here",
  baseURL: "https://pak-llm.com/api/v1",
});

const completion = await client.chat.completions.create({
  model: "pak-llm-awam-v2",
  messages: [{ role: "user", content: "Hello Pak-LLM!" }],
});
console.log(completion.choices[0].message.content);
7

Rate Limits & HTTP Error Codes

HTTP StatusStatus CodeRemedy / Action
200 OKSuccessRequest processed successfully.
400 Bad RequestInvalid SchemaCheck JSON syntax and required messages parameter.
401 UnauthorizedInvalid KeyMissing or invalid Bearer API key. Check key prefix.
403 ForbiddenQuota ExceededMonthly token limit exhausted. Upgrade subscription plan.
429 Too Many RequestsRate Limit ExceededRPM limit reached. Implement backoff retry with jitter.
8

Security & Data Residency

Under our sovereign security policy, API request prompt bodies execute in volatile memory under strict Zero Data Retention (ZDR) agreements. No customer queries are used to train foundational models. All API keys are sealed using SHA-256 one-way hashes and secret vaults protected by NIST FIPS 203 Post-Quantum Cryptography (ML-KEM-768).

Ready to Build with Pak-LLM?

Generate your API key in seconds and start querying sovereign foundation models.

Open Developer Console