> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nano-gpt.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Decisions

> Typed choices, scores, and yes/no probabilities from decision models.

## Overview

Decision models answer named, typed questions about the state you provide instead of generating prose:

* `choice` selects one named option and returns a probability for every option.
* `score` returns an expected score over an ordered rubric.
* `noul` returns the probability that a yes/no statement is true.

Image-capable decision models can also evaluate photos and return the same typed answers. Supported formats and limits vary by model; see [Image input](#image-input), [Bison-1 and Groundhog-1](#bison-1-and-groundhog-1), and [Mercury Decide](#mercury-decide).

For new HTTP integrations, use the native `POST /api/v1/decisions` endpoint. If you already use the official TypeSafe SDK, point it at NanoGPT's `POST /api/v1/systemone` compatibility endpoint. Most decision models are also available through NanoGPT's OpenAI-compatible Chat Completions and Responses APIs and the Anthropic-compatible Messages API. Mercury Decide requires the native Decisions endpoint.

Only input tokens are billed. Browse every decision model, with current pricing, on [nano-gpt.com/models/decisions](https://nano-gpt.com/models/decisions), or list them with `GET /api/v1/decision-models`.

> [!NOTE]
>
> Decision models work on both API hosts. The examples use the direct API host, `https://api.nano-gpt.com`; `https://nano-gpt.com` accepts the same requests. See [API Hosts](https://docs.nano-gpt.com/api-reference/miscellaneous/api-hosts.md).
>
> Before using a model on either host, check that host’s `GET /api/v1/models?detailed=true&output_modalities=decisions` catalog for the model, its `supported_endpoints`, and its `decision_input` capabilities and limits. Catalogs can differ during rollouts.

> [!NOTE]
>
> Decision models return calibrated probabilities, not generated text. Use a chat model when you need an explanation or other free-form response.

## Models

| Model | Context | Images | Use |
| - | - | - | - |
| `typesafe/jev-1.13` | 32K | No | TypeSafe Jev 1.13, pinned for integrations that should not follow alias upgrades. |
| `typesafe/jev-latest` | 32K | No | Moving alias for the latest TypeSafe Jev release. |
| `liquid/d1` | 64K | No | Liquid AI's D1. |
| `baselabs/bison-1` | 32,768 per question | Yes, PNG | Base Labs' dense decision model for classification, routing and scoring. |
| `baselabs/groundhog-1` | 16,384 per question | Yes, PNG | Lower-cost Base Labs decision model. |
| `inception/mercury-decide` | 65,536; 32,768 for extraction | Yes | Native Decisions endpoint only; supports exact text-span extraction. |
| `perplexity/pplx-decider-v1.2` | 262K | Yes | Perplexity's PPLX Decider v1.2. Supports zero data retention. |
| `cloudflare/clef` | 1,800 text tokens | Yes | Cloudflare's open decision model. |
| `cloudflare/clef-flash` | 1,800 text tokens | Yes | Lower-cost Clef variant. |

Use `perplexity/pplx-decider-v1.2` for PPLX integrations. Requests for the retired `perplexity/pplx-decider-v1.1-27b` ID return HTTP 410 with code `model_retired`; update the model ID explicitly to use v1.2. The v1.2 price is \$0.02 per million input tokens, with free output.

Clef also accepts `clef`. The System One compatibility endpoint also accepts the official SDK model names `jev-1.13` and `jev-latest`. `GET /api/v1/models` leaves decision models out, because they reject plain chat requests. List them with `GET /api/v1/decision-models`, which returns detailed entries by default (`detailed=false` for IDs only), or add `output_modalities=decisions` to `/api/v1/models` and its subscription, paid and personalized variants. Each entry has `architecture.output_modalities: ["decisions"]`, a `supported_endpoints` list, and a `decision_input` object. `decision_input.image_input` is `true` for the image-capable models, and `decision_input.image_limits` lists their limits.

For Clef and Clef Flash, the 1,800-token limit covers all text in the request, including `state` text, `questions` and request overhead. Images are counted separately; see [Image input](#image-input).

### Bison-1 and Groundhog-1

Use `baselabs/bison-1` or `baselabs/groundhog-1` with the native Decisions or
System One endpoint. The short IDs `bison-1` and `groundhog-1` also work. Typed
questions are supported through Chat Completions, Messages and Responses with
text input. Neither model generates prose or supports streaming, tools or reasoning.

Bison-1 costs $0.10 per million input tokens; Groundhog-1 costs $0.035. Answer
tokens are free. Shared state is billed once, plus each question, including image
tokens. Cached input uses the ordinary input rate. Both models are excluded from
subscriptions and subscriber discounts.

Each request accepts 1–256 questions with non-empty text `instructions` and
non-empty text criterion descriptions. A `choice` question accepts 1–255 options;
a `score` question requires 2–10 levels. Across all questions, the maximum is 512
options, with each `noul` question counting as two. For `noul`, omit `criteria` or
provide exactly `true` and `false` descriptions.

NanoGPT applies conservative input admission limits of 32,768 tokens per question
for Bison-1 and 16,384 for Groundhog-1. Each limit includes shared state, the
question, criteria, formatting and images. Aggregate billed input across multiple
questions can exceed one question's context limit.

Send text, a JSON object, or an array as `state`. A top-level `null` or an object
with a `messages` key is unsupported. Image input must be placed directly in a
`state` array: up to four static inline PNG images, each at most 512 × 512 pixels.
All images together may contain at most 240,000 base64 characters (180,000 decoded
bytes), within a 1 MiB JSON request body. Remote URLs, JPEG and WebP are unsupported.
Omit `image_url.detail` or set it to `auto`.

Omit `user`, `session_id` and `trace`, including when adapting the examples below.
The `provider` object accepts only `zdr` and `data_collection`; provider selection
is unavailable. Zero data retention is unverified: requests requiring
`provider.zdr: true`, an API-key ZDR policy, or `provider.data_collection: "deny"`
return `400 zdr_not_supported`. Transport redaction is unsupported, and image
input cannot be combined with PII redaction.

### Mercury Decide

Use `inception/mercury-decide` (or `mercury-decide`) only with
`POST /api/v1/decisions`. It does not support System One, Chat Completions,
Responses, or Messages compatibility endpoints. It costs \$0.02 per million input
tokens at the current launch price, with no output charge. It is not included in
subscriptions and is excluded from subscriber discounts.

Omit `user`, `session_id`, and `trace` when selecting Mercury Decide, including
when adapting the native examples below. These fields return HTTP 400 with code
`parameter_not_supported`. A minimal extraction request is:

```json theme={null}
{
  "model": "inception/mercury-decide",
  "state": "Parcel A123 arrived.",
  "questions": {
    "parcel": {
      "type": "extract",
      "instructions": "The parcel identifier"
    }
  }
}
```

Mercury Decide accepts 1–64 named questions of type `noul`, `choice`, `score`, or
`extract`. Text or JSON state is supported. Image requests accept up to four
inline PNG images in a state array; remote image URLs are unsupported. Extraction
is text-only, supports up to 26 fields per question, and returns exact spans with
Unicode code-point offsets. Check `decision_input` in the
[live decision catalog](https://api.nano-gpt.com/api/v1/decision-models) for image
size limits and extraction controls.

Zero data retention and provider selection are unavailable. Requests requiring
`provider.zdr: true` or `provider.data_collection: "deny"` are rejected. Transport
redaction is unsupported, and extraction cannot use masked or redacted input.

## Native Decisions API

### Endpoint

```text theme={null}
POST https://api.nano-gpt.com/api/v1/decisions
```

Authenticate with either `Authorization: Bearer YOUR_API_KEY` or `x-api-key: YOUR_API_KEY`.

### Example request

```bash cURL theme={null}
curl https://api.nano-gpt.com/api/v1/decisions \
  -H "Authorization: Bearer $NANOGPT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "typesafe/jev-1.13",
    "state": {
      "ticket": "I was charged twice and need this fixed before Friday.",
      "customer_tier": "business"
    },
    "questions": {
      "route": {
        "type": "choice",
        "instructions": "Which team should handle this ticket?",
        "criteria": {
          "billing": "Payments, invoices, refunds, or duplicate charges",
          "technical": "Product behavior, bugs, or integrations",
          "sales": "Plans, pricing, or purchasing"
        }
      },
      "urgency": {
        "type": "score",
        "instructions": "How urgent is the ticket?",
        "criteria": [
          "No time pressure",
          "Can wait several days",
          "Needs attention within one business day",
          "Immediate action is required"
        ]
      },
      "needs_human_review": {
        "type": "noul",
        "instructions": "Does this ticket need human review?",
        "criteria": {
          "true": "A person should review the case",
          "false": "Automation can safely handle the case"
        }
      }
    },
    "user": "customer_123"
  }'
```

```javascript JavaScript theme={null}
const response = await fetch("https://api.nano-gpt.com/api/v1/decisions", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.NANOGPT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "typesafe/jev-1.13",
    state: {
      ticket: "I was charged twice and need this fixed before Friday.",
      customer_tier: "business",
    },
    questions: {
      route: {
        type: "choice",
        instructions: "Which team should handle this ticket?",
        criteria: {
          billing: "Payments, invoices, refunds, or duplicate charges",
          technical: "Product behavior, bugs, or integrations",
          sales: "Plans, pricing, or purchasing",
        },
      },
      urgency: {
        type: "score",
        instructions: "How urgent is the ticket?",
        criteria: [
          "No time pressure",
          "Can wait several days",
          "Needs attention within one business day",
          "Immediate action is required",
        ],
      },
      needs_human_review: {
        type: "noul",
        instructions: "Does this ticket need human review?",
        criteria: {
          true: "A person should review the case",
          false: "Automation can safely handle the case",
        },
      },
    },
    user: "customer_123",
  }),
});

if (!response.ok) throw new Error(await response.text());
const decision = await response.json();
console.log(decision.answers);
```

```python Python theme={null}
import os
import requests

response = requests.post(
    "https://api.nano-gpt.com/api/v1/decisions",
    headers={
        "Authorization": f"Bearer {os.environ['NANOGPT_API_KEY']}",
        "Content-Type": "application/json",
    },
    json={
        "model": "typesafe/jev-1.13",
        "state": {
            "ticket": "I was charged twice and need this fixed before Friday.",
            "customer_tier": "business",
        },
        "questions": {
            "route": {
                "type": "choice",
                "instructions": "Which team should handle this ticket?",
                "criteria": {
                    "billing": "Payments, invoices, refunds, or duplicate charges",
                    "technical": "Product behavior, bugs, or integrations",
                    "sales": "Plans, pricing, or purchasing",
                },
            },
            "urgency": {
                "type": "score",
                "instructions": "How urgent is the ticket?",
                "criteria": [
                    "No time pressure",
                    "Can wait several days",
                    "Needs attention within one business day",
                    "Immediate action is required",
                ],
            },
            "needs_human_review": {
                "type": "noul",
                "instructions": "Does this ticket need human review?",
                "criteria": {
                    "true": "A person should review the case",
                    "false": "Automation can safely handle the case",
                },
            },
        },
        "user": "customer_123",
    },
    timeout=30,
)
response.raise_for_status()
print(response.json()["answers"])
```

### Example response

```json theme={null}
{
  "id": "decision_...",
  "model": "typesafe/jev-1.13",
  "answers": {
    "route": {
      "type": "choice",
      "choice": "billing",
      "confidence": 0.97,
      "probabilities": {
        "billing": 0.97,
        "technical": 0.02,
        "sales": 0.01
      }
    },
    "urgency": {
      "type": "score",
      "score": 2.63,
      "confidence": 0.81,
      "legend": {
        "0": "No time pressure",
        "1": "Can wait several days",
        "2": "Needs attention within one business day",
        "3": "Immediate action is required"
      },
      "probabilities": {
        "0": 0.01,
        "1": 0.05,
        "2": 0.24,
        "3": 0.70
      }
    },
    "needs_human_review": {
      "type": "noul",
      "noul": 0.84
    }
  },
  "usage": {
    "input_tokens": 126,
    "output_tokens": 8,
    "estimated_cost": 0.000005292
  }
}
```

`noul` is the probability of the `true` outcome. A `score` can be fractional because it is the expected value across the returned score distribution.

### Usage and cost

Every response reports `usage.input_tokens` and `usage.output_tokens`. Only input tokens are billed; output tokens are free.

By default, the response is returned as soon as the answers are ready, and billing settles immediately afterwards. The charge itself is unaffected. These responses report `usage.estimated_cost`: the model's published input price for the reported input tokens, in USD. It does not include account discounts or payment-currency conversion, so your actual charge can differ.

To get the exact amount charged instead, send `"include_usage": true`. The response then waits for billing to settle and reports the exact charge, in USD, as `usage.cost` instead of `usage.estimated_cost`. This adds a little latency. Your usage history always shows the exact charge.

```json theme={null}
"usage": {
  "input_tokens": 126,
  "output_tokens": 8,
  "cost": 0.000005027
}
```

### Declined questions

A decision model can decline individual questions. On models that do this, such as GPT-6 Luna Decisions, a declined question comes back with only a `type`, and the other questions keep their answers:

```json theme={null}
"answers": {
  "needs_human_review": { "type": "refusal" },
  "route": {
    "type": "choice",
    "choice": "billing",
    "confidence": 0.97,
    "probabilities": { "billing": 0.97, "technical": 0.03 }
  }
}
```

Check each answer's `type` before reading its value. A response with a declined question returns `200` and is charged normally. If every question is declined, the request returns `400` with the code `content_policy_violation` and isn't charged. The compatibility endpoints return a declined question the same way, inside the JSON text. The official TypeSafe JavaScript SDK returns it as is. The Python SDK drops answer types it doesn't recognize and logs a warning, so a declined question is simply missing from `answers`.

### Image input

`perplexity/pplx-decider-v1.2`, `cloudflare/clef` and `cloudflare/clef-flash` accept images on the native `POST /api/v1/decisions` endpoint and the `POST /api/v1/systemone` compatibility endpoint. Use them to classify photos, score visual content, or answer yes/no questions about an image.

Make `state` an array, and put each image directly in it as an `image_url` part with a base64 data URL. Plain strings in the same array add text context. The optional `image_url.detail` field accepts `auto`, `low` or `high`.

```bash cURL theme={null}
IMAGE=$(base64 < return-photo.jpg | tr -d '\n')

curl https://api.nano-gpt.com/api/v1/decisions \
  -H "Authorization: Bearer $NANOGPT_API_KEY" \
  -H "Content-Type: application/json" \
  -d @- <<EOF
{
  "model": "perplexity/pplx-decider-v1.2",
  "state": [
    "Return claim photo.",
    { "type": "image_url", "image_url": { "url": "data:image/jpeg;base64,$IMAGE" } }
  ],
  "questions": {
    "condition": {
      "type": "choice",
      "instructions": "What condition is the returned item in?",
      "criteria": {
        "like_new": "No visible wear",
        "used": "Normal signs of use",
        "damaged": "Cracked, broken or missing parts"
      }
    },
    "screen_cracked": {
      "type": "noul",
      "instructions": "Is the screen cracked?"
    }
  }
}
EOF
```

```javascript JavaScript theme={null}
import { readFile } from "node:fs/promises";

const image = (await readFile("return-photo.jpg")).toString("base64");

const response = await fetch("https://api.nano-gpt.com/api/v1/decisions", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.NANOGPT_API_KEY}`,
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    model: "perplexity/pplx-decider-v1.2",
    state: [
      "Return claim photo.",
      { type: "image_url", image_url: { url: `data:image/jpeg;base64,${image}` } },
    ],
    questions: {
      condition: {
        type: "choice",
        instructions: "What condition is the returned item in?",
        criteria: {
          like_new: "No visible wear",
          used: "Normal signs of use",
          damaged: "Cracked, broken or missing parts",
        },
      },
      screen_cracked: {
        type: "noul",
        instructions: "Is the screen cracked?",
      },
    },
  }),
});

if (!response.ok) throw new Error(await response.text());
console.log((await response.json()).answers);
```

```python Python theme={null}
import base64
import os
import requests

with open("return-photo.jpg", "rb") as f:
    image = base64.b64encode(f.read()).decode()

response = requests.post(
    "https://api.nano-gpt.com/api/v1/decisions",
    headers={"Authorization": f"Bearer {os.environ['NANOGPT_API_KEY']}"},
    json={
        "model": "perplexity/pplx-decider-v1.2",
        "state": [
            "Return claim photo.",
            {"type": "image_url", "image_url": {"url": f"data:image/jpeg;base64,{image}"}},
        ],
        "questions": {
            "condition": {
                "type": "choice",
                "instructions": "What condition is the returned item in?",
                "criteria": {
                    "like_new": "No visible wear",
                    "used": "Normal signs of use",
                    "damaged": "Cracked, broken or missing parts",
                },
            },
            "screen_cracked": {
                "type": "noul",
                "instructions": "Is the screen cracked?",
            },
        },
    },
    timeout=30,
)
response.raise_for_status()
print(response.json()["answers"])
```

To compare several images, put a label before each one, for example `["Photo 1", image1, "Photo 2", image2]`, and refer to the labels in your question criteria.

The following limits apply to PPLX Decider v1.2, Clef and Clef Flash. For the PNG-only
Base Labs models, use the [Bison-1 and Groundhog-1 limits](#bison-1-and-groundhog-1).

| Limit | Value |
| - | - |
| Images per request | Up to 4 |
| Formats | Static PNG, JPEG or WebP, sent inline as base64 data URLs. Remote image URLs are not fetched, and animated images are rejected. |
| Dimensions | Each image at most 512 × 512 pixels |
| Size | All images together at most 240,000 base64 characters (180,000 decoded bytes); the whole JSON body at most 1 MiB |
| Questions | Up to 128 per request |
| Text | Clef and Clef Flash: at most 1,800 text tokens, including questions and request overhead |

Images are billed as input tokens at the model's normal input price; `usage.input_tokens` includes them. Resize larger photos before sending them.

Privacy rules for image requests:

* PPLX Decider v1.2 supports zero data retention: set `provider.zdr` to `true`, or use an API key with a ZDR policy.
* Clef and Clef Flash do not support zero data retention. On these models, requests that require ZDR, and image requests with `provider.data_collection: "deny"`, return `400`.
* Image input cannot be combined with PII redaction.
* PII redaction uses the provider you chose (Tinfoil or Grepture; see [PII Redaction](https://docs.nano-gpt.com/api-reference/miscellaneous/pii-redaction.md)). Tinfoil-hosted decision models do not support it.

Image errors use these codes:

| Status | Code | Meaning |
| - | - | - |
| 400 | `invalid_image` | The image is not a valid static PNG, JPEG or WebP data URL, or it is not placed directly in the `state` array. |
| 400 | `unsupported_modality` | The model does not accept images, or the requested privacy settings are not available for image input. |
| 413 | `image_too_large` | An image, or all images together, exceed the limits above. A JSON body over 1 MiB returns `413 request_body_too_large`. |
| 400 | `context_length_exceeded` | The text and images exceed the model's input limit. |

The Chat Completions, Responses and Messages compatibility endpoints accept text only.

## Question types

| Type | Required fields | Answer |
| - | - | - |
| `choice` | `instructions` and a non-empty `criteria` object | `choice`, `confidence`, and `probabilities` keyed by the supplied labels |
| `score` | `instructions` and 2-10 ordered `criteria` entries | Fractional `score`, `confidence`, `legend`, and `probabilities` keyed from `0` |
| `noul` | `instructions`; optional `criteria.true` and `criteria.false` descriptions | `noul`, a probability from `0` to `1` |

`instructions` and criterion descriptions can be strings, non-empty JSON objects, or non-empty arrays on models that support structured criteria. A `choice` criterion may also be `null` when its label is self-explanatory. Bison-1 and Groundhog-1 require non-empty text instructions and criterion descriptions. The top-level `state` can be a string, JSON object, or JSON array. Question names become keys in `answers`. Any question can come back [declined](#declined-questions) instead.

## Model-specific rules

| Rule | Applies to |
| - | - |
| Noul questions need `instructions`, and `criteria` needs both `true` and `false` when it is sent. | Jev, Liquid D1, PPLX Decider v1.2, Clef, Clef Flash |
| A request can contain at most 128 questions. | PPLX Decider v1.2, Clef, Clef Flash |
| Text input, including questions and request overhead, is limited to 1,800 tokens. | Clef, Clef Flash |

## Request fields

| Field | Type | Required | Description |
| - | - | -: | - |
| `model` | string | Yes | A decision model from the table above. |
| `state` | string, object, or array | Yes | Application state for the model to evaluate. Image-capable models also accept image parts in a `state` array; see [Image input](#image-input). |
| `questions` | object | Yes | One or more named `choice`, `score`, or `noul` questions. Mercury Decide also supports `extract`. |
| `user` | string | No | Your end-user identifier, up to 256 characters. Unsupported by Mercury Decide, Bison-1 and Groundhog-1; omit it for these models. |
| `session_id` | string | No | Your session identifier, up to 256 characters. Unsupported by Mercury Decide, Bison-1 and Groundhog-1; omit it for these models. |
| `trace` | object | No | Caller-supplied trace metadata. Unsupported by Mercury Decide, Bison-1 and Groundhog-1; omit it for these models. |
| `provider` | object or null | No | Model-specific routing controls, described below. Usually omit this field. |
| `include_usage` | boolean | No | Wait for billing to settle and report the exact charge as `usage.cost`. Defaults to `false`, which returns `usage.estimated_cost` without waiting. See [Usage and cost](#usage-and-cost). |

For Jev 1.13, Jev Latest and Liquid D1, the `provider` object can contain endpoint-level `order`, `only`, `ignore`, `allow_fallbacks`, `require_parameters`, `max_price`, `zdr`, and `data_collection` controls. These names describe native Decisions endpoints such as `TypeSafe`; they are not NanoGPT provider IDs.

PPLX Decider v1.2 uses a fixed decision endpoint and accepts only `zdr` and `data_collection`. Clef and Clef Flash support [NanoGPT provider selection](https://docs.nano-gpt.com/api-reference/miscellaneous/provider-selection.md), including `only`, `order`, `ignore`, `allow_fallbacks`, `max_price`, and `sort` (`price` or `auto`). Clef and Clef Flash reject `zdr: true`.

API-key provider restrictions and zero-data-retention requirements apply to every model.

## Official TypeSafe SDK

NanoGPT exposes `POST /api/v1/systemone` so the official TypeSafe JavaScript and Python SDKs can call supported decision models without changing their request types. Mercury Decide is not supported on this endpoint. Set the model to `jev-latest`, `jev-1.13`, `liquid/d1`, `perplexity/pplx-decider-v1.2`, `clef`, `cloudflare/clef-flash`, `baselabs/bison-1` or `baselabs/groundhog-1`. Image input and `include_usage` work the same way as on the native endpoint; preserve each model's request restrictions above.

```typescript JavaScript / TypeScript theme={null}
// npm install @typesafe-ai/sdk
import { choice, TypeSafeClient } from "@typesafe-ai/sdk";

const client = new TypeSafeClient({
  apiKey: process.env.NANOGPT_API_KEY!,
  baseURL: "https://api.nano-gpt.com/api",
  defaultModel: "jev-latest",
});

const result = await client.systemOne({
  state: { ticket: "I was charged twice. Please fix this." },
  questions: {
    route: choice("Which team should handle this ticket?", {
      billing: null,
      technical: null,
      sales: null,
    }),
  },
});

console.log(result.answers.route.choice);
```

```python Python theme={null}
# pip install typesafe-sdk
import os
from typesafe_sdk import Choice, TypeSafeClient

with TypeSafeClient(
    api_key=os.environ["NANOGPT_API_KEY"],
    base_url="https://api.nano-gpt.com/api",
    model="jev-latest",
) as client:
    result = client.system_one(
        state={"ticket": "I was charged twice. Please fix this."},
        questions={
            "route": Choice(
                instructions="Which team should handle this ticket?",
                criteria={
                    "billing": None,
                    "technical": None,
                    "sales": None,
                },
            ),
        },
    )

print(result.choices["route"].choice)
```

> [!WARNING]
>
> The SDK's System One call is supported. The SDK's model-list method is not, because NanoGPT's `/api/v1/models` response uses the NanoGPT/OpenAI-compatible model-list shape rather than TypeSafe's model-list shape.

## OpenAI and Anthropic compatibility

Use these shapes when a decision model must fit into an existing OpenAI- or Anthropic-compatible client. The answer object is returned as JSON text, so parse the returned string once.

Chat Completions and Responses report `usage.estimated_cost` by default. To get the exact charge as `usage.cost`, send `"include_usage": true` or `"stream_options": {"include_usage": true}`. Messages responses always report the exact charge.

### Chat Completions

```bash theme={null}
curl https://api.nano-gpt.com/api/v1/chat/completions \
  -H "Authorization: Bearer $NANOGPT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "typesafe/jev-latest",
    "messages": [
      {"role": "user", "content": "I was charged twice. Please fix this."}
    ],
    "stream": false,
    "response_format": {
      "type": "questions",
      "questions": {
        "billing": {
          "type": "noul",
          "instructions": "Is this request about billing?"
        }
      }
    }
  }'
