SystemOne SDK

Use the TypeSafe SDK to ask Linden-1 for decisions. Set your Gradiated base URL, API key, and model, then send a state and named questions.

Linden-1 is Gradiated's open decision model, served through the native SystemOne API. If you already use TypeSafe's SDK for Jev, use the same client with gradiated/linden-1 on Gradiated. This selects Linden-1; jev-latest is not a Gradiated model alias.

Install#

Shell
pip install typesafe-sdk

Set GRADIATED_API_KEY in your server environment. Use a Gradiated key from the quickstart.

Make a decision#

Send the information to evaluate as state, and the decision to make as a named question. State can be text, a JSON object, or an array.

Python
import os
from typesafe_sdk import Choice, TypeSafeClient

with TypeSafeClient(
    base_url="https://api.gradiated.com",
    api_key=os.environ["GRADIATED_API_KEY"],
    model="gradiated/linden-1",
) as client:
    response = client.system_one(
        state={"ticket": "I was charged twice. Please fix this today."},
        questions={
            "category": Choice(
                instructions="Choose the department for this ticket.",
                criteria={
                    "billing": "Charges or payments",
                    "technical": "Something is broken",
                    "other": "Anything else",
                },
            ),
        },
    )

print(response.choices["category"].choice)
print(response.choices["category"].probabilities)

Use the base URL without /v1; the SDK adds /v1/systemone. Check models and pricing for model access and current pricing.

Ask multiple questions#

Questions in one request share the same state. Use Noul for a yes/no probability and Score for an ordered rating.

Python
import os
from typesafe_sdk import Noul, Score, TypeSafeClient

with TypeSafeClient(
    base_url="https://api.gradiated.com",
    api_key=os.environ["GRADIATED_API_KEY"],
    model="gradiated/linden-1",
) as client:
    response = client.system_one(
        state={"ticket": "I was charged twice. Please fix this today."},
        questions={
            "billing": Noul(instructions="Is this about a payment problem?"),
            "urgency": Score(
                instructions="Rate how urgently this ticket needs attention.",
                criteria=["Can wait", "Needs attention today", "Needs immediate attention"],
            ),
        },
    )

print(response.nouls["billing"].noul)
print(response.scores["urgency"].score)
QuestionResult
choiceThe selected option, probabilities for each option, and confidence.
noulA probability of “yes” from 0 to 1. Apply your own decision threshold.
scoreAn expected score across zero-indexed criteria. The three-level example returns a number from 0 to 2, which can be fractional.

Call your own decision model#

A decision model you trained on linden-1 and deployed with grad deploy is called the same way: set model to its name (<org>/ticket-triage, or <org>/ticket-triage/<version> to pin a version) and ask any of the questions it was trained on, in any order, with their trained types and options. With the same question wording as in training, each question gets the same prompt as in training, whichever subset you send. Answers have the same shape as linden-1's. A question it was not trained on, or one with other options, is refused with 400 invalid_request for questions.

Supported requests#

Linden-1 accepts 1–1,024 named questions per request. A choice has 1–255 options, as an object of descriptions or a list of option names, and a score 1–255 ordered criteria; a single option or level is answered with certainty. Instructions are optional: a question without them is asked through its criteria alone. States are text, JSON or a text-only chat; images and other media are not supported. The hosted runtime limits bodies to 1 MiB and each question's prompt, including the state, to 32,768 tokens.

Use the native SystemOne endpoint for Linden-1. It returns all answers in one response, with no streaming or text generation parameters such as max_tokens or temperature. Only the default service tier is supported; omit service_tier to use it.

Usage counts the tokens Linden-1 reads: the prompt shared by all questions once, plus each question's own part. A request of up to about 3,000 tokens is read twice, so it counts roughly twice its length. Generated output tokens are zero. See errors and retries for handling rejected requests and rate limits.

SDK reference: Python · JavaScript.