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.
Table of Contents
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_....
Chat Completions API
/api/v1/chat/completionsGenerates conversational completions with native Nastaliq subword compression. Supports real-time Server-Sent Events (SSE) streaming and deterministic tool calling.
| Field | Type | Required | Description |
|---|---|---|---|
| model | string | Yes | e.g. pak-llm-awam-v2 or pak-llm-awam-instruct-v1 |
| messages | array | Yes | Array of message objects ({ role: "system"|"user"|"assistant", content: string }) |
| stream | boolean | Optional | When true, returns SSE stream (text/event-stream) |
| temperature | number | Optional | Sampling temperature (0.0 to 1.0, default: 0.7) |
| max_tokens | number | Optional | Maximum generation token cutoff (default: 4096) |
{
"model": "pak-llm-awam-v2",
"messages": [
{
"role": "user",
"content": "پاکستان میں آئی ٹی کمپنیوں پر ٹیکس استثنیٰ کی تفصیل بتائیں۔"
}
],
"temperature": 0.3
}{
"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
}
}Models & Embeddings Registry
List available foundation models and generate semantic multilingual vector embeddings:
/api/v1/modelsReturns active sovereign model IDs, context window sizes, and regional script capabilities.
/api/v1/embeddingsGenerates 768-dimensional normalized dense vectors optimized for Urdu, Sindhi, and Pashto hybrid semantic search.
Outbound Webhook Subscriptions
Webhooks push real-time JSON events to your specified HTTPS destination endpoint as soon as operations complete in Pak-LLM.
| Event Key | Trigger Condition | Key Payload Data |
|---|---|---|
| chat.completed | An AI inference stream or query completes | { thread_id, prompt_tokens, response_text } |
| workflow.completed | An automated Pak-Workflow finishes execution | { workflow_id, execution_id, step_results } |
| courier.dispatched | Trax or TCS consignment booked with tracking ID | { tracking_number, courier, consignee } |
| voice.call_ended | Spoken Voice AI session terminates | { duration_seconds, persona_id, language } |
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
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)
);
}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:
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)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);Rate Limits & HTTP Error Codes
| HTTP Status | Status Code | Remedy / Action |
|---|---|---|
| 200 OK | Success | Request processed successfully. |
| 400 Bad Request | Invalid Schema | Check JSON syntax and required messages parameter. |
| 401 Unauthorized | Invalid Key | Missing or invalid Bearer API key. Check key prefix. |
| 403 Forbidden | Quota Exceeded | Monthly token limit exhausted. Upgrade subscription plan. |
| 429 Too Many Requests | Rate Limit Exceeded | RPM limit reached. Implement backoff retry with jitter. |
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.