Create Chat Completions
https://api.peakprivacy.ch/v1/ai/completions
HEADERS
Key | Value |
Api-token | api_token from |
X-Requested-With | XMLHttpRequest |
Accept | application/json |
REQUEST BODY SCHEMA: application/json
Key | Value |
model | string ID of the model to use. Supported models : - |
messages | Array of objects The prompt(s) to generate completions for, encoded as a list of dict with role and content. The first prompt role should be user or system. |
temperature | number or null |
top_p | number or null |
max_tokens | integer or null |
random_seed | integer or null |
safe_prompt | boolean or null |
anonymize | boolean or null |
stream | boolean or null |
messages SCHEMA:
Key | Value |
role | string |
content | string |
BODY raw
{
"model": "gpt-4-1106-preview",
"messages": [
{
"role": "assistant",
"content": "content"
}
],
"temperature": null,
"top_p": null,
"max_tokens": null,
"random_seed": null,
"safe_prompt": null,
"anonymize": true
}
Example request
curl --location --request POST 'https://api.peakprivacy.ch/v1/ai/completions' \
--header 'Api-token: api_token' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data-raw '{
"model": "gpt-4-1106-preview",
"messages": [
{
"role": "user",
"content": "content"
}
],
"temperature": null,
"top_p": null,
"max_tokens": null,
"random_seed": null,
"safe_prompt": null,
"anonymize": true
}'
Possible Responses
200 - Success
200 - Success
{
"id": "1df8f5af-c96d-42ba-938a-3f5c4f62e633",
"object": "chat.completion",
"created": 1705942239,
"model": "gpt-3.5-turbo-1106",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "Hello! How can I assist you today?",
"role": "assistant"
}
}
],
"usage": {
"completion_tokens": 9,
"prompt_tokens": 8,
"total_tokens": 17
}
}RESPONSE SCHEMA: application/json
Key | Value |
id | string |
object | string |
created | integer |
model | string |
choices | Array of objects |
usage | object |
choices SCHEMA: application/json
Key | Value |
finish_reason | string |
index | string |
message | object |
message SCHEMA: application/json
Key | Value |
role | string |
content | string |
usage SCHEMA: application/json
Key | Value |
completion_tokens | integer |
prompt_tokens | integer |
total_tokens | integer |
400 - Bad Request; Validation Error
400 - Bad Request; Validation Error
{
"message": "Validation error",
"errors": {
"model": [
"The model field is required."
]
}
}401 - Unauthenticated; Form Token Expired
401 - Unauthenticated; Form Token Expired
{
"error": "Unauthenticated"
}403 - Forbidden; Subscription amount limit has been reached
403 - Forbidden; Subscription amount limit has been reached
{
"error": "Subscription amount limit has been reached"
}response SCHEMA: application/json
Key | Value |
error | string |
Get supported models list
https://api.peakprivacy.ch/v1/ai/models
HEADERS
Key | Value |
Api-token | api_token from |
X-Requested-With | XMLHttpRequest |
Accept | application/json |
Example request
curl --location --request GET 'https://api.peakprivacy.ch/v1/ai/models' \
--header 'Api-token: ' \
--header 'X-Requested-With: XMLHttpRequest' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
Response samples
200 - Success
200 - Success
{
"object": "list",
"data": [
{
"id": "gpt-4-1106-preview",
"object": "model",
"created": 0,
"owned_by": "OpenAI"
},
...
]
}RESPONSE SCHEMA: application/json
Key | Value |
object | string |
data | Array of objects |
data SCHEMA: application/json
Key | Value |
id | string |
object | string |
created | integer |
owned_by | object |
401 - Unauthenticated; Form Token Expired
401 - Unauthenticated; Form Token Expired
{
"error": "Unauthenticated"
}response SCHEMA: application/json
Key | Value |
error | string |
