LLM API | Basic Completions
POST
/v1/chat/completionsPiAPI also provides different LLM API at cost effective pricing, sometimes at 25%~75% of their official pricing.
model name | pricing | Notes |
---|---|---|
uncensored-small-32k-20240717 | input 1M tokens = $0.125 output 1M tokens = $0.5 |
Deployed our own NSFW LLM model |
gpt-4o-mini | input 1M tokens = $0.1125 output 1M tokens = $0.45 |
75% of OpenAI's official pricing |
gpt-4o | input 1M tokens = $1.875 output 1M tokens = $7.5 Only for Creator Plan or Above |
75% of OpenAI's official pricing, as the original OpenAI's API model gpt-4o. |
o1-mini | input 1M tokens = $2.25 output 1M tokens = $9 Only for Creator Plan or Above |
75% of OpenAI's official pricing |
o1-preview | input 1M tokens = $11.25 output 1M tokens = $45 Only for Creator Plan or Above |
75% of OpenAI's official pricing |
claude-3-opus-20240229 | input 1M tokens = $11.25 output 1M tokens = $56.25 Only for Creator Plan or Above |
75% of Anthropic's official pricing |
claude-3-5-sonnet-20240620 | input 1M tokens = $2.25 output 1M tokens = $11.25 Only for Creator Plan or Above |
75% of Anthropic's official pricing |
gpt-4-gizmo-*(gpts) | input 1M tokens = $2.5 output 1M tokens = $10 each completion call of this model has a $0.005 minimum charge* Only for Creator Plan or Above |
equal to OpenAI gpt-4o price |
Note:
- OpenAI's input and output tokens, where 1k token roughly equals to 750 words. Thus 1 token roughly equates to 0.75 word.
- 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
Your API KEY for authorization
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.
A list of messages comprising the conversation so far
A list of functions the model may generate JSON inputs for.
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.
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.
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.
Defaults to 1.
How many chat completion choices to generate for each input message.
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
Defaults to null.
Up to 4 sequences where the API will stop generating further tokens.
Defaults to the maximum number of tokens to generate in the chat completion.
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.
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.
Defaults to null. Modify the likelihood of specified tokens appearing in the completion.
//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
}'
Request samples
Responses
{
"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
}
}