POST
/
v1
/
chat
/
completions
curl --request POST \
  --url https://nano-gpt.com/api/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "chatgpt-4o-latest",
  "messages": [
    {
      "role": "user",
      "content": "Testing, please reply!"
    }
  ],
  "stream": false,
  "temperature": 0.7,
  "max_tokens": 4000,
  "top_p": 1,
  "frequency_penalty": 0,
  "presence_penalty": 0
}'
{
  "id": "<string>",
  "object": "<string>",
  "created": 123,
  "choices": [
    {
      "index": 123,
      "message": {
        "role": "assistant",
        "content": "<string>"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123
  }
}

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
Parameters for chat completion
model
string
default:chatgpt-4o-latest
required

The model to use for completion

messages
object[]
required

Array of message objects with role and content

stream
boolean
default:false

Whether to stream the response

temperature
number
default:0.7

Controls randomness (0-2)

max_tokens
integer
default:4000

Maximum number of tokens to generate

top_p
number
default:1

Nucleus sampling parameter (0-1)

frequency_penalty
number
default:0

Penalty for frequency of tokens (-2 to 2)

presence_penalty
number
default:0

Penalty for presence of tokens (-2 to 2)

Response

200
application/json
Chat completion response
id
string

Unique identifier for the completion

object
string

Object type, always 'chat.completion'

created
integer

Unix timestamp of when the completion was created

choices
object[]

Array of completion choices

usage
object