# tOpenAIClient

Available in...

* Cloud Data Fabric
* Data Fabric
* Qlik Talend Cloud Enterprise Edition
* Real-Time Big Data Platform

Accesses the OpenAI API. With this component, you can use OpenAI models and their different capabilities.

For a quick introduction on using this component in your Job, see the following video:

## tOpenAIClient Standard properties

These properties are used to configure tOpenAIClient running in the Standard Job framework.

The Standard tOpenAIClient component belongs to the AI family.

Information noteNote: This component is available only when you have installed the 8.0.1-R2024-05 Talend Studio monthly update or a later one delivered by Talend. For more information, check with your administrator.

## Basic settings

| Properties | Description |
| --- | --- |
| Property type | Either Built-in or<br>Repository<br>.<br><br><ul> <li> <span>Built-in</span>: No property data stored                        centrally.</li> <li> <span>Repository</span>: Select the repository                        file in which the properties are stored. The fields that follow are                        completed automatically using the data retrieved.</li> </ul> |
| Schema and Edit Schema | A schema is a row description, it defines the number of fields to be<br>processed and passed on to the next component. The schema is either<br>Built-in or stored remotely in the<br>Repository.<br><br><ul> <li> <p> <span>Built-in</span>: You create and store the schema locally                           for this component only. For more information about a component schema in                           its <span>Basic settings</span> tab, see <a href="https://help.qlik.com/talend/r/en-US/8.0/studio-user-guide/basic-settings-tab" target="_blank">Basic settings tab</a>.</p> </li> <li> <p> <span>Repository</span>: You have already                           created the schema and stored it in the <span>Repository</span>. You can reuse it in various projects and Job                           designs. For more information about a component schema in its                              <span>Basic settings</span> tab, see <a href="https://help.qlik.com/talend/r/en-US/8.0/studio-user-guide/basic-settings-tab" target="_blank">Basic settings tab</a>.</p> </li> </ul><br><br>Click Edit<br>schema to make changes to the schema. If the current schema is of the Repository type, three options are available:<br><br><ul> <li> <p> <span>View schema</span>: choose this                option to view the schema only.</p> </li> <li> <p> <span>Change to built-in property</span>:                choose this option to change the schema to <span>Built-in</span> for local changes.</p> </li> <li> <p> <span>Update repository connection</span>:                choose this option to change the schema stored in the repository and decide whether                to propagate the changes to all the Jobs upon completion.</p> <p>If you just want to                propagate the changes to the current Job, you can select <span>No</span> upon completion and choose this schema metadata                again in the <span>Repository Content</span>                window.</p> </li> </ul> |
| Token | To enter the raw access token, click the [...] button<br>next to the corresponding field to bring out the Enter a new<br>password dialog box, enter the token in the text field, and click<br>OK.<br><br>Note that you can enter either a JSON string in<br>the pure password mode or a Java expression in the<br>Java mode. You can toggle between the two modes by<br>clicking switch to Java mode or switch to<br>pure password mode on the top of the text field. |
| Model | To select one of the available OpenAI models, click the<br>[...] button next to the field. In the dialog box<br>displayed, select the model that will be used or select the Use custom<br>value check box and specify the model name in the Custom<br>value field. |
| Prompt | Enter your instructions in this field. For more information on prompt<br>writing best practices, read [Prompt engineering](https://platform.openai.com/docs/guides/prompt-engineering).<br><br>Example: Given the<br>following addresses, guess the corresponding country<br>names. |

## Advanced settings

| Properties | Description |
| --- | --- |
| tStatCatcher Statistics | Select this check box to gather the Job processing metadata at a Job level<br>and at each component level. |
| Base URL | Type in the base URL address of the OpenAI API server you want to access, by<br>default it is https://api.openai.com. |
| Endpoint | Enter the second part of the URL in order to complete the base URL filled in<br>the Base URL field. Base URL and<br>Endpoint values are joined with the character<br>/ when needed. |
| Use raw JSON | Select this option to manually enter the raw JSON body. |
| Response body format | Select the response body format from the drop-down list. The right format<br>allows the connector to parse and apply operations to the response. Currently,<br>text, and JSON formats are supported.<br><br><ul> <li> <span>Text</span>: Select this format to return a plain text                        message. In that case the response payload is not parsed and it will not be                        possible to extract a sub-part from it.</li> <li> <span>JSON</span>: Select this format if the response received has                        a JSON format. In that case the payload is translated into correctly parsed                        JSON records.</li> </ul> |
| Extract a sub-part of the response | Enter the path of a node to select a sub-element of the response. If the<br>element is an array, each element of the array will be looped over. For more<br>information about the syntax for entering the node name, see [Data Shaping Selector Language syntax](https://help.qlik.com/talend/r/en-US/8.0/data-shaping-language-reference-guide/using-data-shaping-selector-language).<br><br>This field is optional and must remain empty to retrieve the entire JSON<br>response.<br><br>This field is only available if you select<br>JSON from the Response body<br>format drop-down list.<br><br>Information noteNote: This field impacts the schema<br>of the output flow of this component. It is recommended to update the schema by<br>clicking the Update configuration button after setting<br>this field. |
| Customize output with DSSL | Select this option to customize the output by entering key/value pairs. Add<br>a row in the table by clicking the plus button under the table, enter the name of<br>the node in the Name field, and enter the value in the<br>Value field.<br><br>For more information about the value<br>syntax, see [Data Shaping Selector Language<br>syntax](https://help.qlik.com/talend/r/en-US/8.0/data-shaping-language-reference-guide/using-data-shaping-selector-language).<br><br>This field is only available if you select<br>JSON from the Response body<br>format drop-down list.<br><br>Information noteNote: This option impacts the schema<br>of the output flow of this component. It is recommended to update the schema by<br>clicking the Update configuration button after setting<br>the key/value pairs in the table under this option. |

## Global Variables

| Variables | Description |
| --- | --- |
| ERROR\_MESSAGE | ERROR\_MESSAGE: the error message generated by the component when an<br>error occurs. This is an After variable and it returns a string. |
| NB\_LINE | NB\_LINE: the number<br>of rows read by an input component or transferred to an output component. This is an<br>After variable and it returns an integer. |

**Related tasks**

* [Identifying countries from input addresses using OpenAI](https://help.qlik.com/talend/en-US/components/8.0/ai/topenaiclient-tfixedflowinput-tlogrow-identifying-countries-from-addresses "This Job uses fixed input data containing addresses provided by sales team in different formats without country names, sends them to OpenAI to identify the countries, and displays the results in the console.")