> For the complete documentation index, see [llms.txt](https://docs.frends.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.frends.com/tasks/tasks/openai/callchatgpt.md).

# CallChatGPT

Task version: 1.1.0

Required Frends version: 5.5+

Required .NET version: 6.0

Compatible Agents: Crossplatform

Source code: <https://github.com/FrendsPlatform/Frends.OpenAI/tree/main/Frends.OpenAI.CallChatGPT>

## Task Parameters

{% tabs %}
{% tab title="Input" %}

| Name                        | Description                                                                                                                                                                                                                                                                      |
| --------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Model : `String`            | <p>Chat GPT model to use.</p><p>Find a list of available models from <https://platform.openai.com/docs/models>.</p><p><br>Default: <code>gpt-3.5-turbo</code><br>Example: <code>gpt-3.5-turbo</code></p>                                                                         |
| 🗝ApiKey : `String`         | <p>Chat GPT API key.</p><p><br>Default: <code>-</code><br>Example: <code>1234567qwerty</code></p>                                                                                                                                                                                |
| Messages : `InputMessage[]` | <p>Array of messages to send to Chat GPT.</p><p><br>Default: <code>-</code><br>Example: <code>\[ { "Content": "How are you?", "Role": "User" }, { "Content": "I'm fine, thanks. How about you?", "Role": "System" }, { "Content": "I'm fine too.", "Role": "User" } ]</code></p> |
| {% endtab %}                |                                                                                                                                                                                                                                                                                  |

{% tab title="Options" %}

| Name                                      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| ----------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| MaxTokens : `Nullable<Int32>`             | <p>The maximum number of tokens that can be generated in the chat</p><p>completion. Set to 0 for unlimited tokens.</p><p>The total length of input tokens and generated tokens is still limited</p><p>by the model's context length.</p><p><br>Default: <code>-</code><br>Example: <code>100</code></p>                                                                                                                                                              |
| N : `Int32`                               | <p>How many chat completion choices to generate for each input message.</p><p>Note that you will be charged based on the number of generated tokens</p><p>across all of the choices. Keep n as 1 to minimize costs.</p><p><br>Default: <code>1</code><br>Example: <code>3</code></p>                                                                                                                                                                                 |
| Seed : `Nullable<Int32>`                  | <p>If specified, ChatGPT system will make a best effort to sample</p><p>deterministically, such that repeated requests with the same seed and</p><p>parameters should return the same result. Determinism is not guaranteed,</p><p>and you should refer to the system\_fingerprint response parameter to</p><p>monitor changes in the backend.</p><p>Set to null for non-deterministic results.</p><p><br>Default: <code>-</code><br>Example: <code>12345</code></p> |
| User : `String`                           | <p>A unique identifier representing your end-user, which can help OpenAI to</p><p>monitor and detect abuse.</p><p><br>Default: <code>-</code><br>Example: <code>User12345</code></p>                                                                                                                                                                                                                                                                                 |
| ThrowExceptionOnErrorResponse : `Boolean` | <p>Whether to throw an exception if the API returns an error. Otherwise</p><p>the error is returned as part of the result.</p><p><br>Default: <code>True</code><br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                    |
| {% endtab %}                              |                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| {% endtabs %}                             |                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |

## Task Result

| Name                              | Description                                                                                                                                                                                                                                                                                                                                                                                                            |
| --------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ChatCompletion : `ChatCompletion` | <p>Contains the input repeated the specified number of times.<br>Example: <code>{ Id: "chatcmpl-123", Created: 1677652288, Model: "gpt-3.5-turbo-0613", SystemFingerprint: "fp\_44709d6fcb", Choices: \[ { Index: 0, Message: { Role: "assistant", Content: "\n\nHello there, how may I assist you today?" }, FinishReason: "stop" } ], Usage: { PromptTokens: 9, CompletionTokens: 12, TotalTokens: 21 } }</code></p> |
| Success : `Boolean`               | <p>Indicates whether the operation was successful.<br>Example: <code>true</code></p>                                                                                                                                                                                                                                                                                                                                   |
| Error : `String`                  | <p>Error message, if the operation was not successful. Otherwise null.<br>Example: <code>OpenAI API call failed with status code 500 and content ...</code></p>                                                                                                                                                                                                                                                        |

## Task Changelog

Changelog for Task Frends.OpenAI.CallChatGPT.

### \[1.1.0] - 2025-02-17

#### Changed

* Update packages:
* RestSharp 110.2.0 -> 112.1.0
* SonarAnalyzer.CSharp 9.8.0.76515 -> 10.7.0.110445
* System.ComponentModel.Annotations 4.7.0 -> 5.0.0

### \[1.0.1] - 2024-01-05

#### Changed

* Moved some input parameters to options
* Moved API key from options to input

### \[1.0.0] - 2023-12-28

#### Changed

* Initial implementation


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.frends.com/tasks/tasks/openai/callchatgpt.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