```

Parse `choices[0].message.content` as JSON.

### Responses API

```bash theme={null}
curl https://api.nano-gpt.com/api/v1/responses \
  -H "Authorization: Bearer $NANOGPT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "typesafe/jev-latest",
    "input": "I was charged twice. Please fix this.",
    "stream": false,
    "store": false,
    "text": {
      "format": {
        "type": "questions",
        "questions": {
          "billing": {
            "type": "noul",
            "instructions": "Is this request about billing?"
          }
        }
      }
    }
  }'
```

Parse `output_text` as JSON. The same JSON text is also available in the assistant output item.

### Anthropic Messages

```bash theme={null}
curl https://api.nano-gpt.com/api/v1/messages \
  -H "x-api-key: $NANOGPT_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "typesafe/jev-latest",
    "max_tokens": 128,
    "messages": [
      {"role": "user", "content": "I was charged twice. Please fix this."}
    ],
    "stream": false,
    "output_config": {
      "format": {
        "type": "questions",
        "questions": {
          "billing": {
            "type": "noul",
            "instructions": "Is this request about billing?"
          }
        }
      }
    }
  }'
```

Parse `content[0].text` as JSON. `max_tokens` is accepted for Anthropic SDK compatibility but does not change the fixed typed output.

## Limitations

Decision-model requests are deliberately narrower than chat generation requests:

* Only non-streaming text input in `user` messages is supported on Chat Completions, Messages and Responses compatibility endpoints. PPLX Decider v1.2, Clef, Clef Flash, Bison-1 and Groundhog-1 accept images on the native Decisions and System One endpoints, subject to each model's format and size limits. Mercury Decide accepts inline PNG images on the native Decisions endpoint only.
* System, developer, assistant, tool, audio, video, and file input is not supported. Compatibility endpoints also reject images.
* Tools, sampling controls, log probabilities, and reasoning generation controls are not supported.
* On compatibility endpoints, output-token-limit fields are accepted where an SDK requires them, but they do not change the fixed typed output. Mercury Decide rejects these fields.
* BYOK and accountless Lightning L402 payments are not supported.
* Standard NanoGPT or `X-Provider` provider pins are not supported. Use the native Decisions `provider` object only when you need endpoint-level routing controls.

Unsupported combinations return a `400` error instead of being silently ignored.


## OpenAPI

````yaml POST /v1/decisions
openapi: 3.1.0
info:
  title: NanoGPT API
  description: >-
    API documentation for the NanoGPT language, image, video, speech-to-text,
    and text-to-speech generation services
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://api.nano-gpt.com/api
    description: Direct API host
  - url: https://nano-gpt.com/api
    description: Website host, for IPv6-only clients and the routes that name it
security: []
paths:
  /v1/decisions:
    post:
      tags:
        - Decisions
      summary: Create typed decisions with a decision model
      description: >-
        Evaluates application state with one or more typed Choice, Score, or
        Noul (yes/no) questions. Decision models return typed answers with
        calibrated probabilities instead of generated text, and only input
        tokens are billed. Supported models: TypeSafe Jev (typesafe/jev-1.13,
        typesafe/jev-latest), Liquid AI's D1 (liquid/d1), Perplexity's PPLX
        Decider v1.2 (perplexity/pplx-decider-v1.2), and Cloudflare's Clef
        (cloudflare/clef) and Clef Flash (cloudflare/clef-flash). PPLX Decider
        v1.2 accepts only the zdr and data_collection routing controls in
        provider. Clef and Clef Flash support NanoGPT provider selection and
        reject zdr true. PPLX Decider v1.2, Clef and Clef Flash also accept up
        to four inline images in the state array; Clef and Clef Flash limit text
        input to 1,800 tokens. By default the response returns before billing
        settles and reports usage.estimated_cost; set include_usage to true for
        the exact usage.cost. Check GET /api/v1/decision-models on your chosen
        host for model availability, supported_endpoints and decision_input
        capabilities. Requests for the retired perplexity/pplx-decider-v1.1-27b
        ID return HTTP 410 with code model_retired; select
        perplexity/pplx-decider-v1.2 explicitly. Bison-1 (baselabs/bison-1) and
        Groundhog-1 (baselabs/groundhog-1) support this endpoint with text, JSON
        or up to four inline PNG images. They accept 1–256 questions, 1–255
        choice options, 2–10 score levels and at most 512 total options (each
        noul counts as two). Instructions and criterion descriptions must be
        non-empty text. Context admission is 32,768 tokens per question for
        Bison-1 and 16,384 for Groundhog-1, including shared state, formatting
        and images. Input costs $0.10 and $0.035 per million tokens
        respectively, including cached input; answer tokens are free. Shared
        state is billed once plus each question. Neither model is included in
        subscriptions or subscriber discounts. Omit user, session_id and trace.
        Only provider.zdr and provider.data_collection are accepted; ZDR
        requirements and data_collection deny return 400 zdr_not_supported. No
        streaming, tools, reasoning or transport redaction.
      operationId: createDecision
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/NativeDecisionsRequest'
      responses:
        '200':
          description: Typed decisions response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NativeDecisionsResponse'
        '400':
          description: Invalid state, questions, model, or unsupported parameter
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DecisionsError'
        '401':
          description: Missing or invalid API key
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DecisionsError'
        '410':
          description: The requested model is retired (code model_retired)
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DecisionsError'
        '429':
          description: Rate limit exceeded
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/DecisionsError'
      security:
        - bearerAuth: []
        - apiKeyAuth: []
components:
  schemas:
    NativeDecisionsRequest:
      oneOf:
        - $ref: '#/components/schemas/DecisionsRequest'
        - $ref: '#/components/schemas/MercuryDecisionsRequest'
    NativeDecisionsResponse:
      type: object
      required:
        - model
        - answers
        - usage
      properties:
        id:
          type: string
        model:
          type: string
        answers:
          type: object
          additionalProperties:
            oneOf:
              - $ref: '#/components/schemas/DecisionsChoiceAnswer'
              - $ref: '#/components/schemas/DecisionsScoreAnswer'
              - $ref: '#/components/schemas/DecisionsNoulAnswer'
              - $ref: '#/components/schemas/DecisionsRefusalAnswer'
              - $ref: '#/components/schemas/MercuryDecisionsExtractAnswer'
        usage:
          type: object
          required:
            - input_tokens
            - output_tokens
          properties:
            input_tokens:
              type: integer
              minimum: 0
            output_tokens:
              type: integer
              minimum: 0
            cost:
              type: number
              minimum: 0
              description: >-
                Exact charge in USD. Returned when the request sets
                include_usage to true.
            estimated_cost:
              type: number
              minimum: 0
              description: >-
                Estimated charge in USD at the model's published input price for
                the reported input tokens, before account discounts and
                payment-currency conversion. Returned when include_usage is not
                set; billing settles right after the response.
    DecisionsError:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - message
            - type
            - code
          properties:
            message:
              type: string
            type:
              type: string
            code:
              type: string
            param:
              type: string
    DecisionsRequest:
      type: object
      additionalProperties: false
      required:
        - model
        - state
        - questions
      properties:
        model:
          type: string
          description: >-
            Decision model ID. clef is an alias of the prefixed IDs. Use
            perplexity/pplx-decider-v1.2 for PPLX. The retired
            perplexity/pplx-decider-v1.1-27b ID returns HTTP 410 with code
            model_retired. Bison-1 uses baselabs/bison-1 (alias bison-1);
            Groundhog-1 uses baselabs/groundhog-1 (alias groundhog-1).
          enum:
            - typesafe/jev-1.13
            - ~typesafe/jev-latest
            - typesafe/jev-latest
            - liquid/d1
            - cloudflare/clef
            - clef
            - cloudflare/clef-flash
            - perplexity/pplx-decider-v1.2
            - baselabs/bison-1
            - bison-1
            - baselabs/groundhog-1
            - groundhog-1
        state:
          description: >-
            Application state to evaluate. PPLX Decider v1.2, Clef and Clef
            Flash also accept an array that mixes plain strings with up to four
            image_url parts holding static PNG, JPEG or WebP base64 data URLs,
            each at most 512x512 pixels (240,000 base64 characters in total).
            Remote image URLs are not fetched. For Bison-1 and Groundhog-1,
            state must be text, an array or a JSON object without a messages
            key; null is unsupported. Images must be direct state-array
            image_url parts with static PNG base64 data URLs. Maximum: four
            images, 512x512 pixels each, 240,000 aggregate base64 characters /
            180,000 decoded bytes, within a 1 MiB request body. Omit
            image_url.detail or set auto. JPEG, WebP, remote URLs and image
            input with PII redaction are unsupported.
          oneOf:
            - type: string
            - type: object
              additionalProperties: true
            - type: array
              items: {}
        questions:
          type: object
          minProperties: 1
          additionalProperties:
            oneOf:
              - $ref: '#/components/schemas/DecisionsChoiceQuestion'
              - $ref: '#/components/schemas/DecisionsScoreQuestion'
              - $ref: '#/components/schemas/DecisionsNoulQuestion'
          description: >-
            Bison-1 and Groundhog-1 accept 1–256 questions with non-empty text
            instructions and criterion descriptions. Choice supports 1–255
            options, score requires 2–10 levels, and noul criteria must be
            omitted or contain exactly true and false. At most 512 options
            total; each noul counts as two.
        provider:
          description: >-
            Optional model-specific routing controls. Jev 1.13, Jev Latest and
            Liquid D1 use native Decisions endpoint names. PPLX Decider v1.2
            accepts only zdr and data_collection. Clef and Clef Flash support
            NanoGPT provider selection and reject zdr true. Bison-1 and
            Groundhog-1 accept only zdr and data_collection; provider selection
            is unavailable. Requiring zdr true or data_collection deny returns
            400 zdr_not_supported.
          type:
            - object
            - 'null'
          additionalProperties: true
        session_id:
          type: string
          maxLength: 256
          description: >-
            Unsupported by Bison-1 and Groundhog-1; omit this field for these
            models.
        trace:
          type: object
          additionalProperties: true
          description: >-
            Unsupported by Bison-1 and Groundhog-1; omit this field for these
            models.
        user:
          type: string
          maxLength: 256
          description: >-
            Unsupported by Bison-1 and Groundhog-1; omit this field for these
            models.
        include_usage:
          type: boolean
          default: false
          description: >-
            Wait for billing to settle and report the exact charge as
            usage.cost. By default the response returns without waiting and
            reports usage.estimated_cost.
    MercuryDecisionsRequest:
      description: >-
        Mercury Decide is native Decisions only. Local admission limits are
        65,536 tokens, or 32,768 when any question extracts text. Extraction
        requires string state or a source field naming a string in object state;
        it cannot use images or masked/redacted input.
      type: object
      additionalProperties: false
      required:
        - model
        - state
        - questions
      properties:
        model:
          type: string
          enum:
            - inception/mercury-decide
            - mercury-decide
        state:
          description: >-
            Text, JSON object or array. Images must be inline PNG data URLs in a
            state array: up to four images, each at most 512x512 pixels; 240,000
            encoded characters total. Remote URLs are unsupported.
          type:
            - string
            - object
            - array
        questions:
          type: object
          minProperties: 1
          maxProperties: 64
          additionalProperties:
            oneOf:
              - $ref: '#/components/schemas/MercuryDecisionsNoulQuestion'
              - $ref: '#/components/schemas/MercuryDecisionsChoiceQuestion'
              - $ref: '#/components/schemas/MercuryDecisionsScoreQuestion'
              - $ref: '#/components/schemas/MercuryDecisionsExtractQuestion'
        provider:
          type:
            - object
            - 'null'
          additionalProperties: false
          description: >-
            No provider selection or verified ZDR. zdr true and data_collection
            deny are rejected.
          properties:
            zdr:
              type:
                - boolean
                - 'null'
              enum:
                - false
                - null
            data_collection:
              type:
                - string
                - 'null'
              enum:
                - allow
                - null
        include_usage:
          type: boolean
          default: false
          description: >-
            Wait for billing to settle and report the exact charge as
            usage.cost. By default the response returns without waiting and
            reports usage.estimated_cost.
    DecisionsChoiceAnswer:
      type: object
      required:
        - type
        - choice
        - confidence
        - probabilities
      properties:
        type:
          type: string
          const: choice
        choice:
          type: string
        confidence:
          type: number
          minimum: 0
          maximum: 1
        probabilities:
          type: object
          additionalProperties:
            type: number
            minimum: 0
            maximum: 1
    DecisionsScoreAnswer:
      type: object
      required:
        - type
        - score
        - confidence
        - legend
        - probabilities
      properties:
        type:
          type: string
          const: score
        score:
          type: number
          minimum: 0
        confidence:
          type: number
          minimum: 0
          maximum: 1
        legend:
          type: object
          additionalProperties: true
        probabilities:
          type: object
          additionalProperties:
            type: number
            minimum: 0
            maximum: 1
    DecisionsNoulAnswer:
      type: object
      required:
        - type
        - noul
      properties:
        type:
          type: string
          const: noul
        noul:
          type: number
          minimum: 0
          maximum: 1
    DecisionsRefusalAnswer:
      type: object
      description: >-
        The model declined this question, so it has no value or probabilities.
        Other questions in the same request can still have answers. If every
        question is declined, the request fails with 400
        content_policy_violation and is not charged.
      required:
        - type
      properties:
        type:
          type: string
          const: refusal
    MercuryDecisionsExtractAnswer:
      description: >-
        Mercury Decide extraction answer; native Decisions endpoint only. Field
        keys match criteria, or the question name when criteria is omitted.
      type: object
      required:
        - type
        - spans
        - not_stated
      properties:
        type:
          type: string
          const: extract
        spans:
          type: object
          additionalProperties:
            type: array
            items:
              type: object
              required:
                - text
                - start
                - end
                - confidence
              properties:
                text:
                  type: string
                start:
                  type: integer
                  minimum: 0
                  description: Inclusive Unicode code-point offset in the source text.
                end:
                  type: integer
                  minimum: 1
                  description: Exclusive Unicode code-point offset in the source text.
                confidence:
                  type: number
                  minimum: 0
                  maximum: 1
        not_stated:
          type: object
          additionalProperties:
            type: number
            minimum: 0
            maximum: 1
    DecisionsChoiceQuestion:
      type: object
      required:
        - type
        - instructions
        - criteria
      properties:
        type:
          type: string
          const: choice
        instructions:
          $ref: '#/components/schemas/DecisionsStructuredDescription'
        criteria:
          type: object
          minProperties: 1
          additionalProperties:
            oneOf:
              - $ref: '#/components/schemas/DecisionsStructuredDescription'
              - type: 'null'
    DecisionsScoreQuestion:
      type: object
      required:
        - type
        - instructions
        - criteria
      properties:
        type:
          type: string
          const: score
        instructions:
          $ref: '#/components/schemas/DecisionsStructuredDescription'
        criteria:
          type: array
          minItems: 2
          maxItems: 10
          items:
            $ref: '#/components/schemas/DecisionsStructuredDescription'
    DecisionsNoulQuestion:
      description: >-
        A yes/no question. Instructions are required and, when criteria is sent,
        both true and false descriptions.
      type: object
      required:
        - type
        - instructions
      properties:
        type:
          type: string
          const: noul
        instructions:
          $ref: '#/components/schemas/DecisionsStructuredDescription'
        criteria:
          type: object
          required:
            - 'true'
            - 'false'
          properties:
            'true':
              $ref: '#/components/schemas/DecisionsStructuredDescription'
            'false':
              $ref: '#/components/schemas/DecisionsStructuredDescription'
    MercuryDecisionsNoulQuestion:
      type: object
      additionalProperties: false
      required:
        - type
      properties:
        type:
          type: string
          const: noul
        instructions:
          type:
            - string
            - object
            - array
            - 'null'
        criteria:
          type:
            - object
            - 'null'
          additionalProperties: false
          properties:
            'true':
              type:
                - string
                - object
                - array
                - 'null'
            'false':
              type:
                - string
                - object
                - array
                - 'null'
    MercuryDecisionsChoiceQuestion:
      type: object
      additionalProperties: false
      required:
        - type
        - criteria
      properties:
        type:
          type: string
          const: choice
        instructions:
          type:
            - string
            - object
            - array
            - 'null'
        criteria:
          type: object
          minProperties: 1
          maxProperties: 255
          additionalProperties:
            type:
              - string
              - object
              - array
              - 'null'
    MercuryDecisionsScoreQuestion:
      type: object
      additionalProperties: false
      required:
        - type
        - criteria
      properties:
        type:
          type: string
          const: score
        instructions:
          type:
            - string
            - object
            - array
            - 'null'
        criteria:
          type: array
          minItems: 1
          maxItems: 10
          items:
            type:
              - string
              - object
              - array
    MercuryDecisionsExtractQuestion:
      type: object
      additionalProperties: false
      required:
        - type
      properties:
        type:
          type: string
          const: extract
        instructions:
          type:
            - string
            - object
            - array
            - 'null'
        criteria:
          type: object
          minProperties: 1
          maxProperties: 26
          additionalProperties:
            type: string
            pattern: \S
        source:
          type: string
          description: >-
            Required for object state: names a string field to extract from.
            Omit for string state. Array state and images are unsupported for
            extraction.
        threshold:
          type: number
          minimum: 0
          maximum: 1
        snap_to_words:
          type: boolean
          default: true
      anyOf:
        - required:
            - criteria
        - required:
            - instructions
          properties:
            instructions:
              type: string
              pattern: \S
    DecisionsStructuredDescription:
      description: >-
        A non-empty string, JSON object, or JSON array used to describe a
        question or outcome.
      oneOf:
        - type: string
          minLength: 1
        - type: object
          minProperties: 1
          additionalProperties: true
        - type: array
          minItems: 1
          items: {}
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
    apiKeyAuth:
      type: apiKey
      in: header
      name: x-api-key

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.