Before the first request
Iryx Decide turns a context into typed decisions. You send what you know (a message, a record, a small state) and the questions you need answered. Each answer comes back with a value and the full probability spectrum behind it. Iryx does not write text.
This documentation describes version 1 of the API. All values in the examples are illustrative, not measurements.
- The API address and your key are on the dashboard.
- In the examples, the address lives in the variable
IRYX_URLand the key inIRYX_API_KEY. - The key goes only in the header
Authorization: Bearer <key>, never in a URL or in the body. - The API speaks its own words:
context,decisions,pick,check,scale,spectrum.
export IRYX_URL="<the address that comes with your access>"
export IRYX_API_KEY="<your key>"$env:IRYX_URL = "<the address that comes with your access>"
$env:IRYX_API_KEY = "<your key>"[ part 1 ]
Cookbook
Short recipes for the most common uses. Every field and rule is in the API Reference.
Your first decision
A POST /v1/decide request carries the context and the decisions. This one carries three, one of each kind, about the same message.
curl -s "$IRYX_URL/v1/decide" \
-H "Authorization: Bearer $IRYX_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"context": {"message": "API down since 9am, our checkout is failing"},
"decisions": {
"team": {"kind": "pick", "prompt": "Which team should handle this ticket?",
"options": {"billing": "charges, invoices, refunds", "tech": "bugs, API, outages"}},
"urgent": {"kind": "check", "prompt": "Needs a reply within hours"},
"mood": {"kind": "scale", "prompt": "Customer frustration",
"levels": ["calm", "annoyed", "angry"]}
}
}'PowerShell’s curl is another command; call curl.exe and keep the body in a file to avoid quoting problems.
curl.exe -s "$env:IRYX_URL/v1/decide" -H "Authorization: Bearer $env:IRYX_API_KEY" -H "Content-Type: application/json" --data-binary "@request.json"Response (illustrative values):
{"id": "dec_5b1e0c9a7d2f4e6a8c3b1d0f",
"object": "decision",
"model": "iryx-1.1",
"results": {
"team": {"kind": "pick", "value": "tech", "confidence": 0.95, "spectrum": {"billing": 0.05, "tech": 0.95}},
"urgent": {"kind": "check", "value": 0.91},
"mood": {"kind": "scale", "value": 1.4, "level": "annoyed", "spectrum": {"calm": 0.1, "annoyed": 0.4, "angry": 0.5}}},
"usage": {"decisions": 3},
"latency_ms": 120}resultshas one entry per decision, with the names from the request, in request order.usage.decisionscounts the decisions answered: it is the usage unit.ididentifies the response:dec_plus 24 hexadecimal characters, the same hex as theX-Request-Idheader.modelis the id of the model that answered, as listed byGET /v1/models.- Requests with
iryx-1.0still work, and 1.1 answers them. latency_msis the processing time on the server, in milliseconds. Network time is not included.
pick, check and scale
Every decision has a kind, a prompt and, depending on the kind, options or levels. A decision is always about the context you send.
pick: choose one option
Use it when exactly one option of a fixed set applies. Descriptions are part of the question: say what each option covers.
"team": {"kind": "pick", "prompt": "Which team should handle this ticket?",
"options": {"billing": "charges, invoices, refunds", "tech": "bugs, API, outages", "sales": "prices, plans, upgrades"}}"team": {"kind": "pick", "value": "tech", "confidence": 0.88,
"spectrum": {"billing": 0.07, "tech": 0.88, "sales": 0.05}}value: the option with the highest probability. On a tie, the option listed first wins.confidence: the probability ofvalue(the same number asspectrum[value]).spectrum: every option with its probability, in request order.
check: is this statement true?
Write the prompt as a statement about the context that can be true or false ("Needs a reply within hours"), not as a question.
"urgent": {"kind": "check", "prompt": "Needs a reply within hours"}"urgent": {"kind": "check", "value": 0.91}value: the probability, from 0 to 1, that the statement is true. The probability that it is false is1 - value. There is nospectrum.
scale: where on an ordered scale?
List the levels from lowest to highest.
"mood": {"kind": "scale", "prompt": "Customer frustration", "levels": ["calm", "annoyed", "angry"]}"mood": {"kind": "scale", "value": 1.4, "level": "annoyed",
"spectrum": {"calm": 0.1, "annoyed": 0.4, "angry": 0.5}}spectrum: the probability of each level, by name, in request order.value: the expected position on the scale, counting the first level as 0 and the last asn - 1:0 × 0.1 + 1 × 0.4 + 2 × 0.5 = 1.4. Three decimals.level: the name of the level nearest tovalue(a fraction of exactly .5 rounds up). Here 1.4 rounds to 1,"annoyed".
Several decisions in one request
One request carries 1 to 32 decisions about the same context. Each decision answered counts one in usage.decisions. Several contexts in one request are not in v1: send one request per context.
In Python, standard library only, handling errors by their type:
import json
import os
import urllib.error
import urllib.request
URL = os.environ["IRYX_URL"] + "/v1/decide"
KEY = os.environ.get("IRYX_API_KEY") # your key
body = {
"context": {"message": "API down since 9am, our checkout is failing"},
"decisions": {
"team": {"kind": "pick", "prompt": "Which team should handle this ticket?",
"options": {"billing": "charges, invoices, refunds", "tech": "bugs, API, outages"}},
"urgent": {"kind": "check", "prompt": "Needs a reply within hours"},
},
}
headers = {
"Content-Type": "application/json",
"User-Agent": "iryx-example/1.0", # Cloudflare, in front of the API, rejects urllib's default User-Agent
}
if KEY:
headers["Authorization"] = "Bearer " + KEY
request = urllib.request.Request(URL, data=json.dumps(body).encode("utf-8"), headers=headers, method="POST")
try:
with urllib.request.urlopen(request, timeout=60) as response:
answer = json.load(response)
except urllib.error.HTTPError as error:
raw = error.read()
try:
problem = json.loads(raw)
except ValueError:
raise SystemExit("%d, body is not JSON: %r" % (error.code, raw[:200]))
raise SystemExit("%d %s: %s (param=%s, request id %s)" % (
error.code, problem["error"]["type"], problem["error"]["message"],
problem["error"].get("param"), problem["id"]))
team = answer["results"]["team"]
print(team["value"], team["confidence"], answer["results"]["urgent"]["value"])How much fits in one request
The limit applies to the context and the decisions combined. The longer the context and the more decisions in one request, the sooner the limit comes. For ordinary prose, with a short prompt and a few short options per decision, the context fits in about:
| decisions in the request | context, about |
|---|---|
| 1 to 4 | 6,000 characters |
| 8 | 3,000 characters |
| 16 | 1,300 characters |
| 32 | 500 characters |
- Over the limit: you get
422 context_too_longand nothing was decided. Send the same context with fewer decisions per request, or a shorter context. - Service at capacity: you get
503 overloadedwith theRetry-Afterheader. Wait that many seconds and send the same request again; nothing was decided. - Too many requests: you get
429with theRetry-Afterheader. Wait that many seconds and try again, waiting longer after each new failure; nothing was decided. - A structured context works: keys and values are part of what Iryx reads, so clear key names help.
Reading confidence and the spectrum
Each kind tells you how far to trust the answer in its own way:
pick:confidenceis the probability of the chosen option, and thespectrumshows the others, including the runner-up.check:valueis the probability that the statement is true. For a yes/no reading, compare it with 0.5, or with a stricter threshold when a wrong "yes" is costly.scale:valuekeeps the uncertainty (1.4 is between "annoyed" and "angry", closer to "annoyed");levelis the nearest named level, for display or routing.
"team": {"kind": "pick", "value": "tech", "confidence": 0.88,
"spectrum": {"billing": 0.07, "tech": 0.88, "sales": 0.05}}Here tech comes out at 0.88 and the runner-up is billing, at 0.07. The numbers can move slightly between two identical requests: see Reading the numbers.
Handling the low band
A response doesn’t come with a ready-made band: it comes with the probability. You set the low band: below a threshold you choose, the decision goes to a person.
- Choose a threshold for each decision. Above it, your software acts on its own; below it, a person decides.
- Send the spectrum along to that person: it shows the runner-up.
- In a
check, use a threshold stricter than 0.5 when a wrong "yes" is costly. - An almost tied answer can switch sides between two identical requests: one more reason for a person to check.
import os
import requests
URL = os.environ["IRYX_URL"] + "/v1/decide"
headers = {"Authorization": "Bearer " + os.environ["IRYX_API_KEY"]} if os.environ.get("IRYX_API_KEY") else {}
body = {
"context": {"temperature_c": 31, "co2_ppm": 1800, "someone_home": True},
"decisions": {
"action": {"kind": "pick", "prompt": "What should the home system do now?",
"options": ["nothing", "turn_on_ventilation", "alert_resident", "call_emergency"]},
"severity": {"kind": "scale", "prompt": "How serious is the situation?",
"levels": ["normal", "attention", "serious", "emergency"]},
},
}
response = requests.post(URL, json=body, headers=headers, timeout=60)
if response.status_code != 200:
try:
problem = response.json()
except ValueError:
raise SystemExit(f"{response.status_code}, body is not JSON: {response.content[:200]!r}")
raise SystemExit(f"{response.status_code} {problem['error']['type']}: {problem['error']['message']}")
result = response.json()["results"]
action = result["action"]
if action["confidence"] >= 0.8: # illustrative threshold: pick your own
print("do it:", action["value"])
else:
print("ask a person; spectrum:", action["spectrum"])
print("severity:", result["severity"]["level"], result["severity"]["value"])The 0.8 threshold in the example is illustrative: pick your own. requests sends Content-Type: application/json by itself when you pass json=.
[ part 2 ]
API Reference
Every field, limit, error and header of API v1, as the service works today. All values in the examples are illustrative.
Overview
| Protocol | HTTP/1.1, JSON bodies in UTF-8 |
|---|---|
| Base URL | comes with your access (IRYX_URL in the examples) |
| Version | path prefix /v1; GET /v1/health reports "api_version": "1" |
| Authentication | Authorization: Bearer <key> |
| Usage unit | the decision: every response reports usage.decisions |
| method | path | what it does | key needed |
|---|---|---|---|
POST | /v1/decide | answers 1 to 32 decisions about one context | yes |
GET | /v1/models | lists the available model ids | yes |
GET | /v1/health | liveness and readiness | no |
GET | /health | same as /v1/health | no |
OPTIONS | any path | CORS preflight | no |
Authentication
- Every request carries
Authorization: Bearer <key>, exceptGET /v1/health,GET /healthandOPTIONS. The wordBeareris case-insensitive. - A missing or wrong key returns
401 unauthorizedwith the headerWWW-Authenticate: Bearer. Without a valid key, an unknown path also returns 401, not 404. - Send the key only in the header, never in a URL or in the body.
POST /v1/decide
Answers 1 to 32 decisions about one context. A full example is in Your first decision.
Request body
| field | type | required | rules |
|---|---|---|---|
model | string | no | a model id from GET /v1/models, or an accepted alias for one of them (see GET /v1/models). Omitted: the default model (the one /v1/health reports). Unknown id: 404 model_not_found |
context | object | yes | any JSON object, up to 65,536 bytes when serialized as compact UTF-8 JSON. For a single piece of free text, use {"message": "<text>"} |
decisions | object | yes | 1 to 32 entries: decision name → decision object. Names match ^[A-Za-z0-9_.-]{1,64}$ |
Any other top-level field returns 422 invalid_request, with param set to that field. The whole body is limited to 1,048,576 bytes (413 above it).
The context is read as given. A structured context works: keys and values are part of what Iryx reads, so clear key names help the reader ({"temperature_c": 31, "co2_ppm": 1800} rather than {"t": 31, "c": 1800}).
Decision object
| field | kinds | type | required | rules |
|---|---|---|---|---|
kind | all | string | yes | pick, check or scale |
prompt | all | string | yes | not empty or blank, up to 2,000 characters |
options | pick | object or array | yes | 2 to 26 options. Object: name → description (a string, "" allowed, up to 2,000 characters). Array: names only. Names are non-blank strings, up to 200 characters, unique |
levels | scale | array | yes | 2 to 26 level names, ordered from lowest to highest. Non-blank, up to 200 characters, unique |
A field that does not belong to the kind (for example levels in a pick) returns 422 invalid_request with param = decisions.<name>.<field>.
Decisions must be about the context you send. A decision about the API itself, rather than the context, returns 422 self_reference_not_supported.
Rules for each kind
pick:valueis the option with the highest probability; on a tie, the option listed first wins.confidenceis the probability ofvalue(the same number asspectrum[value]).spectrumhas every option, in request order.check: write thepromptas a statement, not as a question.valueis the probability, from 0 to 1, that the statement is true; the probability that it is false is1 - value. There is nospectrum.scale: levels go from lowest to highest.spectrumhas the probability of each level, in request order.valueis the expected position, counting the first level as 0 and the last asn - 1, with three decimals.levelis the name of the level nearest tovalue(a fraction of exactly .5 rounds up).
Examples of each kind are in pick, check and scale.
Response body (200)
| field | type | meaning |
|---|---|---|
id | string | dec_ + 24 hexadecimal characters. Same hex as the X-Request-Id header (req_...) |
object | string | always "decision" |
model | string | the model id that answered, as listed by GET /v1/models. A request that named an alias gets the listed id here, not the alias |
results | object | one entry per decision, with the names from the request, in request order |
usage | object | {"decisions": n}: how many decisions were answered |
latency_ms | integer | processing time on the server, in milliseconds. Network time is not included |
Result object, by kind:
| field | pick | check | scale |
|---|---|---|---|
kind | "pick" | "check" | "scale" |
value | string: the chosen option | number from 0 to 1 | number from 0 to n - 1 |
confidence | number from 0 to 1 | not present | not present |
level | not present | not present | string: nearest level |
spectrum | object: option → probability | not present | object: level → probability |
Reading the numbers
- Probabilities have 4 decimals and lie between 0 and 1. A spectrum sums to 1 up to rounding, and a small probability can round to 0.
- For identical requests, probabilities can differ by up to about 0.02. The choice only changes when the answer is almost tied.
- Use
confidence(pick) andvalue(check) as probabilities. A common pattern: act automatically above a threshold you choose, and send the rest to a person. The spectrum shows the runner-up. - For a yes/no reading of a
check, comparevaluewith 0.5, or with a stricter threshold when a wrong "yes" is costly. - In a
scale,valuekeeps the uncertainty (1.4 is between "annoyed" and "angry", closer to "annoyed");levelis the nearest named level, for display or routing.
GET /v1/models
{"data": [{"id": "iryx-1.1", "object": "model"}]}Lists the available model ids. Any of them can go in the model field of /v1/decide.
The API may also accept an alias: another id that answers exactly as one of the listed models, for example an older id kept for clients that still send it. Aliases are not listed here. A request with an alias is answered by the model it points to, and the response carries the listed id. An unknown alias is 404 model_not_found, like any unknown id.
GET /v1/health and /health
{"status": "ok", "model": "iryx-1.1", "api_version": "1"}modelis the default model, used when a request omitsmodel.- No key is needed.
- A 200 here means the service is ready to answer.
OPTIONS CORS preflight
Any path returns 204 without a key, with Access-Control-Allow-Methods: GET, POST, OPTIONS, Access-Control-Allow-Headers: Authorization, Content-Type and Access-Control-Max-Age: 600. No origin is allowed today: a page on another site, in the browser, cannot read the answers. Call the API from your server, where the key stays private.
Errors
Every API error is JSON, with the same shape:
{"error": {"type": "invalid_request",
"message": "\"options\" must have between 2 and 26 items.",
"param": "decisions.team.options"},
"id": "req_5b1e0c9a7d2f4e6a8c3b1d0f"}type: stable and machine-readable. Branch on it (and onparam), not onmessage.message: English, for people. It may change.param: present when one field caused the error.id: the request id, equal to theX-Request-Idheader. Quote it when reporting a problem.
| status | type | when |
|---|---|---|
| 400 | invalid_json | the body is empty, is not valid UTF-8 JSON, or did not arrive in full. The message gives the reason (see below) |
| 400, 414, 431, 505 | bad_request | the HTTP request itself is malformed: bad request line (400), URL too long (414), too many or too large headers (431), unsupported HTTP version (505) |
| 401 | unauthorized | the request has no valid Authorization: Bearer <key> |
| 402 | payment_required | the account has no active plan or credit, or a payment is overdue. Message: No active plan or credit, or a payment is overdue. See Billing in the console. |
| 402 | quota_exceeded | the decisions included in the plan and the credit are used up. Message: Your included decisions and your credit are used up. Buy credit, turn on auto top-up or change your plan. |
| 402 | spend_limit_reached | this cycle’s spending reached the spending limit set on the account. Message: This cycle's spending limit was reached. Raise it in Billing or wait for the next cycle. |
| 403 | forbidden | the key is valid but is not allowed to do this. Message: This key is not allowed to do this. |
| 404 | not_found | unknown path |
| 404 | model_not_found | model is not one of the ids in GET /v1/models (param: model) |
| 405 | method_not_allowed | wrong method for a known path (the Allow header lists the right ones), or an unknown method (no Allow header) |
| 413 | payload_too_large | the body is larger than 1,048,576 bytes |
| 422 | invalid_request | valid JSON that breaks a rule of this reference: missing or unknown field, wrong type, a limit exceeded, repeated option or level names |
| 422 | self_reference_not_supported | the decision is about the API itself, not the context sent (param: the prompt, options or levels of that decision). Nothing was decided |
| 422 | context_too_long | the request is valid, but the context and the decisions exceed the request size limit (see Limits). param is always context and the message is always Context and decisions exceed the request size limit. Nothing was decided: shorten the context or split the decisions into several requests |
| 429 | rate_limited | you went over your plan’s decisions-per-second limit. Comes with Retry-After; nothing was decided. Message: Too many decisions per second for your plan. Wait the seconds in Retry-After. |
| 429 | too_many_requests | too many requests from the same network (for example, many attempts with an invalid key). It is not your plan’s limit. Comes with Retry-After; nothing was decided. Message: Too many requests from your network. Wait the seconds in Retry-After. |
| 500 | internal_error | an unexpected failure. The message is generic; quote the request id when you contact support |
| 503 | overloaded | the service is at capacity and could not answer this request now. The Retry-After header says how many seconds to wait before trying again. Nothing was decided; the request can be repeated as is |
In front of the API, Cloudflare may answer without JSON: for example, 403 with the body error code: 1010 for the default User-Agent of Python’s urllib. Send your own User-Agent, as the examples do.
The 402, 403 and 429 errors belong to the hosted service (plans, credit, limits and key permissions).
Specific 400 messages
| message |
|---|
Request body is empty. Send a JSON object. |
Request body is not valid JSON. |
Numbers must be finite (a number in the body is out of range). |
Request body has an unpaired surrogate escape (invalid Unicode). |
Send the body with a Content-Length header (chunked transfer is not supported). |
Invalid Content-Length header. |
Request body ended before Content-Length bytes. |
Request body is nested too deeply. |
Timed out reading the request body. |
Forms of param
param | points to |
|---|---|
model | the model field |
context | the context field (missing, not an object, too large), and every context_too_long |
decisions | the decisions field, or an invalid decision name |
decisions.team.kind, decisions.team.prompt | a field of one decision |
decisions.team.options, decisions.mood.levels | the whole list or object |
decisions.team.options[1], decisions.mood.levels[0] | one item of a list |
decisions.team.options.billing | the description of one option |
| any other name | an unknown top-level field |
Headers
Send:
| header | when |
|---|---|
Content-Type: application/json | on every POST |
Content-Length | on every request with a body. Chunked transfer encoding is not supported |
Authorization: Bearer <key> | on every request that needs a key (see Authentication) |
Every JSON response (all statuses except the 204 of OPTIONS) carries:
| header | value |
|---|---|
Content-Type | application/json; charset=utf-8 |
X-Request-Id | req_ + 24 hexadecimal characters |
Cache-Control | no-store |
X-Content-Type-Options | nosniff |
Server | iryx |
Access-Control-Allow-Origin | not sent today: no origin is allowed (see OPTIONS) |
WWW-Authenticate: Bearer | on 401 |
Allow | on 405 for a known path |
Retry-After | on 429 and 503: seconds to wait before retrying |
The 204 answer to OPTIONS has no body: it carries X-Request-Id, Server, Allow and the CORS headers above.
Connections are HTTP/1.1 keep-alive. The server closes the connection after an error that left part of the body unread.
Limits
| what | limit |
|---|---|
| request body | 1,048,576 bytes |
context | 65,536 bytes, serialized as compact UTF-8 JSON |
| decisions per request | 1 to 32 |
| decision name | 1 to 64 characters from A-Z a-z 0-9 _ . - |
prompt | 1 to 2,000 characters |
| options (pick), levels (scale) | 2 to 26 |
| option or level name | 1 to 200 characters |
| option description | 0 to 2,000 characters |
| silence on a connection | 60 s: a connection that sends nothing for 60 s is closed (in the middle of a body, with 400 invalid_json) |
| context + decisions | see below; above it, 422 context_too_long |
How much fits in a request
The limit applies to the context and the decisions combined. The longer the context and the more decisions in one request, the sooner the limit comes. For ordinary prose, with a short prompt and a few short options per decision, the context fits in about:
| decisions in the request | context, about |
|---|---|
| 1 to 4 | 6,000 characters |
| 8 | 3,000 characters |
| 16 | 1,300 characters |
| 32 | 500 characters |
These numbers are approximate on purpose. Long prompts and option descriptions count too, and text that is not ordinary prose (numbers, code, JSON with many short keys, emoji, some non-Latin scripts) reaches the limit sooner. If you get context_too_long, send the same context with fewer decisions per request, or a shorter context. The context byte limit in the table above is a separate, larger ceiling on the request itself.
Two errors ask you to wait and try again, and both carry Retry-After: 429, when there are too many requests (rate_limited, over your plan’s per-second limit, or too_many_requests, too many requests from the same network), and 503 overloaded, when the service is at capacity. In both cases nothing was decided: wait at least the seconds in Retry-After and send the same request again. If the error comes back, wait longer on each attempt (exponential backoff).
Versioning
- The API version is in the path (
/v1) and inGET /v1/health("api_version": "1"). A change that would break v1 clients goes to a new path. - Within v1, responses may gain new optional fields. Clients should ignore fields they do not know.
- Model ids are fixed: one id always names the same model, and so does each alias of it. A new model gets a new id, listed by
GET /v1/models. To follow the default model instead of pinning one, omitmodel.
Data policy
- The model server reads the request, decides in memory and replies. The content of the request and of the answer does not go into the logs.
- The server log has one line per request: time, request id, method, route, status, number of decisions and duration. Never the context, prompts, options or results.
- An unexpected error adds its error type and the code location to the log, without the error message, which could echo client content.
- Responses carry
Cache-Control: no-store. - On the hosted service, the API access log also keeps the date, the IP and the ID of the key used, without the content, for 6 months, as Brazil’s Marco Civil da Internet requires (Law 12,965/2014, art. 15).
What is kept, for how long and why is in the platform’s Privacy Policy and Terms of Use.
Not in v1
- Text generation, streaming, or several contexts in one request (send one request per context).
- Idempotency keys, usage-count headers (the limit shows up only as
429withRetry-After) and chunked uploads.