Console

API reference

Generate

Write short text, or JSON in a shape you define, from a state.

POST/v1/generate

Base URL https://wity-proxy-production-2c33.up.railway.app. Same authentication as decisions: Authorization: Bearer wity_…. For what generate is for and how to design shapes, see Generate.

Request body#

state
string | object | array
What to write from. Objects and arrays are read as JSON. Up to 32,000 characters.
instructions
stringrequired
What to write. Up to 8,000 characters.
shape
JSON Schema object
Optional. A schema with "type": "object". The output is constrained to it and returned parsed in value. Supports properties, required, pattern, enum, maxLength, numbers, booleans, nested objects and arrays. Leave it out for free text.
max_tokens
integer
1 to 512. Default 128.
image
string
Optional data URL (data:image/…;base64,…). See Images.
model
string
Optional and ignored.

Note

Unknown top-level fields are rejected with 400.

Example#

curl https://wity-proxy-production-2c33.up.railway.app/v1/generate \
-H "Authorization: Bearer $WITY_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"state": "Ticket scan: LISBOA (LIS) -> BERLIN BRANDENBURG (BER), 14 Oct, seat 23C.",
"instructions": "Origin city, as printed on the ticket",
"shape": { "type": "object",
"properties": { "city": { "type": "string", "pattern": "^[A-Za-z ]{1,40}$" } },
"required": ["city"] },
"max_tokens": 40
}'

Response#

{
"model": "wity-1",
"text": "{\"city\": \"Lisbon\"}",
"value": { "city": "Lisbon" },
"finish_reason": "stop",
"usage": { "input_tokens": 98, "output_tokens": 8 },
"metadata": { "elapsed_ms": 612.4 }
}
text
string
What Wity wrote. With a shape, this is the JSON text.
value
object | null
Present when you sent a shape: the parsed object. null only if the output was cut off by max_tokens.
finish_reason
"stop" | "length"
length means max_tokens was reached; raise it if the text looks cut off.
usage
object
input_tokens is billed; output_tokens is reported and not billed.