# run-openai-model

## Description

The <mark style="color:purple;">`run-openai-model`</mark> adaptor uses [OpenAI Chat Completions](https://platform.openai.com/docs/guides/text-generation) to create a model response for a given chat message.

Note that this adaptor can be used to create a single response for one chat message only. If you would like to create a response for each value in a datatable column, use the [<mark style="color:purple;">`transform-columns`</mark>](/data-flo/reference-guide/transform-columns.md) adaptor. If the values are in a list, you can use the [<mark style="color:purple;">`convert-list-to-datatable`</mark>](/data-flo/reference-guide/convert-list-to-datatable.md) adaptor to convert the list to a datatable before running the model.

## Inputs

**`model`**\
Type: `text`\
Required: No\
The name of the language models to run. Consider the [price points](https://openai.com/pricing) of each model. If unspecified, defaults to `gpt-3.5-turbo`.

**`system message`**\
Type: `text`\
Required: Yes\
The system message helps set the behavior of the assistant (e.g., `You are a helpful assistant`). You can [modify the personality of the assistant](https://platform.openai.com/docs/guides/text-generation/chat-completions-api) or provide specific instructions about how it should behave throughout the conversation.&#x20;

**`user message`**\
Type: `text`\
Required: Yes\
The input of the model to run.

**`api token`**\
Type: `text`\
Required: Yes\
[OpenAI API token](https://platform.openai.com/account/api-keys)

## Outputs

**`assistant message`**\
Type: `text`\
The model prediction.

**`duration`**\
Type: `text`\
The duration of the model run.

## Examples

### Example 1: Find the capital of a country.

#### Inputs:

`model`: gpt-3.5-turbo

`system message`: You will be provided with a country name and your task is to return the name of its national capital.

`user message`: United Kingdom

`api token`: sk-\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\* (visit [API Keys](https://platform.openai.com/account/api-keys) page to retrieve the API key)

#### Outputs:

`assistant message`: London

`duration`: 1019


---

# Agent Instructions: 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:

```
GET https://cgps.gitbook.io/data-flo/reference-guide/run-openai-model.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
