Input

Every capability takes one text or a batch of texts, and returns results in the order you sent them.

Every capability endpoint reads the same two fields. Send text for one input, or texts for a batch. The rest of the body names the decision: statement, labels, scale, question, schema, types, or field with value.

No API key is required during the launch period.

The two input fields

text
string

One input, 1 to 20,000 characters. Send this field or texts, never both.

texts
string[]

A batch of 1 to 32 inputs. Each item takes the same 1 to 20,000 character limit.

Every request carries one of the two fields.

text and texts are mutually exclusive. If you send both, or neither, the API returns 400 with the message body: provide text or texts, not both.

yes-no is the one exception. It accepts both fields at once and reads text. It also accepts neither, and then returns {"results": []}.

One text

curl -s https://api.milliseconds.ai/v1/decision-machine-1/classify \
-H 'content-type: application/json' \
-d '{
"text": "My card was charged twice this month.",
"labels": {
"billing": "A problem with payment, invoices or charges",
"shipping": "A question about delivery or address changes",
"bug": "A defect in the product"
}
}'

Shape JSON records into text

The models read prose, not objects. Flatten a record into short labelled lines before you send it. Keep the field names that carry meaning. Drop ids, timestamps, and internal flags that no decision uses.

A ticket record, flattened
Subject: Double charge on my plan
From: dana@example.com
Plan: Team annual
Message: My card was charged twice this month and support has not replied.

Three rules keep the input clean:

  1. Put one field on one line, as Name: value.
  2. Write values as they read to a person: Team annual, not plan_id=3.
  3. Keep the whole record under 2,000 characters when you can. The service chunks longer text.

Every character you send counts toward the character limit. The response header x-input-tokens reports the input tokens billed for this call. Cost grows with everything you send: the text plus the labels, statements, questions, or schema, at $0.04 per million input tokens. See Pricing.

Batching with texts

Send up to 32 inputs in texts. The response is always the batch envelope {"results": [...]}, with one entry per input, in the order you sent them. Match results to inputs by index.

curl -s -D - https://api.milliseconds.ai/v1/decision-machine-1/classify \
-H 'content-type: application/json' \
-d '{
"texts": [
"My card was charged twice this month.",
"Can you change the delivery address?"
],
"labels": {
"billing": "A problem with payment, invoices or charges",
"shipping": "A question about delivery or address changes",
"bug": "A defect in the product"
}
}'

That call reported x-input-chars: 73, the number of input characters, and x-input-tokens: 18, the input tokens billed for this call. The chars header counts the sum over all items in the batch.

Each text in texts costs one inference call. Batched statements or questions go into one call and add only their own length to the billed input. You pay $0.04 per million input tokens and $0 per output token. See Pricing.

Nested batches

On yes-no and answer you can batch both axes. texts with statements, or texts with questions, nests the envelope: an outer result per text, an inner result per statement or question.

curl -s https://api.milliseconds.ai/v1/decision-machine-1/yes-no \
-H 'content-type: application/json' \
-d '{
"texts": [
"My card was charged twice this month and support has not replied.",
"Can you change the delivery address?"
],
"statements": [
"The message reports a billing problem.",
"The message needs a human reply today."
]
}'

Two texts by two statements take 1.08 s.

Read it as results[textIndex].results[statementIndex]. Both axes keep input order.

Input limits

FieldLimitError on breach
text20,000 characterstext: Too big: expected string to have <=20000 characters
texts32 itemstexts: Too big: expected array to have <=32 items
statements / questions32 itemsstatements: Too big: expected array to have <=32 items
labels (array form)2 to 64labels: Too small: expected array to have >=2 items
scale2 to 10 levelsscale: Too big: expected array to have <=10 items

Split anything over 20,000 characters yourself. The service chunks any text over 2,000 characters, and the merge rule differs per capability.

Next