Core concepts
Structured outputs
To get machine-readable JSON back, define the exact shape you want in a system instruction and ask the model to return raw JSON only.
Define the schema in the system prompt
Describe the JSON shape and instruct the model to skip any conversational wrapper text.
text
You are a database formatter. You must output raw JSON payloads matching the schema below.
Schema:
{
"user_id": "string",
"email": "string",
"active": "boolean"
}
Do not write markdown code fences. Output only raw JSON text.Full request
curl https://api.tnsaai.com/infer \
-H "x-api-key: $TNSA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "NGen-4.3-Pro",
"history": [
{ "role": "system", "content": "Output only raw JSON matching: {\"user_id\":\"string\",\"email\":\"string\",\"active\":\"boolean\"}" }
],
"prompt": "Register user Alice, email alice@domain.com.",
"stream": false
}'Example output
json
{ "user_id": "u_8a21", "email": "alice@domain.com", "active": true }Tips for reliable JSON
- State the schema explicitly, including every field and its type.
- Tell the model not to wrap output in markdown code fences.
- Lower the temperature (e.g. 0.2) for more deterministic structure.
- Always validate and parse the response before using it.
Validate before you trust
Models can occasionally deviate from a schema. Parse the response defensively and re-prompt if validation fails.