API builder
Variables and templates
Declare typed inputs and insert them into the system prompt and prompt with {{variables}}.
Variables
Each variable is an input callers send in inputs:
{
"key": "ticket",
"label": "Ticket",
"description": "The ticket to classify.",
"type": "object",
"required": true,
"default": null,
"enum": null,
"items": null,
"properties": [
{ "key": "subject", "label": "Subject", "type": "string", "required": true },
{ "key": "body", "label": "Body", "type": "string", "required": true }
]
}key: a lowercase letter, then letters, digits or_, up to 64 characters. Unique among its siblings.type:string,number,integer,boolean,enum,array,objectorfile.required: callers must send it, unless it has adefault.default: used when the variable isn't required and isn't sent.enum: the allowed values, for typeenum.items: for typearray, a variable-like schema of each item (nokey). Items can be objects with their ownproperties.properties: for typeobject, a list of variables. Objects nest to any depth.
file variables take {"file_ids": ["<uuid>", ...], "query": "..."}. They're accepted and validated, but running endpoints that use them isn't available yet: the gateway answers 501 not_implemented.
Input validation
The gateway checks inputs before calling a model:
- every required variable is present unless it has a default;
- types match: an
integeris a whole number, anenumvalue is listed, objects and array items are checked recursively; - inputs that aren't declared are refused.
Problems come back as 422 invalid_inputs with the path:
{ "error": { "message": "inputs.ticket.subject: required", "type": "invalid_inputs", "code": "invalid_inputs" } }Templates
system and prompt are templates. {{ name }} inserts a variable and {{ obj.field }} reaches into objects. Whitespace inside the braces is ignored.
Classify this ticket and answer in {{ language }}.
Subject: {{ticket.subject}}
Body:
{{ticket.body}}Values are inserted like this:
| Value | Inserted as |
|---|---|
| string | as it is, in any language, nothing stripped |
| number, boolean | JSON (4.5, true) |
| array, object | compact JSON (["a","b"]) |
A name that isn't declared is an error when you save the endpoint and when it runs. There's no other template logic: no conditions or loops. Put that logic in the prompt's wording, or send pre-formatted text as a string variable.
In the console's prompt editors, type {{ or / to pick from the declared variables, including nested object paths.