Laboratorio de salida estructurada

Valida muestras JSON ajustadas a un esquema y copia patrones de solicitud por proveedor sin llamar a la API de ningún modelo.

Espacio de trabajo de salida estructurada
Preajustes de ejemplo
Resultado de validación

Se encontraron 5 incidencias.

Ruta $.price
Incidencia Falta un campo obligatorio.
Ruta $.extra
Incidencia Campo inesperado.
Ruta $.attributes[0].rank
Incidencia Campo inesperado.
Ruta $.in_stock
Incidencia Se esperaba boolean, pero se recibió string.
Ruta $.sku
Incidencia Se esperaba string, pero se recibió number.
Patrones por proveedor
Prompt independiente del proveedor
Usa la estructura JSON objetivo como contrato y rechaza claves adicionales.
Return JSON only.
Use the target JSON structure as the contract for keys, nesting, arrays, and value types.
Do not wrap the result in markdown.
Do not add extra keys.

Target structure:
{
  "sku": "abc-123",
  "price": 19.99,
  "in_stock": true,
  "attributes": [
    {
      "name": "color",
      "value": "blue"
    }
  ]
}
OpenAI Responses API
Usa text.format con un esquema JSON estricto para solicitar salida estructurada directa.
from openai import OpenAI

client = OpenAI()

response = client.responses.create(
    model="gpt-5",
    input="Return the response in the required JSON shape.",
    text={
        "format": {
            "type": "json_schema",
            "name": "structured_output",
            "strict": True,
            "schema": {
              "type": "object",
              "properties": {
                "sku": {
                  "type": "string"
                },
                "price": {
                  "type": "number"
                },
                "in_stock": {
                  "type": "boolean"
                },
                "attributes": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "value": {
                        "type": "string"
                      }
                    },
                    "required": [
                      "name",
                      "value"
                    ],
                    "additionalProperties": false
                  }
                }
              },
              "required": [
                "sku",
                "price",
                "in_stock",
                "attributes"
              ],
              "additionalProperties": false
            },
        }
    },
)

print(response.output_text)
Patrón de prompt para Anthropic
Pega la estructura objetivo literalmente e indica al modelo que responda solo con JSON.
You are returning structured data for a downstream parser.
Output JSON only.
Match the exact keys, nesting, and value types shown below.
If a field is unknown, return a valid placeholder of the same type.

Target structure:
{
  "sku": "abc-123",
  "price": 19.99,
  "in_stock": true,
  "attributes": [
    {
      "name": "color",
      "value": "blue"
    }
  ]
}