Quickstart
This guide takes you from authenticating a user to your first API call in minutes. Every example uses real xAI ecosystem APIs.
Prerequisites
An xAI Identity account (sign up at identity.xai.io.vn). Your app should run on a *.xai.io.vn subdomain to use cookie-based SSO.
Step 1 — Authenticate the user
Call the introspection endpoint to check whether the user is signed in. The xv_session cookie is sent automatically across .xai.io.vn subdomains.
// Kiểm tra người dùng đã đăng nhập (trình duyệt tự gửi cookie xv_session)
const res = await fetch('https://identity.xai.io.vn/api/session', {
credentials: 'include',
});
const session = await res.json();
if (!session.authenticated) {
// Chưa đăng nhập → chuyển tới trang đăng nhập trung tâm
const back = encodeURIComponent(location.href);
location.href =
'https://identity.xai.io.vn/login?client_id=my-app&redirect=' + back;
} Step 2 — Call a product API
Example: anchor an invoice fingerprint on the ledger with xAI Blockchain. The public sandbox runs in mock mode, no wallet required.
curl -X POST 'https://blockchain.xai.io.vn/api/anchor' \
-H 'Content-Type: application/json' \
-d '{
"scenario": "e_invoice",
"payloadId": "INV-2026-001",
"dataFields": { "taxId": "0312345678", "amount": 500000000 }
}' Step 3 — Use an AI-powered API
xAI Governance offers Workers AI-powered APIs. For example, classify an AI system risk tier per the EU AI Act:
const res = await fetch('https://governance.xai.io.vn/api/ai/classify-risk', {
method: 'POST',
credentials: 'include',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ description: 'Chấm điểm tín dụng tự động', lang: 'vi' }),
});
const { tier, obligations } = await res.json(); Next steps