---
title: Quickstart
description: Send your first SubQ Decisions API request.
---

Make your first API request in minutes.

**Decision Models:** [`subq-snap-1.2`](/using-the-api/models/#subq-snap-12) is available to all accounts for returning decision outputs.

**Text generation models (Early Access):** SubQ Savant ([`subq-savant-1.4`](/using-the-api/models/#subq-savant-14)) generates text over long context but requires organization enablement. [Join the waitlist](https://subq.ai/small#waitlist).

## Start with a coding agent

Paste this prompt into your coding agent:

```text title="Prompt"
Read https://docs.subq.ai/markdown/index.md and follow it to set up the SubQ API in this codebase: help me create an API key, store it as SUBQ_API_KEY outside the code, and make a first request to confirm it works.
```

To run the steps yourself, continue below.

## 1. Get your API key

Sign up at [console.subq.ai](https://console.subq.ai) and create an API key from
the dashboard. Store it in an environment variable:

```bash
export SUBQ_API_KEY="sk-your-api-key"
```

## 2. Check account access

Make sure your account has credits before sending requests. A request without
available credits returns `402`.

## 3. Send a request

```bash title="cURL"
curl --request POST \
  --url https://api.subq.ai/v1/systemone \
  --header "Authorization: Bearer $SUBQ_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "subq-snap-1.2",
  "state": "Patient with asthma reports a sore throat, fever since yesterday, and shortness of breath walking to the kitchen this morning.",
  "questions": {
    "escalate": {
      "type": "noul",
      "instructions": "Should a nurse see this chat before the patient books anything?",
      "criteria": {
        "true": "Breathing trouble, chest pain, or a flare of a known condition",
        "false": "Stable symptoms the patient can book for themselves"
      }
    }
  }
}
'
```

```ts title="TypeScript"
const baseURL = "https://api.subq.ai/v1";

const response = await fetch(`${baseURL}/systemone`, {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.SUBQ_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "subq-snap-1.2",
    state:
      "Patient with asthma reports a sore throat, fever since yesterday, and shortness of breath walking to the kitchen this morning.",
    questions: {
      escalate: {
        type: "noul",
        instructions: "Should a nurse see this chat before the patient books anything?",
        criteria: {
          true: "Breathing trouble, chest pain, or a flare of a known condition",
          false: "Stable symptoms the patient can book for themselves",
        },
      },
    },
  }),
});

if (!response.ok) {
  const error = await response.json();
  throw new Error(
    `${response.status} ${error.detail.error_type}: ${error.detail.message}`,
  );
}

const result = await response.json();
console.log(`Escalate: ${result.answers.escalate.noul.toFixed(2)}`);
```

```py title="Python"
import json
import os
import urllib.error
import urllib.request

base_url = "https://api.subq.ai/v1"

request = urllib.request.Request(
    f"{base_url}/systemone",
    method="POST",
    headers={
        "Authorization": f"Bearer {os.environ['SUBQ_API_KEY']}",
        "Content-Type": "application/json",
    },
    data=json.dumps(
        {
            "model": "subq-snap-1.2",
            "state": (
                "Patient with asthma reports a sore throat, fever since "
                "yesterday, and shortness of breath walking to the kitchen "
                "this morning."
            ),
            "questions": {
                "escalate": {
                    "type": "noul",
                    "instructions": (
                        "Should a nurse see this chat before the patient "
                        "books anything?"
                    ),
                    "criteria": {
                        "true": (
                            "Breathing trouble, chest pain, or a flare of a "
                            "known condition"
                        ),
                        "false": (
                            "Stable symptoms the patient can book for "
                            "themselves"
                        ),
                    },
                },
            },
        }
    ).encode(),
)

try:
    with urllib.request.urlopen(request, timeout=60) as response:
        result = json.load(response)
except urllib.error.HTTPError as error:
    detail = json.load(error)["detail"]
    raise RuntimeError(
        f"{error.code} {detail['error_type']}: {detail['message']}"
    ) from error

print(f"Escalate: {result['answers']['escalate']['noul']:.2f}")
```

The answer is in `answers.escalate.noul`, the probability of yes from `0` to
`1`. See the [Decisions API](/endpoints/decisions-api/) for choice and score
questions, images, and errors.

## Generate text with SubQ Savant

SubQ Savant is in early access and is OpenAI-compatible. Use the OpenAI SDK
with its base URL set to `https://api.subq.ai/v1`, or call
`POST https://api.subq.ai/v1/chat/completions` directly.

```bash title="cURL"
curl --request POST \
  --url https://api.subq.ai/v1/chat/completions \
  --header "Authorization: Bearer $SUBQ_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "subq-savant-1.4",
  "messages": [
    {
      "role": "user",
      "content": "A vendor contract says: Either party may terminate this Agreement for convenience upon ninety (90) days prior written notice. How much notice do we need to give to cancel? Answer in one sentence."
    }
  ]
}
'
```

```ts title="TypeScript"
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.SUBQ_API_KEY,
  baseURL: "https://api.subq.ai/v1",
});

const completion = await client.chat.completions.create({
  model: "subq-savant-1.4",
  messages: [
    {
      role: "user",
      content:
        "A vendor contract says: Either party may terminate this Agreement for convenience upon ninety (90) days prior written notice. How much notice do we need to give to cancel? Answer in one sentence.",
    },
  ],
});

console.log(completion.choices[0].message.content);
```

```py title="Python"
import os

from openai import OpenAI

client = OpenAI(
    api_key=os.environ["SUBQ_API_KEY"],
    base_url="https://api.subq.ai/v1",
)

completion = client.chat.completions.create(
    model="subq-savant-1.4",
    messages=[
        {
            "role": "user",
            "content": (
                "A vendor contract says: Either party may terminate this "
                "Agreement for convenience upon ninety (90) days prior written "
                "notice. How much notice do we need to give to cancel? Answer "
                "in one sentence."
            ),
        }
    ],
)

print(completion.choices[0].message.content)
```

The answer is in `choices[0].message.content`:

```text
You need to give 90 days' written notice.
```

A `403` `model_not_allowed` means Savant isn't enabled for your organization
yet. See the [Chat Completions API](/endpoints/chat-completions-api/) for
reasoning, token limits, files, and errors, and
[Models](/using-the-api/models/#subq-savant-14) for the context window and
pricing.
