Skip to contents

This function extracts the date-time string of when the response was created from the parsed HTTP response of an API call to the OpenAI chat completions endpoint.

Usage

created(response)

Arguments

response

a list object representing the HTTP response

Value

A POSIXct date-time in UTC, the time the response was created.

Author

Ulrich Matter umatter@protonmail.com

Examples

# A hand-built response, shaped like the list chat_completion() returns
response <- list(id = "chatcmpl-123", object = "chat.completion",
  created = 1700000000, model = "gpt-4o-mini",
  usage = list(prompt_tokens = 5, completion_tokens = 3, total_tokens = 8),
  choices = data.frame(index = 0))
response$choices$message <- data.frame(role = "assistant", content = "Hi!")
created(response)
#> [1] "2023-11-14 22:13:20 UTC"