curl https://api.dottxt.ai/v1/chat/completions \
-H "Authorization: Bearer $DOTTXT_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-oss-20b",
"messages": [{ "role": "user", "content": "Build a lead capture form for B2B demo requests. Need company email, team size with options 1-10, 11-50, 51-200, and 201+, and whether they want migration help." }],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "form_spec",
"schema": {
"type": "object",
"properties": {
"title": { "type": "string", "minLength": 3, "maxLength": 80 },
"layout": { "type": "string", "enum": ["single_column", "two_column"] },
"fields": {
"type": "array",
"minItems": 1,
"maxItems": 20,
"items": {
"type": "object",
"properties": {
"name": { "type": "string", "pattern": "^[a-z][a-z0-9_]*$" },
"label": { "type": "string", "minLength": 1, "maxLength": 50 },
"component": { "type": "string", "enum": ["text", "email", "number", "select", "textarea", "checkbox"] },
"required": { "type": "boolean" },
"placeholder": { "type": "string", "maxLength": 80 },
"options": { "type": "array", "items": { "type": "string", "minLength": 1, "maxLength": 40 }, "maxItems": 20 }
},
"required": ["name", "label", "component", "required"],
"additionalProperties": false,
"allOf": [
{
"if": { "properties": { "component": { "const": "select" } } },
"then": { "required": ["options"] }
}
]
}
}
},
"required": ["title", "layout", "fields"],
"additionalProperties": false
}
}
}
}'