Sansxel REST API, quickstart
Authenticate, send a chat request, stream a reply. Three steps. Copy-paste examples in JavaScript and Python.
The sansxel API is a thin REST surface. One endpoint for chat, one for image generation, one for voice. Everything streams, everything uses bearer auth.
1. Get a key
Head to /account/keys, click New key, copy it. Keys are shown once, store them somewhere safe.
2. Authenticate
Send your key in the Authorization header on every request:
Authorization: Bearer sk_your_api_key_here3. Send a chat request
JavaScript:
const res = await fetch("https://sansxel.ai/api/v1/chat", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${process.env.SANSXEL_KEY}`,
},
body: JSON.stringify({
messages: [{ role: "user", content: "Hello!" }],
stream: true,
}),
});
// Stream the reply
const reader = res.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
process.stdout.write(decoder.decode(value));
}Python:
import os, requests
with requests.post(
"https://sansxel.ai/api/v1/chat",
headers={
"Content-Type": "application/json",
"Authorization": f"Bearer {os.environ['SANSXEL_KEY']}",
},
json={
"messages": [{"role": "user", "content": "Hello!"}],
"stream": True,
},
stream=True,
) as res:
for chunk in res.iter_content(chunk_size=None):
print(chunk.decode(), end="", flush=True)What you get back
With stream: true the response body is plain UTF-8 text streamed chunk by chunk. With stream: false you get a single JSON object with { text, usage } after the model finishes.
Rate limits
- Free: 50 chats / week.
- Core: 500 chats / week.
- Plus: 1,500 chats / week (unlimited with Copilot Pro Pack, included).
- Pro / Teams / Enterprise: unlimited.
Want your work in the Learn library? Apply for a hardlocked byline.