Modellss Docs
  1. Chat Completions API
  • Send Request
  • Model List and Price
  • Model APIs
    • Chat API
      • Chat
      • GPTs
      • gemini-pro
      • gpt-4-all(Image)
      • gpt-4-vision-preview
    • Chat Completions API
      • Chat Completions API
        POST
    • Image API
      • Midjourney
        • InsightFace task submission
          • Submit swap_face task
        • Task Submission
          • Perform Action
          • Submit Blend Task
          • Submit a Describe task
          • Submit a Imagine task
          • Submit Modal
          • Submit Shorten Task
        • Task Inquiry
          • Inquire about all tasks
          • Inquire about tasks based on a list of IDs
          • Paged query for tasks
          • Inquire about the task queue
          • Cancel task
          • Retrieve task with specified ID
          • Get the seed for the task image
      • DALL·E 3
      • Stable Diffusion
      • MJ Chat
      • gpt-4-all(generate images)
    • Embedding Vector Generation Interface (Embeddings)
      • Create Embeddings
    • Audio
      • Create transcription
      • Create translation
      • Text to speech
  • Help Center
    • FAQ
  1. Chat Completions API

Chat Completions API

POST
https://api.gptnb.me/v1/completions
Given a prompt, the model will return one or more predicted completions along with the probabilities of alternative tokens at each position. Most developer should use our Chat Completions API to leverage our best and newest models.

Request

Header Params
Authorization
string 
optional
Example:
Bearer {{YOUR_API_KEY}}
Body Params application/json
model
string 
required
ID of the model to use. See the model endpoint compatibility table for details on which models work with the Chat API.
prompt
string 
optional

The prompt(s) to generate completions for, encoded as a string, array of strings, array of tokens, or array of token arrays. Note that <|endoftext|> is the document separator that the model sees during training, so if a prompt is not specified the model will generate as if from the beginning of a new document.

max_tokens
integer 
optional
The maximum number of tokens that can be generated in the completion. The token count of your prompt plus max_tokens cannot exceed the model's context length. Example Python code for counting tokens.
temperature
integer 
optional
What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p but not both.
top_p
integer 
optional
An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both.
n
integer 
optional
How many completions to generate for each prompt. Note: Because this parameter generates many completions, it can quickly consume your token quota. Use carefully and ensure that you have reasonable settings for max_tokens and stop.
stream
boolean 
optional
Whether to stream back partial progress. If set, tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. Example Python code.
logprobs
null 
optional
Include the log probabilities on the logprobs most likely output tokens, as well the chosen tokens. For example, if logprobs is 5, the API will return a list of the 5 most likely tokens. The API will always return the logprob of the sampled token, so there may be up to logprobs+1 elements in the response. The maximum value for logprobs is 5.
stop
string 
optional
Up to 4 sequences where the API will stop generating further tokens. The returned text will not contain the stop sequence.
Example
{
  "model": "gpt-3.5-turbo-instruct",
  "prompt": "Say this is a test",
  "max_tokens": 7,
  "temperature": 0,
  "top_p": 1,
  "n": 1,
  "stream": false,
  "logprobs": null,
  "stop": "\n"
}

Request samples

Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.gptnb.me/v1/completions' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: application/json' \
--data-raw '{
  "model": "gpt-3.5-turbo-instruct",
  "prompt": "Say this is a test",
  "max_tokens": 7,
  "temperature": 0,
  "top_p": 1,
  "n": 1,
  "stream": false,
  "logprobs": null,
  "stop": "\n"
}'

Responses

🟢200Ok
application/json
Body
id
string 
required
object
string 
required
created
integer 
required
model
string 
required
choices
array [object {4}] 
required
text
string 
optional
index
integer 
optional
logprobs
null 
optional
finish_reason
string 
optional
usage
object 
required
prompt_tokens
integer 
required
completion_tokens
integer 
required
total_tokens
integer 
required
Example
{
    "id": "cmpl-uqkvlQyYK7bGYrRHQ0eXlWi7",
    "object": "text_completion",
    "created": 1589478378,
    "model": "text-davinci-003",
    "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
    }
}
Previous
gpt-4-vision-preview
Next
Submit swap_face task
Built with