Given the steep discount, we sometimes face availability issues thus we always recommend developers to always have another back up API source ready - take advantage of our low pricing when you can, and when availability becomes a problem switch to a higher cost solution to maintain overall system up-time.
OpenAI's input and output tokens, where 1k token roughly equals to 750 words. Thus 1 token roughly equates to 0.75 word.
2.
The definition of minimum charge: if the actual token (input+output) usage for that particular completion is less than that value, we will round it that value.
Request
Header Params
Authorization
string
required
Your API KEY for authorization
Body Params application/json
model
string
required
The name of the model to be used
How to get Gizmo model name: Go to ChatGPT official website, explore the GPTs and enter chat with the GPT of your choice, you will see webpage address like https://chatgpt.com/g/g-gFt1ghYJl-logo-creator. Then the model name you should use is gpt-4-gizmo-g-gFt1ghYJl.
messages
array[string]
required
A list of messages comprising the conversation so far
functions
array[string]
optional
A list of functions the model may generate JSON inputs for.
function_call
string
optional
Controls how the model calls functions.
"none" means the model will not call a function and instead generates a message.
"auto" means the model can pick between generating a message or calling a function.
Specifying a particular function via {name:my_function} forces the model to call that function.
"none" is the default when no functions are present.
"auto" is the default if functions are present.
temperature
number
optional
Defaults to 1. 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.
top_p
number
optional
Defaults to 1.
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.
n
integer
optional
Defaults to 1.
How many chat completion choices to generate for each input message.
stream
boolean
optional
Defaults to false.
If set, partial message deltas will be sent, like in ChatGPT.
Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data:[none] message
stop
string|array
optional
Defaults to null.
Up to 4 sequences where the API will stop generating further tokens.
max_tokens
number
optional
Defaults to the maximum number of tokens to generate in the chat completion.
presence_penalty
number
optional
Defaults to 0.
Number between -2.0 and 2.0.
Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.
frequency_penalty
number
optional
Defaults to 0.
Number between -2.0 and 2.0.
Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.
logit_bias
string
optional
Defaults to null. Modify the likelihood of specified tokens appearing in the completion.
Example
//Request Example - No Streaming
curl https://api.piapi.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer API_KEY" \
-d '{"model":"gpt-3.5-turbo","messages":[{"role":"system","content":"You are a helpful assistant."},{"role":"user","content":"Hello!"}]}'
//Request Example - Streaming
curl https://api.piapi.ai/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer API_KEY" \
-d '{"model":"gpt-3.5-turbo","messages":[{"role":"system","content":"You are a helpful assistant."},{"role":"user","content":"Hello!"}],"stream":true}'
{"id":"chatcmpl-83jZ61GDHtdlsFUzXDbpGeoU193Mj","object":"chat.completion","created":1695900828,"model":"gpt-3.5-turbo","choices":[{"index":0,"message":{"role":"assistant","content":"Hello! How can I assist you today?"},"finish_reason":"stop"}],"usage":{"prompt_tokens":19,"completion_tokens":9,"total_tokens":28}}