> 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="https://1582137130-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FkTYtq8XZyg79paoHbd93%2Fuploads%2FO6NxxY5k350Zeej9fKwv%2FScreenshot%202023-05-23%20at%2019.44.33.png?alt=media&amp;token=e5880505-887e-4038-b23c-512bd7e71eed" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
