Inference
Structured outputs
Request JSON output with json_object or JSON Schema response formats.
Updated
Use response_format when downstream code needs JSON output. LLMBase supports
the OpenAI-compatible json_object and json_schema request shapes on models
that advertise that feature.
Before sending structured output requests, choose a model whose metadata
includes json_mode or structured_outputs in supported_features.
JSON object
Use json_object when your application can validate or repair the final shape
itself.
{
"model": "<model-id-from-/v1/models>",
"messages": [
{ "role": "user", "content": "Return three product risks as JSON." }
],
"response_format": { "type": "json_object" }
}
JSON Schema
Use json_schema when missing fields or wrong enum values should be treated as
model errors.
{
"model": "<model-id-from-/v1/models>",
"messages": [
{ "role": "user", "content": "Extract the company name and priority." }
],
"response_format": {
"type": "json_schema",
"json_schema": {
"name": "ticket",
"schema": {
"type": "object",
"properties": {
"company": { "type": "string" },
"priority": { "type": "string", "enum": ["low", "medium", "high"] }
},
"required": ["company", "priority"],
"additionalProperties": false
}
}
}
}
Structured output is still model generation, not a database constraint. Keep schemas compact, include all required fields, and validate returned JSON in your application before writing to production systems.
Capability checks
Check /v1/models?metadata=true for the live list before using structured
output in production:
curl "https://api.llmbase.ai/v1/models?metadata=true" \
-H "Authorization: Bearer $LLMBASE_API_KEY"
Models without JSON support
json_objectis accepted by every chat model. On a model whosesupported_featuresdoes not includejson_mode, the request runs without JSON mode: ask for JSON in your prompt and validate the result, because the output is not guaranteed to be valid JSON.json_schemais never ignored, because callers rely on schema-valid output. On a model withoutstructured_outputsinsupported_features, LLMBase returns400withinvalid_request_errorand codeunsupported_request_featuresinstead of running the request. Choose a model that listsstructured_outputs, or usejson_object.