myt AI Cloud

By Mauritius Telecom

Beta
⌘K
Core features

Structured outputs

Constrain model responses to a JSON schema for reliable machine-readable output.

POST

/v1/chat/completions

Use response_format to request JSON-mode or schema-constrained output from supported models.

Request body

Add response_format to a standard chat completions request.

FieldTypeNotes
response_format.typestring"json_schema"
response_format.json_schema.namestringIdentifier for the schema (used in the response).
response_format.json_schema.strictbooleantrue enforces the schema strictly; the model will refuse rather than produce invalid output.
response_format.json_schema.schemaobjectA JSON Schema object.

Example request — strict schema

{
"model": "myt/qwen3.6-35b-a3b",
"messages": [
  { "role": "user", "content": "Extract: Alice is 30 years old." }
],
"response_format": {
  "type": "json_schema",
  "json_schema": {
    "name": "person",
    "strict": true,
    "schema": {
      "type": "object",
      "properties": {
        "name": { "type": "string" },
        "age":  { "type": "integer" }
      },
      "required": ["name", "age"],
      "additionalProperties": false
    }
  }
}
}

Example request — JSON object mode (simpler, less strict)

{
"model": "myt/qwen3.6-35b-a3b",
"messages": [
  { "role": "system", "content": "Respond only with valid JSON." },
  { "role": "user",   "content": "Give me a JSON object with name and age for Alice who is 30." }
],
"response_format": { "type": "json_object" }
}

Response

message.content is a JSON string. Parse it in your application.

{
"id": "chatcmpl-struct456",
"object": "chat.completion",
"created": 1749366600,
"model": "myt/qwen3.6-35b-a3b",
"choices": [
  {
    "index": 0,
    "finish_reason": "stop",
    "message": {
      "role": "assistant",
      "content": "{\"name\":\"Alice\",\"age\":30}"
    }
  }
],
"usage": {
  "prompt_tokens": 18,
  "completion_tokens": 9,
  "total_tokens": 27
}
}

Errors

StatusWhen
400Invalid schema, model does not support structured outputs
401API key missing or invalid
429Rate limit or budget exceeded

Code examples

curl -sS --request "POST" \
  --url "$MYT_BASE_URL/chat/completions" \
  --header "Authorization: Bearer $MYT_API_KEY" \
  --header "Content-Type: application/json" \
  --data '{"model":"myt/qwen3.6-35b-a3b","messages":[{"role":"user","content":"Extract: Alice is 30 years old."}],"response_format":{"type":"json_schema","json_schema":{"name":"person","strict":true,"schema":{"type":"object","properties":{"name":{"type":"string"},"age":{"type":"integer"}},"required":["name","age"],"additionalProperties":false}}}}'

Full parameter reference: Chat completions.

On this page