Using Discord Chat Completion
Request
URL: https://ai.purlabs.xyz/discord/chat/completions
Request Method: POST
TS Interface
interface Request {
model: string;
messages: {
role: 'system' | 'user' | 'assistant' | 'function';
content: string;
name?: string;
function_call?: object;
}[];
temperature?: number;
top_p?: number;
n?: number;
stream?: boolean;
stop?: string | any[] | null;
max_tokens?: number;
presence_penalty?: number;
frequency_penalty?: number;
logit_bias?: object | null;
user?: string;
};Request API Reference
⚠️
Refer to OpenAI's docs (opens in a new tab) to learn more about some paramaters!
| Parameter | Type (check TS Interface) | Description |
|---|---|---|
model | string | The model you would like to use. Refer to the Getting Available Models page for more information. |
messages | array (of objects) | An array of messages in the conversation. See the example request body for the message structure. |
messages.role | 'system' | 'user' | ... | The role of the message sender. |
messages.content | string | The content of the message. |
messages.name | string | (Optional) The name associated with the message sender. |
messages.function_call | object | (Optional) Details of a function call in the message. |
Example JSON Request Body
{
"messages": [
{
"role": "user",
"content": "How should I eat cereal: milk first, or after???"
}
]
}Response
TS Response Interface
interface Response {
id: string;
object: 'chat.completion';
created: number;
model: string;
choices: {
index: number;
message: {
role: 'assistant';
content: string;
};
finish_reason: any;
}[];
usage: {
prompt_tokens: number;
completion_tokens: number;
total_tokens: number;
};
overwritten: boolean;
provider: string;
cache?: {
status: 500,
error: {
message: 'Some of our providers returned with errors. Errors are automatically reported to our developers.';
records: {
provider: string;
response: {
status: number;
data?: any;
};
}[];
};
};
calledFunctions: [
{
name: string;
arguments: string;
},
{
role: 'function';
name: string;
content: string;
}
][];
} | {
status: 500,
message: string;
records: {
provider: string;
response: {
status: number;
data?: any;
};
}[];
};Example JSON Response
{
"id": "chatcmpl-QXlha2FBbmROaXhpZUFyZUF3ZXNvbWUK",
"object": "chat.completion",
"created": 0,
"model": "clyde",
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
},
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Definitely after! Pour the cereal first, then add the milk. Enjoy! 🥣"
},
"finish_reason": null
}
],
"provider": "Churchless",
"overwritten": false,
"cache": {
"status": 500,
"error": {
"message": "Some of our providers returned with errors. Errors are automatically reported to our developers.",
"records": [
{
"provider": "CattoGPT",
"response": {
"status": 404,
"data": "<!DOCTYPE html>\n<html lang=\"en\">\n <head>\n <title>Run this Repl to see the results here.</title>\n <link rel=\"stylesheet\"\n href=\"https://fonts.googleapis.com/css?family=IBM+Plex+Sans\">\n <style>\n body {\n margin: 0;\n height: 100vh;\n display: flex;\n justify-content: center;\n align-items: center;\n background: #1c2333;\n font-family: \"IBM Plex Sans\", \"sans\";\n color: #f5f9fc;\n }\n\n .title-box {\n font-size: 12px;\n inline-size: max-content;\n }\n\n .err-box {\n padding: 1em;\n max-width: 30em;\n width: 100vw;\n }\n\n .message {\n display: flex;\n flex-direction: column;\n align-items: center;\n }\n\n @media (max-width: 500px) {\n .message {\n flex-direction: column;\n align-items: center;\n }\n }\n\n .eval-bot {\n margin: 2em;\n }\n\n .console {\n background-color: #0e1628;\n color: #fff;\n font-family: \"IBM Plex Sans\", \"sans\";\n padding: 1em;\n margin: 1em;\n }\n\n .footer {\n margin: 1em;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n\n .link-icon {\n margin-right: 20px;\n margin-top: 4px;\n }\n\n a {\n color: #c2c8cc;\n }\n </style>\n\n <script>\n var reload_timeout = setTimeout(function () {\n window.location.reload();\n }, 60000);\n </script>\n </head>\n\n <body>\n <div class=\"err-box\">\n <div class=\"message\">\n <div class=\"eval-bot\">\n <svg\n width=\"290\"\n height=\"147\"\n viewBox=\"0 0 290 147\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M286.619 23.7207C289.534 27.4209 290.848 32.8497 287.611 40.7404C278.97 61.797 266.814 96.0691 266.814 96.0691C266.814 96.0691 263.84 110.374 247.366 110.374H81.9192L69.2234 94.1967L269.605 4.86339L273.294 6.84472L286.619 23.7207Z\"\n fill=\"#006D21\"\n />\n <path\n d=\"M69.2235 94.1967H234.671C251.144 94.1967 254.119 79.8915 254.119 79.8915C254.119 79.8915 266.274 45.6144 274.939 24.5628C283.605 3.51112 259.815 0.00416558 259.815 0.00416558H90.7234C90.7234 0.00416558 78.9745 -0.669489 71.2757 15.1168C63.5769 30.903 55.0652 58.8398 55.0652 58.8398L69.2235 94.1967Z\"\n fill=\"#77EA94\"\n />\n <path\n d=\"M143.619 64.4024L163.245 20.5902L194.308 48.5716L143.619 64.4024Z\"\n fill=\"#006D21\"\n />\n <path\n d=\"M117.935 55.9471L130.541 50.9095L117.751 94.4543V110.285H91.824L117.935 55.9471Z\"\n fill=\"#1D2332\"\n />\n <path\n d=\"M130.105 13.9131L129.406 36.1585L90.5153 119.825L91.2093 97.5798L130.105 13.9131Z\"\n fill=\"#283DC9\"\n />\n <path\n d=\"M29.6288 88.4013L45.4974 75.1214L18.3954 61.8118L130.105 13.9131L91.2093 97.5798L67.4734 85.9197L26.3768 124.244L1.69403 111.786L29.6288 88.4013Z\"\n fill=\"#5162F6\"\n />\n <path\n d=\"M91.2093 97.5798L90.5153 119.825L66.7794 108.165L67.4734 85.9197L91.2093 97.5798Z\"\n fill=\"#162DA3\"\n />\n <path\n d=\"M67.4734 85.9197L66.7794 108.165L25.6828 146.489L26.3768 124.244L67.4734 85.9197Z\"\n fill=\"#283DC9\"\n />\n <path\n d=\"M26.3768 124.244L25.6828 146.489L1 134.031L1.69403 111.786L26.3768 124.244Z\"\n fill=\"#162DA3\"\n />\n <path\n d=\"M45.4974 75.1214L29.6288 88.4013L20.3486 83.1211L18.3954 61.8118L45.4974 75.1214Z\"\n fill=\"#162DA3\"\n />\n <path\n d=\"M130.105 13.9131L18.3954 61.8118L45.4974 75.1214L29.6288 88.4013L1.69403 111.786L26.3768 124.244L67.4734 85.9197L91.2093 97.5798L130.105 13.9131Z\"\n stroke=\"#1D2332\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n <path\n d=\"M130.105 13.9131L129.406 36.1585L90.5153 119.825L66.7794 108.165L25.6828 146.489L1 134.031L1.69403 111.786\"\n stroke=\"#1D2332\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n <path\n d=\"M18.3954 61.8118L20.3486 83.1211L29.6288 88.4013L29.6586 88.4211\"\n stroke=\"#1D2332\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n <path\n d=\"M66.7794 108.165L67.4734 85.9197\"\n stroke=\"#1D2332\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n <path\n d=\"M91.2093 97.5798L90.5153 119.825\"\n stroke=\"#1D2332\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n <path\n d=\"M26.3768 124.244L25.6828 146.489\"\n stroke=\"#1D2332\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n </div>\n <div class=\"title-box\">\n <h1>Run this Repl to see the results here.</h1>\n </div>\n </div>\n <div class=\"footer\">\n <div class=\"link-icon\">\n <svg\n width=\"16\"\n height=\"16\"\n viewBox=\"0 0 16 16\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n >\n <path\n d=\"M6.66668 8.66666C6.95298 9.04942 7.31825 9.36612 7.73771 9.59529C8.15717 9.82446 8.62102 9.96074 9.09778 9.99489C9.57454 10.029 10.0531 9.96024 10.5009 9.79319C10.9487 9.62613 11.3554 9.36471 11.6933 9.02666L13.6933 7.02666C14.3005 6.39799 14.6365 5.55598 14.6289 4.68199C14.6213 3.808 14.2708 2.97196 13.6527 2.35394C13.0347 1.73591 12.1987 1.38535 11.3247 1.37775C10.4507 1.37016 9.60869 1.70614 8.98001 2.31333L7.83334 3.45333M9.33334 7.33333C9.04704 6.95058 8.68177 6.63388 8.26231 6.4047C7.84285 6.17553 7.37901 6.03925 6.90224 6.00511C6.42548 5.97096 5.94695 6.03975 5.49911 6.20681C5.05128 6.37387 4.6446 6.63528 4.30668 6.97333L2.30668 8.97333C1.69948 9.602 1.3635 10.444 1.3711 11.318C1.37869 12.192 1.72926 13.028 2.34728 13.6461C2.96531 14.2641 3.80135 14.6147 4.67534 14.6222C5.54933 14.6298 6.39134 14.2939 7.02001 13.6867L8.16001 12.5467\"\n stroke=\"#C2C8CC\"\n stroke-linecap=\"round\"\n stroke-linejoin=\"round\"\n />\n </svg>\n </div>\n <div class=\"repl-links\">\n <a href=\"https://replit.com\">Go to Replit</a>\n </div>\n <div></div>\n </div>\n </div>\n </body>\n</html>\n"
}
},
{
"provider": "FoxGPT",
"response": {
"status": 403,
"data": "<!doctype html>\n<html lang=en>\n<title>403 Forbidden</title>\n<h1>Forbidden</h1>\n<p>You don't have the permission to access the requested resource. It is either read-protected or not readable by the server.</p>\n"
}
},
{
"provider": "Pawan",
"response": {
"status": 504,
"data": "timeout of 60000ms exceeded"
}
}
]
}
}
}