> ## Documentation Index
> Fetch the complete documentation index at: https://koreai.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI integration

[Back to list of integrations](https://koreai.mintlify.site/agent-platform/integrations/enterprise-systems.md)

Use the OpenAI integration to let agents and workflows call OpenAI models for chat, assistants, vision, structured extraction, image generation, speech, and transcription.

| Authentication | Actions | Workflow triggers |
| - | - | - |
| API Key | [9](#supported-actions) | None |

## Supported actions

Actions are OpenAI operations that an agent runs as Action Tools during a conversation. You can also run them from an [Integration node](https://koreai.mintlify.site/agent-platform/workflows.md#integration-node) in a workflow.

| Group | Actions |
| - | - |
| Text and vision | [Ask ChatGPT](#ask-chatgpt), [Ask Assistant](#ask-assistant), [Vision Prompt](#vision-prompt), [Extract Structured Data from Text](#extract-structured-data-from-text) |
| Images and audio | [Generate Image](#generate-image), [Text-to-Speech](#text-to-speech), [Transcribe Audio](#transcribe-audio), [Translate Audio](#translate-audio) |
| Advanced | [Custom API Call](#custom-api-call) |

## Prerequisites

* An [OpenAI API key](https://platform.openai.com/api-keys) with access to the models you plan to use.

## Set up the integration

**1. Create the auth profile**

In **Integrations**, select **OpenAI** > **Connect**. On **Project Auth Profiles**, select **New Profile** > **Integration Profile** > **OpenAI** > **Continue**. Paste the key into **API Key**, keep **Header Name** (`authorization`) and **Prefix** (`Bearer `), and select **Create Profile**.

**2. Create the action tool**

In **Tools**, select **New Tool** > **Action** > **OpenAI** > **Continue**. Select the **Action** and **Auth Profile**, set parameter defaults (leave a value empty for the agent to supply at runtime), and select **Create Tool**. Then [assign the tool to an agent](https://koreai.mintlify.site/agent-platform/tools/actions.md#assign-an-action-to-an-agent).

## Action reference

### Text and vision

> [accordion] Ask ChatGPT
>
> | Parameter | Type | Description |
> | - | - | - |
> | `model` | enum | Model. |
> | `prompt` | string | Question or instruction. |
> | `temperature` | number | Randomness. Lower values give more focused output. |
> | `maxTokens` | number | Maximum tokens to generate. |
> | `topP` | number | Nucleus sampling. Use instead of temperature. |
> | `frequencyPenalty` | number | From -2.0 to 2.0. Positive values reduce repetition. |
> | `presencePenalty` | number | From -2.0 to 2.0. Positive values encourage new topics. |
> | `memoryKey` | string | Key that shares chat history across runs and flows. |
> | `roles` | object | Prior messages by role. |

> [accordion] Ask Assistant
>
> | Parameter | Type | Description |
> | - | - | - |
> | `assistant` | enum | Assistant. |
> | `prompt` | string | Question. |
> | `memoryKey` | string | Key that shares chat history across runs and flows. |

> [accordion] Vision Prompt
>
> | Parameter | Type | Description |
> | - | - | - |
> | `image` | string | Public HTTPS URL of the image. |
> | `prompt` | string | Question about the image. |
> | `detail` | enum | Image detail level. Default: `Auto`. |
> | `temperature` | number | Randomness. Lower values give more focused output. |
> | `maxTokens` | number | Maximum tokens to generate. |
> | `topP` | number | Nucleus sampling. Use instead of temperature. |
> | `frequencyPenalty` | number | From -2.0 to 2.0. Positive values reduce repetition. |
> | `presencePenalty` | number | From -2.0 to 2.0. Positive values encourage new topics. |
> | `roles` | object | Prior messages by role. |

> [accordion] Extract Structured Data from Text
>
> | Parameter | Type | Description |
> | - | - | - |
> | `model` | enum | Model. |
> | `text` | string | Unstructured text. |
> | `params` | array | Fields to extract. |

### Images and audio

> [accordion] Generate Image
>
> | Parameter | Type | Description |
> | - | - | - |
> | `model` | enum | Model. |
> | `prompt` | string | Image description. |
> | `resolution` | enum | Resolution. |
> | `quality` | enum | `Standard` is faster; `HD` has more detail. |

> [accordion] Text-to-Speech
>
> | Parameter | Type | Description |
> | - | - | - |
> | `text` | string | Text to speak. |
> | `model` | enum | Model. Default: `tts-1`. |
> | `speed` | number | From 0.25 to 4.00. |
> | `voice` | enum | Voice. Default: `alloy`. |
> | `format` | enum | Audio format. Default: `mp3`. |
> | `fileName` | string | Output file name, without extension. |

> [accordion] Transcribe Audio
>
> | Parameter | Type | Description |
> | - | - | - |
> | `audio` | string | Audio file. |
> | `language` | enum | Audio language. Default: `English`. |

> [accordion] Translate Audio
>
> | Parameter | Type | Description |
> | - | - | - |
> | `audio` | string | Audio file. |

### Advanced

> [accordion] Custom API Call
>
> | Parameter | Type | Description |
> | - | - | - |
> | `url` | object | Endpoint URL. |
> | `method` | enum | HTTP method. |
> | `headers` | object | Additional request headers. Artemis injects the authorization header. |
> | `queryParams` | object | Query parameters. |
> | `body_type` | enum | Body type. Default: `None`. |
> | `body` | object | Request body. |
> | `response_is_binary` | boolean | Turn on for binary responses. Default: `False`. |
> | `failsafe` | boolean | Returns no error when the call fails. |
> | `timeout` | number | Timeout, in seconds. |
> | `followRedirects` | boolean | Follows HTTP redirects. Default: `False`. |

## Troubleshoot common issues

| Issue | Resolution |
| - | - |
| `401 invalid_api_key` | Check the API key and its project. |
| `404 model_not_found` | Select a model your key can access. |
| `429` errors | Check your rate limits and billing in the OpenAI dashboard. |
| Image isn't analyzed | Use a public HTTPS URL that returns the image directly. |

**Related articles:**

* [Auth profiles](https://koreai.mintlify.site/agent-platform/administration/integrations-settings.md#auth-profiles)
* [Action Tools](https://koreai.mintlify.site/agent-platform/tools/actions.md)
* [OpenAI API reference](https://platform.openai.com/docs/api-reference)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.