powered by
Request answer from openai's chat API
chat_api( prompt, model = NULL, config = NULL, max_tokens = NULL, api_key = NULL, ... )
A tibble with available models
a httr2 response object
character string of the prompt to be completed.
character string of the model to be used (defaults to "text-davinci-003").
a configuration prompt to tell the model how it should behave.
The maximum number of tokens to generate in the completion. 2048L is the maximum the models accept.
set the API key. If NULL, looks for the env OPENAI_API_KEY.
additional parameters to be passed to the API (see [the API documentation](https://platform.openai.com/docs/api-reference/completions)
if (FALSE) { chat_api("Hi, how are you?", config = "answer as a friendly chat bot") }
Run the code above in your browser using DataLab