SDK & thư viện
API của xAI là REST thuần JSON nên dùng được với bất kỳ ngôn ngữ nào qua HTTP client có sẵn. SDK chính thức đang trong lộ trình; dưới đây là các client gọn nhẹ để bắt đầu ngay.
Trạng thái SDK
SDK chính thức cho JavaScript/TypeScript và Python đang được phát triển. Theo dõi changelog để cập nhật.
JavaScript / TypeScript
Chạy trên trình duyệt hoặc Node/Workers. Dùng credentials: "include" để gửi cookie SSO.
// xAI ecosystem — client gọn nhẹ bằng fetch (chưa cần SDK chính thức)
const XAI = {
base: {
identity: 'https://identity.xai.io.vn',
governance: 'https://governance.xai.io.vn',
blockchain: 'https://blockchain.xai.io.vn',
},
async session() {
const r = await fetch(this.base.identity + '/api/session', { credentials: 'include' });
return r.json();
},
async anchor(payload) {
const r = await fetch(this.base.blockchain + '/api/anchor', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
});
return r.json();
},
};
const session = await XAI.session(); Python
Dùng requests.Session để giữ cookie phiên giữa các lần gọi.
import requests
BASE = {
"identity": "https://identity.xai.io.vn",
"governance": "https://governance.xai.io.vn",
"blockchain": "https://blockchain.xai.io.vn",
}
def anchor(payload: dict, session: requests.Session) -> dict:
r = session.post(f"{BASE['blockchain']}/api/anchor", json=payload)
r.raise_for_status()
return r.json()
s = requests.Session()
result = anchor({
"scenario": "e_invoice",
"payloadId": "INV-2026-001",
"dataFields": {"taxId": "0312345678", "amount": 500_000_000},
}, s) cURL
Mọi endpoint đều thử nhanh được bằng cURL — xem ví dụ trong từng trang API reference.