> For the complete documentation index, see [llms.txt](https://docs.uify.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.uify.io/integrations/openai/text-to-structured-data.md).

# Text to structured data

This mode is use-case specific. An LLM is good at understand unstructured inputs. Oftentimes, to make use of the LLMs output in a process, you require a structured output. This mode provides just that: It returns a json with a user-defined structure, based on the input.

* **Model**: You can select any model from OpenAI that supports the `chat/completions` endpoint and that you have access to. This includes GPT-4, OpenAI's newest model, however, only if you have already been granted access. More info about that supported models can be found [here](https://platform.openai.com/docs/models/model-endpoint-compatibility).
* **Input**: The input field takes a static or dynamic value that contains the text that should be digested by the model and turned into a json.
* **Describe the input**: A description of what the input is.
* **Output fields**: Output fields are used to describe the structure of the json that will be returned by the model. Each field has a name and a type. At the moment, we support `string`, `number`, `boolean`, `number` and `array`. There needs to be at least one output field.
* **Examples**: Language models are known to perform best if you provide a list of examples. It learns and understands the patterns and applies them to the input. For every example given, you provide an input and the output values based on the structure that was defined in the previous section. Examples are optional but strongly encouraged.

<figure><img src="/files/qKeDiV1kNmrPguMi7GT5" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.uify.io/integrations/openai/text-to-structured-data.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
