> Markdown versions of all pages of this connector library are available by appending `.md` to the page URL. For the full index of connectors, see [llms.txt](https://connectors.appmixer.com/llms.txt).

# appmixer.ai.openai.TransformTextToJSON

- Component: `appmixer.ai.openai.TransformTextToJSON`
- Kind: Action
- Version: 1.0.0
- Visibility: Public
- Connector: [appmixer.ai.openai 2.1.3](https://connectors.appmixer.com/connector/appmixer.ai.openai/2.1.3.md)
- Component page: <https://connectors.appmixer.com/connector/appmixer.ai.openai/2.1.3/component/appmixer.ai.openai.TransformTextToJSON>

Extract structured JSON data from text using AI.

## Input ports

### Port `in`

| Field | Type | Description |
| --- | --- | --- |
| Text (`text`) | textarea | The text from which to extract structured JSON data. Example: `John is 25 years old.`. |
| Output JSON Schema (`jsonSchema`) | textarea | The schema that defines the structure of the output JSON. Use [JSON Schema format](https://json-schema.org/). Example: `{"type":"object","properties":{"name":{"type":"string"}, "age":{"type":"number"}}}`. It must be a valid JSON schema and must be of "type": "object". If you want to produce an array, you can nest the array under an object property of type array. Example: `{"type":"object","properties":{"contacts":{"type":"array","items":{"type":"object","properties":{"name":{"type":"string"},"age":{"type":"number"}}}}}}`. |
| Model (`model`) | text | ID of the model to use. |

## Output ports

### Port `out`

Variables are loaded dynamically from `/component/appmixer/ai/openai/TransformTextToJSON?outPort=out&ignoreAuth=true`.

## Full metadata (component.json)

```json
{
  "name": "appmixer.ai.openai.TransformTextToJSON",
  "author": "Appmixer <info@appmixer.com>",
  "description": "Extract structured JSON data from text using AI.",
  "auth": {
    "service": "appmixer:ai:openai"
  },
  "inPorts": [
    {
      "name": "in",
      "schema": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string"
          },
          "jsonSchema": {
            "type": "string"
          },
          "model": {
            "type": "string"
          }
        },
        "required": [
          "text",
          "jsonSchema"
        ]
      },
      "inspector": {
        "inputs": {
          "text": {
            "label": "Text",
            "type": "textarea",
            "index": 1,
            "tooltip": "The text from which to extract structured JSON data. Example: <code>John is 25 years old.</code>."
          },
          "jsonSchema": {
            "label": "Output JSON Schema",
            "type": "textarea",
            "index": 2,
            "tooltip": "The schema that defines the structure of the output JSON. Use <a target=\"blank\" href=\"https://json-schema.org/\">JSON Schema format</a>. Example: <code>{\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"}, \"age\":{\"type\":\"number\"}}}</code>. It must be a valid JSON schema and must be of \"type\": \"object\". If you want to produce an array, you can nest the array under an object property of type array. Example: <code>{\"type\":\"object\",\"properties\":{\"contacts\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"},\"age\":{\"type\":\"number\"}}}}}}</code>."
          },
          "model": {
            "type": "text",
            "index": 3,
            "label": "Model",
            "tooltip": "ID of the model to use.",
            "defaultValue": "gpt-4o",
            "source": {
              "url": "/component/appmixer/ai/openai/ListModels?outPort=out",
              "data": {
                "transform": "./ListModels#toSelectOptions"
              }
            }
          }
        }
      }
    }
  ],
  "outPorts": [
    {
      "name": "out",
      "source": {
        "url": "/component/appmixer/ai/openai/TransformTextToJSON?outPort=out&ignoreAuth=true",
        "data": {
          "properties": {
            "generateOutputPortOptions": true
          },
          "messages": {
            "in/text": "dummy",
            "in/jsonSchema": "inputs/in/jsonSchema"
          }
        }
      }
    }
  ],
  "icon": "(data URI omitted)"
}
```
