Platform
ScaiWave ScaiGrid ScaiCore ScaiBot ScaiDrive ScaiKey Models Tools & Services
Solutions
Organisations Developers Internet Service Providers Managed Service Providers AI-in-a-Box
Resources
Support Documentation Blog Downloads
Company
About Research Careers Investment Opportunities Contact
Log in

Quickstart

Your first ScaiGrid chat completion in five minutes. Assumes you already have a ScaiGrid instance (managed or self-hosted) and a user account.

1. Get an API key#

From the admin UI: Access → API Keys → Create. Name it something meaningful (my-first-integration). Copy the key — it starts with sgk_ and is shown exactly once.

If you don't have admin UI access, ask your tenant admin to create one for you.

2. Pick a model#

List the models available to you:

bash
1
2
curl -H "Authorization: Bearer $SCAIGRID_API_KEY" \
     https://scaigrid.scailabs.ai/v1/models

You'll get a response like:

json
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
{
  "status": "ok",
  "data": {
    "items": [
      {
        "slug": "scailabs/poolnoodle-omni",
        "display_name": "Poolnoodle Omni",
        "modality": "chat",
        "context_window": 256000,
        "max_output_tokens": 32768
      },
      {
        "slug": "openai/gpt-4o",
        "display_name": "GPT-4o",
        "modality": "chat",
        "context_window": 128000
      }
    ]
  }
}

Pick a slug you like. For this quickstart we'll use scailabs/poolnoodle-omni.

3. Send a chat completion#

Request#

bash
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
curl -X POST https://scaigrid.scailabs.ai/v1/inference/chat \
  -H "Authorization: Bearer $SCAIGRID_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "scailabs/poolnoodle-omni",
    "messages": [
      {"role": "user", "content": "Write a haiku about distributed systems."}
    ],
    "max_tokens": 100
  }'
python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
import os
import httpx

resp = httpx.post(
    "https://scaigrid.scailabs.ai/v1/inference/chat",
    headers={"Authorization": f"Bearer {os.environ['SCAIGRID_API_KEY']}"},
    json={
        "model": "scailabs/poolnoodle-omni",
        "messages": [
            {"role": "user", "content": "Write a haiku about distributed systems."}
        ],
        "max_tokens": 100,
    },
)
resp.raise_for_status()
data = resp.json()
print(data["data"]["choices"][0]["message"]["content"])
typescript
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
const resp = await fetch("https://scaigrid.scailabs.ai/v1/inference/chat", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.SCAIGRID_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "scailabs/poolnoodle-omni",
    messages: [
      { role: "user", content: "Write a haiku about distributed systems." }
    ],
    max_tokens: 100,
  }),
});
const data = await resp.json();
console.log(data.data.choices[0].message.content);

Response#

json
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
{
  "status": "ok",
  "data": {
    "id": "chatcmpl-abc123",
    "model": "scailabs/poolnoodle-omni",
    "created": 1713888000,
    "choices": [
      {
        "index": 0,
        "message": {
          "role": "assistant",
          "content": "Nodes whisper through time,\nConsensus blooms from chaos,\nOne truth from many."
        },
        "finish_reason": "stop"
      }
    ],
    "usage": {
      "prompt_tokens": 12,
      "completion_tokens": 21,
      "total_tokens": 33
    },
    "_meta": {"request_id": "req_xyz789", "latency_ms": 842}
  },
  "meta": {"request_id": "req_xyz789"}
}

That's it. You just made a ScaiGrid chat completion.

4. Stream responses#

For long completions, stream tokens as they arrive:

python
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import os
import httpx
import json

with httpx.stream(
    "POST",
    "https://scaigrid.scailabs.ai/v1/inference/chat",
    headers={"Authorization": f"Bearer {os.environ['SCAIGRID_API_KEY']}"},
    json={
        "model": "scailabs/poolnoodle-omni",
        "messages": [{"role": "user", "content": "Tell me a long story."}],
        "stream": True,
    },
    timeout=600,
) as r:
    for line in r.iter_lines():
        if line.startswith("data: "):
            payload = line[6:]
            if payload == "[DONE]":
                break
            chunk = json.loads(payload)
            delta = chunk["choices"][0]["delta"].get("content", "")
            print(delta, end="", flush=True)
typescript
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const resp = await fetch("https://scaigrid.scailabs.ai/v1/inference/chat", {
  method: "POST",
  headers: {
    "Authorization": `Bearer ${process.env.SCAIGRID_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "scailabs/poolnoodle-omni",
    messages: [{ role: "user", content: "Tell me a long story." }],
    stream: true,
  }),
});

const reader = resp.body!.getReader();
const decoder = new TextDecoder();
let buf = "";
while (true) {
  const { done, value } = await reader.read();
  if (done) break;
  buf += decoder.decode(value, { stream: true });
  const lines = buf.split("\n");
  buf = lines.pop()!;
  for (const line of lines) {
    if (!line.startsWith("data: ")) continue;
    const payload = line.slice(6);
    if (payload === "[DONE]") return;
    const chunk = JSON.parse(payload);
    process.stdout.write(chunk.choices[0].delta.content || "");
  }
}

See Chat Completions for the full streaming protocol, error handling, and tool calls.

What's next#

Updated 2026-05-18 15:01:28 View source (.md) rev 17