Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

CallChatGPT

Task for calling ChatGPT API.

Task version: 1.1.0

Required Frends version: 5.5+

Required .NET version: 6.0

Compatible Agents: Crossplatform

Task Parameters

Name
Description

Model : String

Chat GPT model to use.

Find a list of available models from https://platform.openai.com/docs/models.

Default: gpt-3.5-turbo Example: gpt-3.5-turbo

🗝ApiKey : String

Chat GPT API key.

Default: - Example: 1234567qwerty

Messages : InputMessage[]

Array of messages to send to Chat GPT.

Default: - Example: [ { "Content": "How are you?", "Role": "User" }, { "Content": "I'm fine, thanks. How about you?", "Role": "System" }, { "Content": "I'm fine too.", "Role": "User" } ]

Name
Description

MaxTokens : Nullable<Int32>

The maximum number of tokens that can be generated in the chat

completion. Set to 0 for unlimited tokens.

The total length of input tokens and generated tokens is still limited

by the model's context length.

Default: - Example: 100

N : Int32

How many chat completion choices to generate for each input message.

Note that you will be charged based on the number of generated tokens

across all of the choices. Keep n as 1 to minimize costs.

Default: 1 Example: 3

Seed : Nullable<Int32>

If specified, ChatGPT system will make a best effort to sample

deterministically, such that repeated requests with the same seed and

parameters should return the same result. Determinism is not guaranteed,

and you should refer to the system_fingerprint response parameter to

monitor changes in the backend.

Set to null for non-deterministic results.

Default: - Example: 12345

User : String

A unique identifier representing your end-user, which can help OpenAI to

monitor and detect abuse.

Default: - Example: User12345

ThrowExceptionOnErrorResponse : Boolean

Whether to throw an exception if the API returns an error. Otherwise

the error is returned as part of the result.

Default: True Example: true

Task Result

Name
Description

ChatCompletion : ChatCompletion

Contains the input repeated the specified number of times. Example: { 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 } }

ChatCompletion.Id : String

A unique identifier for the chat completion.

ChatCompletion.Created : Int64

The Unix timestamp (in seconds) of when the chat completion was created.

ChatCompletion.Model : String

The model used for the chat completion.

ChatCompletion.SystemFingerprint : String

This fingerprint represents the backend configuration that the model runs with.

ChatCompletion.Choices : List<Choice>

A list of chat completion choices.

ChatCompletion.Usage : Usage

Usage statistics for the completion request.

ChatCompletion.Usage.PromptTokens : Int32

Number of tokens in the prompt.

ChatCompletion.Usage.CompletionTokens : Int32

Number of tokens in the generated completion.

ChatCompletion.Usage.TotalTokens : Int32

Total number of tokens used in the request (prompt + completion).

Success : Boolean

Indicates whether the operation was successful. Example: true

Error : String

Error message, if the operation was not successful. Otherwise null. Example: OpenAI API call failed with status code 500 and content ...

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

Last updated

Was this helpful?