ask-matt
MAmattpocock/skills336k4,217 new stars in the last 7 days
Build with Nimble, Bespoke Labs' hosted API for typed judgments about text or JSON. You send a state and up to 64 typed questions (noul for true or false, choice for one of several options, score for a point on an ordered scale) to api.bespokelabs.ai, and Nimble returns a probability for every allowed answer. Use when a feature needs a judgment that code can act on, such as routing, triage, classification, moderation, or checking text against a rule; when an LLM prompt-and-parse step could become a structured decision; or when code uses Nimble, nimble-v4.1-max, nimble-v4, BESPOKE_API_KEY, or api.bespokelabs.ai.
Nimble is a family of models from Bespoke Labs that turn language into decisions your code can use. You send a state, the text or JSON to judge, and a set of typed questions about it. Nimble answers all of them in one response, with a probability for each allowed answer. It writes no explanations, so the workflow stays in your code: act on confident answers, and send uncertain ones to a fallback such as a person.
This skill covers the hosted API at https://api.bespokelabs.ai.
The Nimble docs are the source of truth for models, limits, prices, and SDK usage. When this skill and the docs disagree, follow the docs.
.md to its path.| Task | Read |
|---|---|
| Make a first request | Quickstart |
| Choose a model | Overview |
| Write questions and read answers | Question types |
| Call Nimble from Python | TypeSafe SDK |
| Handle limits, errors, and retries | Limits and errors |
| Estimate cost | Pricing |
| Check the exact schema | OpenAPI spec |
If the docs are unreachable, use the reference below and tell the user that you could not check it against the live docs.
Send POST https://api.bespokelabs.ai/v1/systemone with the header
Authorization: Bearer $BESPOKE_API_KEY. Keys are created in the
console. Read the key from the environment or a
secret store, and never put it in client-side code.
{
"model": "nimble-v4.1-max",
"state": "The customer was charged twice and asks for a refund. The service still works.",
"questions": {
"requests_refund": {
"type": "noul",
"instructions": "Does the customer ask for a refund?"
},
"department": {
"type": "choice",
"instructions": "Which department should handle this request?",
"criteria": {
"billing": "Charges, payments and refunds",
"technical": "Software bugs and outages"
}
},
"urgency": {
"type": "score",
"instructions": "How urgent is this request?",
"criteria": [
"Routine request; the service works",
"Some functionality is unavailable",
"Complete service outage"
]
}
}
}
The response uses your question IDs as keys. The numbers here are only an example:
{
"model": "nimble-v4.1-max",
"answers": {
"requests_refund": { "type": "noul", "noul": 0.99 },
"department": {
"type": "choice",
"choice": "billing",
"probabilities": { "billing": 0.98, "technical": 0.02 },
"confidence": 0.86
},
"urgency": {
"type": "score",
"score": 0.07,
"legend": {
"0": "Routine request; the service works",
"1": "Some functionality is unavailable",
"2": "Complete service outage"
},
"probabilities": { "0": 0.94, "1": 0.05, "2": 0.01 },
"confidence": 0.77
}
},
"usage": { "input_tokens": 338, "output_tokens": 4 }
}
| Type | Asks | criteria | Answer fields |
|---|---|---|---|
noul | Whether a statement is true | Optional: {"true": "...", "false": "..."} | noul: the probability that the statement is true |
choice | Which of 2 to 255 options fits best | Option keys mapped to descriptions; null means "use the key" | choice (the most likely key), probabilities (sum to 1), confidence |
score | Where the state falls on 2 to 255 ordered levels | The levels as a list, lowest first | score (the expected level from 0; can fall between levels), legend, probabilities, confidence |
confidence is 1 when one answer has all the probability and 0 when every answer is
equally likely. It is not the probability that the answer is right.
The state can be a string, or a JSON object or list. Nimble reads JSON as JSON text, so
you can pass structured records as they are.
| Model | Use it |
|---|---|
nimble-v4.1-max | By default. It is the newest and most accurate model, and nimble-latest points to it. It has zero data retention. |
nimble-v4-max | Only in code that already uses it. It is the previous model and still works. |
nimble-v4 | Not in new code. It is deprecated and now answers with nimble-v4-max. |
nimble-v3 | Not in new code. It is deprecated. |
A request without model uses nimble-latest, which moves to newer models as they are
released. Name a specific model in production: a new model returns different
probabilities, which can shift the thresholds you tuned.
422.413.429.| Status | Meaning | What to do |
|---|---|---|
401 | The key is missing or invalid | Fix the key. Do not retry. |
402 | Not enough credit | Buy credit in the console. Do not retry until then. |
413, 422 | The body is too large, or the request is invalid or over a limit (detail says why) | Fix the request. Never retry it unchanged. |
429 | The organization's concurrency limit is reached | Retry after the Retry-After seconds. |
502 | A model returned an error | Retry with exponential backoff. |
503 | A model is starting or briefly unavailable | Retry after Retry-After, or back off if the header is missing. |
504 | The request took too long | Send fewer questions or a shorter state. |
529 | The model is busy | Retry after about a second, with backoff. |
A 422 whose detail is "Nimble request failed" comes from the model, usually because a
prompt is over the token limit or the model name is unknown. Failed requests are not
charged. Every response, including errors, has an x-request-id header. Log it, because
Bespoke Labs support needs it to trace a request.
Nimble charges for input tokens only. Each question's prompt repeats the shared text, which
is the state and all the question definitions, but you pay for the shared text once per
request. So one request with many questions costs much less than many requests with one
question each. usage.input_tokens in the response is the billed count.
Nimble accepts TypeSafe's System One request format, so use TypeSafe's Python SDK and point it at Bespoke Labs.
pip install typesafe-sdk
import os
from typesafe_sdk import Choice, Noul, RetryPolicy, TypeSafeClient
# Example thresholds. Tune them on labeled examples from your own data.
REFUND_THRESHOLD = 0.9
ROUTING_THRESHOLD = 0.8
client = TypeSafeClient(
api_key=os.environ["BESPOKE_API_KEY"],
base_url="https://api.bespokelabs.ai",
model="nimble-v4.1-max",
# The SDK retries failed calls by itself. Limit it to Nimble's retryable statuses.
retry=RetryPolicy(http_statuses={429, 502, 503, 529}),
)
ticket_text = "I was charged twice for my subscription this month. Please refund one of the charges."
response = client.system_one(
ticket_text,
{
"requests_refund": Noul(instructions="Does the customer ask for a refund?"),
"department": Choice(
instructions="Which department should handle this request?",
criteria={
"billing": "Charges, payments and refunds",
"technical": "Software bugs and outages",
},
),
},
)
refund = response.nouls["requests_refund"]
if refund.noul >= REFUND_THRESHOLD:
print(f"Refund requested (p={refund.noul:.2f})")
else:
print(f"No clear refund request (p={refund.noul:.2f}), so a person should check")
department = response.choices["department"]
p = department.probabilities[department.choice]
if p >= ROUTING_THRESHOLD:
print(f"Route to {department.choice} (p={p:.2f})")
else:
print(f"Unsure of the department, so send it to human review: {department.probabilities}")
response.nouls, response.choices, and response.scores hold the answers of each type,
typed for your type checker. response.answers holds all of them.Score(instructions=..., criteria=[...]) asks a score question. Read .score from
response.scores[...]. Its .probabilities are keyed by level number.model="nimble-v4-max" to system_one to use another model for one call.AsyncTypeSafeClient takes the same arguments. Use it with async with.Retry-After. Its default statuses also include 504 and every other 5xx, so
pass RetryPolicy(http_statuses={429, 502, 503, 529}) as above. Do not wrap SDK calls in a
retry loop of your own. Change the RetryPolicy instead.TYPESAFE_API_KEY, TYPESAFE_BASE_URL, and
TYPESAFE_DEFAULT_MODEL. Either way, set the base URL to https://api.bespokelabs.ai,
or the SDK will not call Nimble, and use a Bespoke Labs key, not a TypeSafe key.From other languages, send the JSON above with any HTTP client.
Start from the decision your code has to make, and pick the type that matches it:
noul. Set a threshold on its probability.choice. Cover every real case, and add an
explicit option such as none_of_these when an input can fit none of them.score. Describe each
level concretely, lowest first.Then write the questions:
state, the decision in instructions, and the meaning of
each answer in criteria.requests_refund rather than q1.
They are part of the prompt, so renaming one can change its answer.choice answer, check probabilities[choice], the probability of the
chosen option, against a threshold, as the Python example does. Send low values to review.probabilities when answers near a boundary matter, and the expected score to rank
items.nimble-v4.1-max. If you move a question to another model, tune its threshold
again.429, 502, 503, and 529, with
backoff, and honor Retry-After. With the Python SDK, set this with RetryPolicy instead
of writing your own retry loop.BESPOKE_API_KEY out of source control and client bundles.MAmattpocock/skills336k4,217 new stars in the last 7 days
MAmattpocock/skills336k4,217 new stars in the last 7 days
MAmattpocock/skills336k4,217 new stars in the last 7 days
OBobra/superpowers331k5,030 new stars in the last 7 days
AFaffaan-m/ECC314k3,503 new stars in the last 7 days
AFaffaan-m/ECC314k3,503 new stars in the last 7 days