---
title: Quickstart
path: getting-started/quickstart
status: published
---

# 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
curl -H "Authorization: Bearer $SCAIGRID_API_KEY" \
     https://scaigrid.scailabs.ai/v1/models
```

You'll get a response like:

```json
{
  "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
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
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
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
{
  "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
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
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](../04-api-guides/01-chat-completions.md) for the full streaming protocol, error handling, and tool calls.

## What's next

- [Authentication](./02-authentication.md) — API keys vs JWTs, when to use which.
- [Your First Integration](./03-your-first-integration.md) — a complete walk-through with error handling, retries, and accounting.
- [Chat Completions](../04-api-guides/01-chat-completions.md) — the full chat API reference.
