Structured Output

Overview

Parasail APIs offer built-in support for structured outputs, enabling easy integration and reliable data parsing.

Best Practices

  • Clearly define your schema in the prompt.

  • Use simple and direct parameters to facilitate predictable responses.

  • Validate responses against your expected schema.

By using structured outputs, Parasail helps developers maintain consistency and integration simplicity across applications.

Currently Supported Models:

Models
Structured Outputs
JSON Schema
Python Object
Regex

parasail-llama-33-70b-fp8

Y

Y

Y

parasail-llama-4-scout-instruct

Y

Y

Y

Y

parasail-llama-4-maverick-instruct-fp8

Y

Y

Y

Y

parasail-qwen3-30b-a3b

Y

Y

Y

parasail-qwen3-235b-a22b

Y

Y

Y

parasail-qwen3-32b

Y

Y

Y

parasail-gemma3-27b-it

Y

Y

Y

Y

parasail-mistral-devstral-small

Y

Y

Y

Y

Structured Output Formats

Parasail supports several structured output formats based on OpenAI specifications:

1. JSON Schema

Define structured responses using JSON schema to ensure clear data contracts.

Prompt Example:

Expected Response:

2. Python Object

Responses structured directly as Python dictionaries for seamless Python integrations.

Prompt Example:

Expected Response (Model Dependent):

3. Regex

Define structured outputs using regular expressions to match specific response patterns.

Prompt Example:

Expected Response:

Making an API Call

Send structured output requests using Parasail's inference endpoint:


Examples:

Using the Parasail Serverless Chat Example:

JSON Example:

Using: parasail-qwen3-32b (to enable thinking, remove /no_think in the prompt to remove thinking)

Input:

Output

Python Object:

Using: parasail-qwen3-32b (to enable thinking, remove /no_think in the prompt to remove thinking)

Input:

Output:

Regex:

JSON Example:

Using: parasail-qwen3-32b (to enable thinking, remove /no_think in the prompt to remove thinking)

Input:

Output:


Parasail Structured Output—5-Minute Quick-Start

Perfect for someone who just wants to see it work once before reading the details.


  1. Prerequisites

  2. One-file demo

    Save this as structured_demo.py:

  3. Run it

    Expected output:

  4. Swap constraints in one line

    Want a date instead? Replace the schema with a regex:

    Want a fixed choice?


Troubleshooting tips:

Symptom
Likely Cause
Fix

Model ignores constraint

Prompt overshadowed parameter

Put the schema/regex in both your prompt and structured_output.

Response is valid JSON but wrong keys

additionalProperties not set

Add "additionalProperties": false to your schema.

Streaming needed

Large JSON output

Use stream=True—constraints still apply.

Last updated