# OPENAICHAT

## Overview

The **OPENAICHAT** workflow application lets you interact with AI chat models from multiple providers, including OpenAI, Mistral AI, Google Gemini, and Anthropic Claude.

## How it works

* The application allows you to interact with completion models.
* Application logs are available. These can be specified by setting the value of the `OpenAIChatLogLevel` parameter in the `web.config` file to `0` to deactivate logs, `1` for error logs, `2` for information logs, or `3` for debug logs; the default value is `0`.

## Supported providers

<table><thead><tr><th width="206.264892578125">Provider</th><th width="207.47296142578125">API format</th><th>Default URL</th></tr></thead><tbody><tr><td>OpenAI</td><td>Native</td><td><code>https://api.openai.com/v1/chat/completions</code></td></tr><tr><td>Mistral AI</td><td>OpenAI-compatible</td><td><code>https://api.mistral.ai/v1/chat/completions</code></td></tr><tr><td>Google Gemini</td><td>OpenAI-compatible</td><td><code>https://generativelanguage.googleapis.com/v1beta/openai/chat/completions</code></td></tr><tr><td>Anthropic Claude</td><td>Native</td><td><code>https://api.anthropic.com/v1/messages</code></td></tr></tbody></table>

The provider is automatically detected from the API URL, but it can be explicitly set using the `PROVIDER` parameter (see the [Optional parameters](#optional-parameters) table below).

### OpenAI-compatible providers

The OPENAICHAT application automatically detects and supports OpenAI-compatible providers based on the API URL. For providers that use the OpenAI-compatible API format (Mistral AI, Google Gemini), you can set the `URL` parameter (or the provider's API URL setting in the `web.config` file) to the provider's endpoint.

{% hint style="warning" %}
For **Anthropic Claude**, which uses a different native API, either set `URL` to an Anthropic endpoint (auto-detected), or set `PROVIDER = anthropic` explicitly.
{% endhint %}

### **Provider API configuration settings**

<table><thead><tr><th width="279.69512939453125" valign="top">Setting</th><th valign="top">Description</th></tr></thead><tbody><tr><td valign="top"><code>OpenAIApiKey</code></td><td valign="top">OpenAI API key</td></tr><tr><td valign="top"><code>OpenAIChatApiUrl</code></td><td valign="top">OpenAI API endpoint</td></tr><tr><td valign="top"><code>MistralApiKey</code></td><td valign="top">Mistral AI API key (required for Mistral)</td></tr><tr><td valign="top"><code>MistralChatApiUrl</code></td><td valign="top">Mistral AI API endpoint<br><strong>Default:</strong> <code>https://api.mistral.ai/v1/chat/completions</code></td></tr><tr><td valign="top"><code>GeminiApiKey</code></td><td valign="top">Google Gemini API key (required for Gemini)</td></tr><tr><td valign="top"><code>GeminiChatApiUrl</code></td><td valign="top"><p>Google Gemini API endpoint</p><p><strong>Default:</strong> <code>https://generativelanguage.googleapis.com/v1beta/openai/chat/completions</code> <br><strong>Note:</strong> This is a beta endpoint that may change when GA.</p></td></tr><tr><td valign="top"><code>AnthropicApiKey</code></td><td valign="top">Anthropic API key (required for Anthropic)</td></tr><tr><td valign="top"><code>AnthropicChatApiUrl</code></td><td valign="top">Anthropic API endpoint <br><strong>Default:</strong> <code>https://api.anthropic.com/v1/messages</code></td></tr></tbody></table>

{% hint style="warning" %}
Each provider requires its own API key. There is no cross-provider fallback.
{% endhint %}

### **Provider auto-detection**

<table><thead><tr><th valign="top">URL pattern</th><th valign="top">Detected provider</th></tr></thead><tbody><tr><td valign="top">Contains <code>api.anthropic.com</code></td><td valign="top">Anthropic</td></tr><tr><td valign="top">Contains <code>generativelanguage.googleapis.com</code></td><td valign="top">Gemini</td></tr><tr><td valign="top">Contains <code>api.mistral.ai</code></td><td valign="top">Mistral</td></tr><tr><td valign="top">Default</td><td valign="top">OpenAI</td></tr></tbody></table>

### Compatible providers

<table><thead><tr><th valign="top">Provider</th><th valign="top">Type</th></tr></thead><tbody><tr><td valign="top">Azure OpenAI</td><td valign="top">Cloud</td></tr><tr><td valign="top">Ollama</td><td valign="top">Self-hosted</td></tr><tr><td valign="top">vLLM</td><td valign="top">Self-hosted</td></tr><tr><td valign="top">LocalAI</td><td valign="top">Self-hosted</td></tr><tr><td valign="top">LM Studio</td><td valign="top">Self-hosted</td></tr><tr><td valign="top">Together AI</td><td valign="top">Cloud</td></tr><tr><td valign="top">Groq</td><td valign="top">Cloud</td></tr><tr><td valign="top">Mistral AI</td><td valign="top">Cloud</td></tr><tr><td valign="top">OpenRouter</td><td valign="top">Cloud</td></tr></tbody></table>

{% hint style="warning" %}

* Do not use `MAX_COMPLETION_TOKENS` and `REASONING_EFFORT` with non-OpenAI providers unless you know the provider supports these parameters.
* Use `MAX_TOKENS` for token limits when using non-OpenAI providers.
* Some providers may ignore unsupported parameters, while others may return an error.
  {% endhint %}

## Required parameters

<table data-full-width="false"><thead><tr><th width="238.32476806640625" valign="top">Parameter</th><th width="110.18804931640625" valign="top">Type</th><th width="110.04266357421875" valign="top">Direction</th><th valign="top">Description</th></tr></thead><tbody><tr><td valign="top"><code>MODEL</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top">ID of the model to use<br><br>You can find available models at the following link: <a href="https://platform.openai.com/docs/models/">https://platform.openai.com/docs/models/</a>; the endpoint used by default is <code>/v1/chat/completions</code>.</td></tr></tbody></table>

You can use either of the following configurations: with system/user messages, with a message number, or with a JSON message array.

### With system/user messages

<table data-full-width="false"><thead><tr><th width="238.32489013671875" valign="top">Parameter</th><th width="110.18798828125" valign="top">Type</th><th width="110.042724609375" valign="top">Direction</th><th valign="top">Description</th></tr></thead><tbody><tr><td valign="top"><code>SYSTEM_MESSAGE</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top">The system message content</td></tr><tr><td valign="top"><code>USER_MESSAGE</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top">The user message content</td></tr></tbody></table>

### With a message number

<table data-full-width="false"><thead><tr><th width="238.79205322265625" valign="top">Parameter</th><th width="110.18804931640625" valign="top">Type</th><th width="110.04266357421875" valign="top">Direction</th><th valign="top">Description</th></tr></thead><tbody><tr><td valign="top"><code>MESSAGE_ROLEx</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top">The type of the message, where <code>x</code> corresponds to the message number; the<br>value should be <code>assistant</code>, <code>system</code>, or <code>user</code></td></tr><tr><td valign="top"><code>MESSAGE_CONTENTx</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top">The user message content, where <code>x</code> corresponds to the message number</td></tr></tbody></table>

### With a JSON message array

<table data-full-width="false"><thead><tr><th width="238.32489013671875" valign="top">Parameter</th><th width="110.18798828125" valign="top">Type</th><th width="110.04278564453125" valign="top">Direction</th><th valign="top">Description</th></tr></thead><tbody><tr><td valign="top"><code>MESSAGE_JSON</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top"><p>The JSON array message object; the structure should match the following:</p><pre class="language-json"><code class="lang-json">[
    {
        "role": "assistant/system/user",
        "content": "First message content"
    },
    {
        "role": "assistant/system/user",
        "content": "Second message content"
    }
]
</code></pre></td></tr></tbody></table>

## Optional parameters

<table data-full-width="false"><thead><tr><th width="237.63812255859375" valign="top">Parameters</th><th width="111" valign="top">Type</th><th width="104" valign="top">Direction</th><th valign="top">Description</th></tr></thead><tbody><tr><td valign="top"><code>PROVIDER</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top">Force provider selection; if not set, the provider is auto-detected from the URL<br><br><strong>Possible values:</strong> <code>openai</code>, <code>mistral</code>, <code>gemini</code>, or <code>anthropic</code></td></tr><tr><td valign="top"><code>API_KEY</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top">API key<br><br>By default, this value comes from the <code>OpenAIApiKey</code> parameter in the <code>web.config</code> file.</td></tr><tr><td valign="top"><code>URL</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top">API endpoint; this value comes from the <code>OpenAIChatApiUrl</code> parameter in the <code>web.config</code> file, if it's been defined</td></tr><tr><td valign="top"><code>TEMPERATURE</code></td><td valign="top">NUMERIC</td><td valign="top">IN</td><td valign="top"><p>Sampling temperature, between <code>0</code> and <code>1</code></p><p><strong>Default:</strong> <code>1</code></p><p></p><p>Higher values (e.g. <code>0.8</code>) will make the output more random, while lower values (e.g. <code>0.2</code>) will make it more focused and deterministic.</p></td></tr><tr><td valign="top"><code>TOP_P</code></td><td valign="top">NUMERIC</td><td valign="top">IN</td><td valign="top"><p>An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with <code>top_p</code> probability mass</p><p><strong>Default:</strong> <code>1</code></p><p></p><p>📌 <strong>Example:</strong> A value of <code>0.1</code> means only the tokens comprising the top 10% probability mass are considered.</p></td></tr><tr><td valign="top"><code>FREQUENCY_PENALTY</code></td><td valign="top">NUMERIC</td><td valign="top">IN</td><td valign="top"><p>Number between <code>-2.0</code> and <code>2.0</code></p><p><strong>Default:</strong> <code>0</code></p><p></p><p>Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.</p></td></tr><tr><td valign="top"><code>MAX_TOKENS</code></td><td valign="top">NUMERIC</td><td valign="top">IN</td><td valign="top"><p>Maximum number of tokens that can be generated in the chat completion</p><p></p><p><strong>Default:</strong> <code>4096</code> for Anthropic only; undefined for other providers</p><p></p><p>✏️ <strong>Note:</strong> For reasoning models (o1, o3, GPT-5 series), use <code>MAX_COMPLETION_TOKENS</code> instead. If both <code>MAX_TOKENS</code> and <code>MAX_COMPLETION_TOKENS</code> are specified, <code>MAX_COMPLETION_TOKENS</code> takes precedence.</p></td></tr><tr><td valign="top"><code>MAX_COMPLETION_TOKENS</code></td><td valign="top">NUMERIC</td><td valign="top">IN</td><td valign="top"><p>Maximum number of tokens to generate in the completion </p><p></p><p>This parameter is required for reasoning models (o1, o3, GPT-5 series) and takes precedence over <code>MAX_TOKENS</code> when both are specified. For reasoning models, this value includes both reasoning tokens and visible completion tokens.</p></td></tr><tr><td valign="top"><code>REASONING_EFFORT</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top"><p>Controls the effort level for reasoning models; only applicable to reasoning models (o1, o3, GPT-5 series) </p><p></p><p><strong>Values:</strong> <code>low</code>, <code>medium</code>, or <code>high</code></p><p></p><p>⚠️ <strong>Important:</strong> Do not use this parameter with non-reasoning models (e.g. GPT-4o, GPT-4-turbo) as this will cause an API error.</p></td></tr><tr><td valign="top"><code>PRESENCE_PENALTY</code></td><td valign="top">NUMERIC</td><td valign="top">IN</td><td valign="top"><p>Number between <code>-2.0</code> and <code>2.0</code></p><p><strong>Default:</strong> <code>0</code></p><p></p><p>Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.</p></td></tr><tr><td valign="top"><code>RESPONSE_FORMAT</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top"><p>Format of the response: <code>json_object</code>, <code>text</code>, or <code>json_schema</code></p><p></p><p>When the value is <code>json_object</code>, the system prompt should contain the JSON keyword. When the value is <code>json_schema</code>, the expected schema must be provided in the  <code>RESPONSE_FORMAT_JSON_SCHEMA</code> parameter.</p></td></tr><tr><td valign="top"><code>RESPONSE_FORMAT_JSON_SCHEMA</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top"><p>The JSON schema that will be used by the model to respond.<br></p><p>See the <a href="#response_format_json_schema"><code>RESPONSE_FORMAT_JSON_SCHEMA</code></a> section below for an example.</p></td></tr><tr><td valign="top"><code>APP_RESPONSE_IGNORE_ERROR</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top"><p>Specifies (<code>Y</code> or <code>N</code>) if error should be ignored</p><p><strong>Default:</strong> <code>N</code><br></p><p>✏️ <strong>Note:</strong> In case of error, if the parameter has <code>Y</code> as its value, the error will be ignored and defined OUT parameters (<code>APP_RESPONSE_STATUS</code> or <code>APP_RESPONSE_CONTENT</code>) will be mapped. Otherwise, an exception will be thrown.</p></td></tr><tr><td valign="top"><code>TOOLS</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top">List of tools available to the model, formatted in JSON and compliant with OpenAI's format: <a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-tools">https://platform.openai.com/docs/api-reference/chat/create#chat-create-tools</a>; see the <a href="#tools"><code>TOOLS</code></a> section below for an example</td></tr><tr><td valign="top"><code>TOOL_CHOICE_REQUIRED</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top"><p>Specifies whether the model must necessarily choose a tool</p><p></p><p><strong>Values:</strong> <code>Y</code> or <code>N</code> (default)</p></td></tr><tr><td valign="top"><code>PARALLEL_TOOL</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top"><p>Specifies whether the model can choose multiple tools</p><p></p><p><strong>Values:</strong> <code>Y</code> (default) or <code>N</code></p></td></tr><tr><td valign="top"><code>MESSAGE_HISTORY</code></td><td valign="top">TEXT</td><td valign="top">INOUT</td><td valign="top"><p>The message history in JSON format</p><p></p><p>The reference structure follows OpenAI's documentation for the <code>messages</code> object:<br><a href="https://platform.openai.com/docs/api-reference/chat/create#chat-create-messages">https://platform.openai.com/docs/api-reference/chat/create#chat-create-messages</a>.</p></td></tr><tr><td valign="top"><code>SELECTED_TOOLS</code></td><td valign="top">TEXT</td><td valign="top">OUT</td><td valign="top">The list of selected tool names, separated by commas</td></tr><tr><td valign="top"><code>SELECTED_TOOLS_PARAM</code></td><td valign="top">TEXT</td><td valign="top">OUT</td><td valign="top">A JSON array representing the list of selected tools along with their parameters; see the <a href="#selected_tools_params"><code>SELECTED_TOOLS_PARAMS</code></a> section below for an example output</td></tr><tr><td valign="top"><code>SELECTED_TOOLS_COUNT</code></td><td valign="top">NUMERIC</td><td valign="top">OUT</td><td valign="top">The number of selected tools</td></tr><tr><td valign="top"><code>RESULT</code></td><td valign="top">TEXT</td><td valign="top">OUT</td><td valign="top">Chat result call</td></tr><tr><td valign="top"><code>RESULT_CONTENT</code></td><td valign="top">TEXT</td><td valign="top">OUT</td><td valign="top">Content of the assistant message</td></tr><tr><td valign="top"><code>RESULT_TOTAL_TOKENS</code></td><td valign="top">NUMERIC</td><td valign="top">OUT</td><td valign="top">Total of tokens used for generation</td></tr><tr><td valign="top"><code>RESULT_COMPLETION_TOKENS</code></td><td valign="top">NUMERIC</td><td valign="top">OUT</td><td valign="top">Total of tokens used for generation</td></tr><tr><td valign="top"><code>RESULT_PROMPT_TOKENS</code></td><td valign="top">NUMERIC</td><td valign="top">OUT</td><td valign="top">Total of token used for the prompt</td></tr><tr><td valign="top"><code>RESULT_REASONING_TOKENS</code></td><td valign="top">NUMERIC</td><td valign="top">OUT</td><td valign="top"><p>Number of tokens used for internal reasoning by reasoning models (o1, o3, GPT-5 series)</p><p></p><p>These tokens are not visible in the response but count toward usage and billing. Returns <code>0</code> for non-reasoning models.</p></td></tr><tr><td valign="top"><code>RESULT_CACHED_TOKENS</code></td><td valign="top">NUMERIC</td><td valign="top">OUT</td><td valign="top"><p>Number of prompt tokens that were served from cache</p><p></p><p>Cached tokens are billed at a reduced rate. This is useful for understanding cost optimization from prompt caching.</p></td></tr><tr><td valign="top"><code>APP_RESPONSE_STATUS</code></td><td valign="top">TEXT</td><td valign="top">OUT</td><td valign="top">Response status code</td></tr><tr><td valign="top"><code>APP_RESPONSE_CONTENT</code></td><td valign="top">TEXT</td><td valign="top">OUT</td><td valign="top">Response payload or error message</td></tr><tr><td valign="top"><code>USER_AUDIO</code></td><td valign="top">FILE</td><td valign="top">IN</td><td valign="top">Local audio file sent as audio input <br><br>WorkflowGen converts the file to base64 before sending the request. Supported by OpenAI (audio-capable models only), Mistral, and Gemini.</td></tr><tr><td valign="top"><code>USER_DOCUMENT_URL</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top">URL of a document to analyze<br><br>Best used with the optional <code>USER_DOCUMENT_NAME</code> parameter. Supported by Mistral and Anthropic (PDF URLs only for Anthropic).</td></tr><tr><td valign="top"><code>USER_FILE_ID</code></td><td valign="top">TEXT</td><td valign="top">IN</td><td valign="top">File identifier returned by the provider's Files API<br><br>Use this when the file has already been uploaded outside OPENAICHAT. Supported by OpenAI, Mistral, and Anthropic.</td></tr><tr><td valign="top"><code>USER_FILE</code></td><td valign="top">FILE</td><td valign="top">IN</td><td valign="top">Local file sent inline in the chat request as base64 file content<br><br>No pre-upload step is required. Supported by OpenAI and Anthropic. Anthropic currently accepts PDF and plain text files only in this flow.</td></tr></tbody></table>

## Multimodal input

OPENAICHAT supports multimodal user input through `USER_AUDIO`, `USER_DOCUMENT_URL`, `USER_FILE_ID`, and `USER_FILE`.

Use these parameters together with `USER_MESSAGE` to tell the model what to do with the attached audio, document, or file.

### Provider support

<table data-header-hidden><thead><tr><th>Provider</th><th align="center" valign="middle">USER_AUDIO</th><th width="200.28204345703125" align="center" valign="middle">USER_DOCUMENT_URL</th><th align="center" valign="middle">USER_FILE_ID</th><th width="123.32049560546875" align="center">USER_FILE</th></tr></thead><tbody><tr><td>OpenAI</td><td align="center" valign="middle">Yes, with audio-capable models</td><td align="center" valign="middle">No</td><td align="center" valign="middle">Yes</td><td align="center">Yes</td></tr><tr><td>Mistral</td><td align="center" valign="middle">Yes</td><td align="center" valign="middle">Yes</td><td align="center" valign="middle">Yes</td><td align="center">No</td></tr><tr><td>Gemini (OpenAI-compatible endpoint)</td><td align="center" valign="middle">Yes</td><td align="center" valign="middle">No</td><td align="center" valign="middle">No</td><td align="center">No</td></tr><tr><td>Anthropic</td><td align="center" valign="middle">No</td><td align="center" valign="middle">Yes, for PDF document URLs</td><td align="center" valign="middle">Yes</td><td align="center">Yes, for PDF and plain text files</td></tr></tbody></table>

### Indexed variants

These parameters also support indexed variants when a single user message must contain multiple content blocks.

#### 📌 Examples

* `USER_AUDIO1`, `USER_AUDIO2`
* `USER_DOCUMENT_URL1`, `USER_DOCUMENT_URL2`
* `USER_FILE_ID1`, `USER_FILE_ID2`
* `USER_FILE1`, `USER_FILE2`

Use `USER_DOCUMENT_NAME1`, `USER_DOCUMENT_NAME2`, and so on with the matching `USER_DOCUMENT_URL` index.

{% hint style="info" %}

* When indexed multimodal parameters are used, the non-indexed versions of `USER_AUDIO`, `USER_DOCUMENT_URL`, `USER_FILE_ID`, and `USER_FILE` are ignored.
* If `USER_MESSAGE1` is not provided, the non-indexed `USER_MESSAGE` can still be included as the first text block.
* If the selected provider does not support one of these content types, OPENAICHAT skips that content and writes an informational log entry (if application logging is enabled).
  {% endhint %}

## **Provider-specific considerations**

### **Parameter availability by provider**

<table data-full-width="false"><thead><tr><th width="287.1766357421875">Parameter</th><th width="114.906005859375" align="center">OpenAI</th><th width="115.92022705078125" align="center">Mistral</th><th width="115.0997314453125" align="center">Gemini</th><th width="116.30633544921875" align="center">Anthropic</th></tr></thead><tbody><tr><td><code>MODEL</code></td><td align="center">Yes</td><td align="center">Yes</td><td align="center">Yes</td><td align="center">Yes</td></tr><tr><td><code>SYSTEM_MESSAGE</code></td><td align="center">Yes</td><td align="center">Yes</td><td align="center">Yes</td><td align="center">Yes</td></tr><tr><td><code>USER_MESSAGE</code></td><td align="center">Yes</td><td align="center">Yes</td><td align="center">Yes</td><td align="center">Yes</td></tr><tr><td><code>TEMPERATURE</code></td><td align="center"><code>0</code>-<code>2</code></td><td align="center"><code>0</code>-<code>2</code></td><td align="center"><code>0</code>-<code>1</code></td><td align="center"><code>0</code>-<code>1</code></td></tr><tr><td><code>TOP_P</code></td><td align="center">Yes</td><td align="center">Yes</td><td align="center">Yes</td><td align="center">No</td></tr><tr><td><code>MAX_TOKENS</code></td><td align="center">Yes</td><td align="center">Yes</td><td align="center">Yes</td><td align="center">Required</td></tr><tr><td><code>TOOLS</code></td><td align="center">Yes</td><td align="center">Yes</td><td align="center">Yes</td><td align="center">Yes</td></tr><tr><td><code>RESPONSE_FORMAT</code></td><td align="center">Yes</td><td align="center">Yes</td><td align="center">Yes</td><td align="center">Yes</td></tr><tr><td><code>DEVELOPER_MESSAGE</code></td><td align="center">o1+ only</td><td align="center">No</td><td align="center">No</td><td align="center">No</td></tr><tr><td><code>MAX_COMPLETION_TOKENS</code></td><td align="center">o1+ only</td><td align="center">No</td><td align="center">No</td><td align="center">No</td></tr><tr><td><code>REASONING_EFFORT</code></td><td align="center">o1/o3</td><td align="center">No</td><td align="center">Mapped</td><td align="center">Mapped</td></tr><tr><td><code>FREQUENCY_PENALTY</code></td><td align="center">Yes</td><td align="center">Yes</td><td align="center">No</td><td align="center">No</td></tr><tr><td><code>PRESENCE_PENALTY</code></td><td align="center">Yes</td><td align="center">Yes</td><td align="center">No</td><td align="center">No</td></tr><tr><td><code>PARALLEL_TOOL</code></td><td align="center">Yes</td><td align="center">Yes</td><td align="center">Yes</td><td align="center">Yes</td></tr></tbody></table>

{% hint style="info" %}

* Parameters not supported by a provider are silently ignored.
* `TEMPERATURE` values above `1.0` are capped at `1.0` for Gemini and Anthropic (Mistral supports `0`-`2`).
* `REASONING_EFFORT` is mapped to provider-specific thinking/reasoning configurations.
* `MAX_TOKENS` is required for Anthropic (not optional).
* When `REASONING_EFFORT` is used with Anthropic, `TEMPERATURE` and `TOP_P` are ignored (API requirement).
  {% endhint %}

{% hint style="warning" %}
`TOP_P` is not sent for Anthropic because Claude 4.5 models don't allow both `temperature` and `top_p` together.
{% endhint %}

## OpenAI reasoning models

OpenAI offers reasoning models (o1, o3, GPT-5 series) that use internal reasoning before generating a response. These models have specific parameter requirements:

### Parameters

<table><thead><tr><th width="289.66668701171875" valign="top">Parameter</th><th>Description</th></tr></thead><tbody><tr><td valign="top"><code>MAX_COMPLETION_TOKENS</code><br><strong>(required for reasoning models)</strong></td><td>Specifies the maximum tokens for the completion, including both reasoning tokens and visible output tokens</td></tr><tr><td valign="top"><code>REASONING_EFFORT</code><br><strong>(optional)</strong></td><td>Controls the depth of reasoning: <code>low</code>, <code>medium</code>, or <code>high</code><br><br>Higher values use more reasoning tokens but may produce better results.</td></tr></tbody></table>

{% hint style="warning" %}

* **Use `MAX_COMPLETION_TOKENS` instead of `MAX_TOKENS`** for reasoning models. The `MAX_TOKENS` parameter is deprecated for these models.
* **Do not use `REASONING_EFFORT` with non-reasoning models** (e.g., GPT-4o, GPT-4-turbo). These models don't support this parameter and the API will return an error.
* **When using `REASONING_EFFORT`, always set `MAX_COMPLETION_TOKENS`**. If `REASONING_EFFORT` is specified without `MAX_COMPLETION_TOKENS`, no token limit is sent to the API (the API will use its default limits). This is intentional because reasoning models reject the `MAX_TOKENS` parameter.
* **Reasoning tokens are not visible** in the response content but are included in the token usage count and billing.
  {% endhint %}

### Output parameters

<table><thead><tr><th width="290.37896728515625" valign="top">Parameter</th><th>Description</th></tr></thead><tbody><tr><td valign="top"><code>RESULT_REASONING_TOKENS</code></td><td><p>Number of tokens used for internal reasoning</p><p></p><p>Only populated for reasoning models; returns <code>0</code> for other models.</p></td></tr><tr><td valign="top"><code>RESULT_CACHED_TOKENS</code></td><td>Number of prompt tokens served from cache (applies to all models with prompt caching)</td></tr></tbody></table>

### Example of reasoning model use

```
MODEL = gpt-5-mini
USER_MESSAGE = "Solve this math problem: If a train travels 120 km in 2 hours, what is its average speed?"
MAX_COMPLETION_TOKENS = 500
REASONING_EFFORT = medium
```

#### Output

```
RESULT_CONTENT = "Average speed = distance ÷ time = 120 km ÷ 2 h = 60 km/h."
RESULT_TOTAL_TOKENS = 124
RESULT_COMPLETION_TOKENS = 95
RESULT_PROMPT_TOKENS = 29
RESULT_REASONING_TOKENS = 64
RESULT_CACHED_TOKENS = 0
```

## JSON schema use case

Using a JSON schema as a response format enforces the application to respond in a structured manner that aligns with the schema.&#x20;

You can directly extract the returned values to populate specific data; simply specify the name of the property to extract as the parameter name and set the target data in OUT.

### Examples

### `TOOLS`

<pre class="language-json"><code class="lang-json"><strong>[
</strong>    {
        "name": "GET_STOCK_INFORMATION",
        "description": "Get stock information about a product. If the product is not found, return an error. If the stock is less than 10, return a warning and a purchase order should be done.",      
        "parameters": {
            "type": "object",
            "properties": {
                "product_name": {
                    "type": "string",
                    "description": "The product name"
                },
                "serial_number": {
                    "type": "string",
                    "description": "The product serial number"
                }
            },
            "additionalProperties": false,
            "required": ["serial_number"]
        }
    },
    {
        "name": "PURCHASE_ORDER",
        "description": "Make a purchase order for a product.",    
        "parameters": {
            "type": "object",
            "properties": {
                "product_name": {
                    "type": "string",
                    "description": "The product name"
                },
                "serial_number": {
                    "type": "string",
                    "description": "The product serial number"
                },
                "quantity": {
                    "type": "number",
                    "description": "The quantity of the product to purchase"
                }
            },
            "additionalProperties": false,
            "required": ["serial_number", "quantity"]
        }
    }
]
</code></pre>

### `SELECTED_TOOLS_PARAMS`

```json
[
    {
        "name": "GET_STOCK_INFORMATION",
        "id": "call_Vuc2Ga8jP7vUksxG9C0fwpY8",
        "parameters": {
            "product_name": "vis",
            "serial_number": "V45645"
        }
        
    },
    {
        "name": "GET_STOCK_INFORMATION",
        "id": "call_nq3SCVUk0FjAHCeqOZGNXpC8",
        "parameters": {
            "product_name": "boulons",
            "serial_number": "b456"
        }
    }
]
```

### `RESPONSE_FORMAT_JSON_SCHEMA`

```json
{
  "name": "schema",
  "schema": {
    "$schema": "http://json-schema.org/draft-04/schema#",
    "type": "object",
    "properties": {
      "advice": {
        "type": "string"
      },
      "next_action": {
        "type": "string",
        "enum": ["expert","sales","support","logistics",null]
      },
      "confidence_level": {
        "type": "number"
      }
    },
    "required": ["advice", "next_action","confidence_level"]
  }
}
```

## Resolution priority (strict, no cross-provider fallback)

The application resolves provider, URL, and API key in the following order:

#### Provider resolution

1. `PROVIDER` parameter (if set and valid)
2. Auto-detect from `URL` parameter (if set)
3. Default: OpenAI

{% hint style="info" %}
Provider detection only uses the `URL` parameter, not configuration values.
{% endhint %}

#### **URL resolution (based on resolved provider)**

1. `URL` parameter (if set)
2. Provider-specific configuration URL:
   * OpenAI → `OpenAIChatApiUrl`
   * Mistral → `MistralChatApiUrl`
   * Gemini → `GeminiChatApiUrl`
   * Anthropic → `AnthropicChatApiUrl`
3. Hardcoded default URL for provider

{% hint style="info" %}
No cross-provider fallback. Each provider uses only its own configuration URL.
{% endhint %}

#### **API key resolution (based on resolved provider)**

1. `API_KEY` parameter (if set)
2. Provider-specific configuration key:
   * OpenAI → `OpenAIApiKey`
   * Mistral → `MistralApiKey`
   * Gemini → `GeminiApiKey`
   * Anthropic → `AnthropicApiKey`

{% hint style="info" %}
No cross-provider fallback. Each provider uses only its own configuration key.
{% endhint %}

### **Common scenarios**

<table><thead><tr><th valign="top">Scenario</th><th valign="top">Provider</th><th valign="top">URL</th><th valign="top">API key</th></tr></thead><tbody><tr><td valign="top">All defaults (nothing set)</td><td valign="top">OpenAI</td><td valign="top"><code>OpenAIChatApiUrl</code> or default</td><td valign="top"><code>OpenAIApiKey</code></td></tr><tr><td valign="top"><code>PROVIDER=anthropic</code></td><td valign="top">Anthropic</td><td valign="top"><code>AnthropicChatApiUrl</code> or default</td><td valign="top"><code>AnthropicApiKey</code></td></tr><tr><td valign="top"><code>PROVIDER=mistral</code></td><td valign="top">Mistral</td><td valign="top"><code>MistralChatApiUrl</code> or default</td><td valign="top"><code>MistralApiKey</code></td></tr><tr><td valign="top"><code>PROVIDER=gemini</code></td><td valign="top">Gemini</td><td valign="top"><code>GeminiChatApiUrl</code> or default</td><td valign="top"><code>GeminiApiKey</code></td></tr><tr><td valign="top"><code>URL=https://api.mistral.ai/...</code></td><td valign="top">Mistral (auto)</td><td valign="top"><code>URL</code> parameter</td><td valign="top"><code>MistralApiKey</code></td></tr><tr><td valign="top"><code>URL=https://api.anthropic.com/...</code></td><td valign="top">Anthropic (auto)</td><td valign="top"><code>URL</code> parameter</td><td valign="top"><code>AnthropicApiKey</code></td></tr></tbody></table>

### **How to use each provider**

<table><thead><tr><th valign="top">Provider</th><th valign="top">Required configuration</th></tr></thead><tbody><tr><td valign="top">OpenAI</td><td valign="top">Nothing (default) or set <code>OpenAIApiKey</code> in configuration</td></tr><tr><td valign="top">Mistral</td><td valign="top">Set <code>PROVIDER=mistral</code> OR <code>URL</code> param, AND <code>MistralApiKey</code> in configuration or <code>API_KEY</code> parameter</td></tr><tr><td valign="top">Gemini</td><td valign="top">Set <code>PROVIDER=gemini</code> OR <code>URL</code> param, AND <code>GeminiApiKey</code> in configuration or <code>API_KEY</code> parameter</td></tr><tr><td valign="top">Anthropic</td><td valign="top">Set <code>PROVIDER=anthropic</code> OR <code>URL</code> parameter, AND <code>AnthropicApiKey</code> in configuration or <code>API_KEY</code> parameter</td></tr></tbody></table>

## Common examples

These examples work across all four providers, using parameters fully compatible with all of them.

### Basic chat

```
MODEL = gpt-4o / mistral-large-latest / gemini-2.0-flash / claude-sonnet-4-5-20250929
SYSTEM_MESSAGE = "You are a helpful assistant."
USER_MESSAGE = "Explain quantum computing in simple terms."
MAX_TOKENS = 500
TEMPERATURE = 0.7
```

### Multi-turn conversation with `MESSAGE_HISTORY`

```
MODEL = [any provider model]
MESSAGE_HISTORY = [previous conversation JSON]
USER_MESSAGE = "Continue from where we left off."
MAX_TOKENS = 500
```

### Tool/function calling

```
MODEL = [any provider model]
USER_MESSAGE = "What's the weather in Paris?"
TOOLS = [{"name": "get_weather", "description": "Get weather info", "parameters": {...}}]
MAX_TOKENS = 500
```

## Provider-specific examples

### OpenAI-specific examples

#### Reasoning models (o1/o3/GPT-5 series)

```
MODEL = o3-mini
USER_MESSAGE = "Solve this complex math problem..."
MAX_COMPLETION_TOKENS = 2000
REASONING_EFFORT = high
```

Output includes: `RESULT_REASONING_TOKENS`&#x20;

#### Developer message (o1+ models)

```
MODEL = o1
DEVELOPER_MESSAGE = "You are a code reviewer. Be strict."
USER_MESSAGE = "Review this code..."
MAX_COMPLETION_TOKENS = 1000
```

### Mistral AI-specific examples

#### Using Mistral endpoint

```
URL = https://api.mistral.ai/v1/chat/completions
MODEL = mistral-large-latest
USER_MESSAGE = "Translate to French: Hello world"
MAX_TOKENS = 200
```

#### With explicit provider

```
PROVIDER = mistral
MODEL = mistral-large-latest
USER_MESSAGE = "Translate to French: Hello world"
MAX_TOKENS = 200
```

{% hint style="info" %}
`FREQUENCY_PENALTY` and `PRESENCE_PENALTY` are supported.
{% endhint %}

### Google Gemini-specific examples

{% hint style="warning" %}
Gemini's OpenAI-compatible endpoint does NOT support `FREQUENCY_PENALTY` and `PRESENCE_PENALTY`. These parameters are ignored.
{% endhint %}

#### Using Gemini OpenAI-compatible endpoint

```
URL = https://generativelanguage.googleapis.com/v1beta/openai/chat/completions
MODEL = gemini-2.0-flash
USER_MESSAGE = "Analyze this image"
USER_IMAGE_URL = https://example.com/image.jpg
MAX_TOKENS = 500
```

#### With explicit provider

```
PROVIDER = gemini
MODEL = gemini-2.0-flash
USER_MESSAGE = "Explain this concept"
MAX_TOKENS = 500
```

{% hint style="info" %}
`FREQUENCY_PENALTY` and `PRESENCE_PENALTY` are supported.
{% endhint %}

### Anthropic Claude-specific examples

#### **Basic Claude usage**

```
PROVIDER = anthropic
MODEL = claude-sonnet-4-5-20250929
SYSTEM_MESSAGE = "You are a helpful assistant."
USER_MESSAGE = "Explain machine learning."
MAX_TOKENS = 1000
```

#### **Extended thinking (Claude)**

```
PROVIDER = anthropic
MODEL = claude-sonnet-4-5-20250929
USER_MESSAGE = "Solve this complex reasoning problem..."
MAX_TOKENS = 2000
REASONING_EFFORT = high
```

Maps to Claude's `thinking.budget_tokens` parameter:

* `low` → 1,024 tokens
* `medium` → 8,192 tokens
* `high` → 24,576 tokens

#### **Claude with Vision**

```
PROVIDER = anthropic
MODEL = claude-sonnet-4-5-20250929
USER_MESSAGE = "Describe this image"
USER_IMAGE = [attached image file]
MAX_TOKENS = 500
```


---

# 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://docs.workflowgen.com/admin/workflow-applications/openai/openaichat.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.
