NAME

OpenAPI::Client::OpenAI::Path::completions - Documentation for the /completions path.

DESCRIPTION

This document describes the API endpoint at /completions.

PATHS

POST /completions

Creates a completion for the provided prompt and parameters.

Operation ID

createCompletion

$client->createCompletion( ... );

Parameters

Request Body

Content Type: application/json

Models

ID of the model to use. You can use the List models API to see all of your available models, or see our Model overview for descriptions of them.

  • gpt-3.5-turbo-instruct

  • davinci-002

  • babbage-002

Example:

{
   "max_tokens" : 16,
   "n" : 1,
   "stream_options" : null,
   "suffix" : "test.",
   "temperature" : 1,
   "top_p" : 1,
   "user" : "user-1234"
}


         

Responses

Status Code: 200

OK

Content Types:

  • application/json

    Example (See the OpenAI spec for more detail):

    {
      "id": "cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7",
      "object": "text_completion",
      "created": 1589478378,
      "model": "gpt-4-turbo",
      "choices": [
        {
          "text": "\n\nThis is indeed a test",
          "index": 0,
          "logprobs": null,
          "finish_reason": "length"
        }
      ],
      "usage": {
        "prompt_tokens": 5,
        "completion_tokens": 7,
        "total_tokens": 12
      }
    }

SEE ALSO

OpenAPI::Client::OpenAI::Path

COPYRIGHT AND LICENSE

Copyright (C) 2023-2025 by Nelson Ferraz

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.14.0 or, at your option, any later version of Perl 5 you may have available.