Structured Output
When large models perform information extraction or structured data generation tasks, they often return extra text (such as `json markers), causing downstream parsing failures.
Solution
Enable structured output by setting the response_format parameter to force the model to return a standard format pure JSON string.
Supported Models
GLM
- GLM-5.1
- GLM-5
- GLM-4.7
Minimax
- MiniMax-M2.5
- MiniMax-M2.1
Usage
response_format: Specify response format, set to {"type": "json_object"} to enable JSON mode
Structured Output Examples
Using in Python
import requests
url = "https://api.jalapeno-cloud.ai/v1/chat/completions"
payload = {
"model": "${MODEL_NAME}",
"messages": [
{
"role": "system",
"content": "Extract company full name, city, contact phone number as JSON. Keys: company_full_name, city, contact_phone. If info missing, set value to null."
},
{
"role": "user",
"content": "Global Cloud Solution Co., Ltd. is based in Singapore, no phone number provided."
}
],
"response_format": {
"type": "json_object"
}
}
headers = {
"Authorization": "Bearer ${API_KEY}",
"Content-Type": "application/json"
}
response = requests.request("POST", url, json=payload, headers=headers)
print(response.text)
Using in curl
curl --location --request POST 'https://api.jalapeno-cloud.ai/v1/chat/completions' \
--header 'Authorization: Bearer ${API_KEY}' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "${MODEL_NAME}",
"messages": [
{
"role": "system",
"content": "Extract company full name, city, contact phone number as JSON. Keys: company_full_name, city, contact_phone. If info missing, set value to null."
},
{
"role": "user",
"content": "Global Cloud Solution Co., Ltd. is based in Singapore, no phone number provided."
}
],
"response_format": {
"type": "json_object"
}
}'
Response
{
"company_full_name": "Global Cloud Solution Co., Ltd.",
"city": "Singapore",
"contact_phone": null
}