Documentation Index
Fetch the complete documentation index at: https://concentrate.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Structured output lets you constrain AI model responses to match a JSON schema you define. Instead of parsing free-form text, you get guaranteed valid JSON that conforms to your schema — ideal for data extraction, API integrations, and any workflow where you need predictable output. Use structured output when you need to:- Extract structured data from unstructured text (names, dates, entities)
- Generate responses that feed directly into your application logic
- Ensure consistent output format across different models and providers
- Build reliable pipelines without fragile text parsing
Prerequisites
Before using structured output, ensure you have:- A Concentrate AI API key (get one here)
- A model that supports structured output (most major models do — see Provider Support)
- A valid JSON Schema defining your desired output format
Quick Start
Format Types
Thetext.format parameter supports three modes:
json_schema
Forces the model to return JSON conforming to a specific JSON Schema. This is the most powerful and recommended option.| Property | Type | Required | Description |
|---|---|---|---|
type | string | Yes | Must be "json_schema" |
name | string | Yes | A name for the schema (alphanumeric, underscores, dots, hyphens) |
schema | object | Yes | A valid JSON Schema object |
description | string | No | Description of the expected output |
strict | boolean | No | Enable strict schema enforcement (default behavior varies by provider) |
json_object
Forces the model to return valid JSON, but without schema enforcement. Useful when you want JSON but don’t need a strict structure.text
Default mode. The model returns free-form text with no structural constraints.Chat Completions API
If you’re using the Chat Completions endpoint (/v1/chat/completions), structured output uses the response_format parameter instead:
The Responses API (
/v1/responses) uses text.format. The Chat Completions API (/v1/chat/completions) uses response_format. The underlying behavior is the same.Strict Mode
Whenstrict is enabled (or when using providers like OpenAI where it’s the default), the model is guaranteed to produce output that exactly matches your schema. The API will:
- Require all properties listed in
required - Reject any additional properties (when
additionalProperties: false) - Enforce type constraints exactly
Advanced Schema Examples
Nested Objects
Enums and Fixed Values
Streaming
Structured output works with streaming. The JSON is delivered incrementally viaresponse.output_text.delta events:
Some provider/model combinations may not support
json_schema in streaming mode. In those cases, the API automatically falls back to json_object mode with a system prompt describing your schema.Provider Support
Concentrate AI normalizes structured output across providers automatically. Here’s how each provider handles it:| Provider | json_schema | json_object | Notes |
|---|---|---|---|
| OpenAI | Native | Native | Full support including strict mode |
| Anthropic | Native | Fallback | Falls back to system prompt for json_object |
| Google (Gemini) | Native | - | Some schema keywords stripped for compatibility |
| AWS Bedrock | Native | - | Schema is stringified for the Bedrock API |
| Mistral | Native | - | Uses Conversations API format |
| Cohere | Adapted | - | Schema embedded in json_object format |
| Cloudflare | Adapted | Adapted | Provider-specific schema handling |
| Z.ai | Fallback | Native | Falls back to system prompt + json_object |
json_schema, Concentrate AI automatically injects a system prompt describing your schema and uses json_object mode. The model will still return JSON matching your schema, but strict enforcement is best-effort rather than guaranteed.
You don’t need to worry about these provider differences. Just set
text.format and Concentrate AI handles the adaptation automatically.Best Practices
Schema Design
- Keep schemas focused — only include the fields you need
- Use descriptions — add a
descriptionto help the model understand what each field represents - Use enums — constrain fields to specific allowed values when possible
- Set
additionalProperties: false— required for strict mode and generally a good idea
Choosing the Right Format
json_schema— use when you need guaranteed structure (recommended for most use cases)json_object— use when you want JSON but the structure can varytext— use when structured output isn’t needed
Performance Tips
- Simpler schemas produce faster, more reliable results
- Deeply nested schemas may increase latency
- Combine with
max_output_tokensto limit response size
Troubleshooting
Model returns text instead of JSON
Solutions:- Verify
text.formatis set correctly in your request - Ensure the model supports structured output
- Check that
typeis"json_schema"or"json_object", not"text"
Schema validation errors
Solutions:- Ensure your schema is valid JSON Schema (Draft 7)
- When using strict mode, include
"additionalProperties": falseon all object types - The
namefield must match the pattern:^[a-zA-Z0-9_.-]+$ - The
schemafield must be an object, not a string
Output doesn’t match schema
Solutions:- Enable
strict: truefor providers that support it - Use a provider with native
json_schemasupport (OpenAI, Anthropic, Gemini) - Simplify your schema — very complex schemas may confuse some models
- Add clear descriptions to schema properties
Related Pages
Create Response
Main API endpoint
Request Parameters
Complete parameter reference
Tool Calling
Function calling with structured parameters
Chat Completions
OpenAI-compatible endpoint