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 |
messages | Array of objects Die Prompt(s) zur Generierung von Vervollständigungen, codiert als Liste von Dicts mit Rolle und Inhalt. Die erste Promptrolle sollte „user“ oder „system“ sein. |
temperature | number or null Welche Temperatur, zwischen 0,0 und 1,0, soll verwendet werden? Höhere Werte wie 0,8 machen die Ausgabe zufälliger, während niedrigere Werte wie 0,2 sie fokussierter und deterministischer machen. |
top_p | number or null Kernel-Sampling, bei dem das Modell die Ergebnisse der Token mit der Wahrscheinlichkeitsmasse top_p berücksichtigt. 0,1 bedeutet also, dass nur die Token berücksichtigt werden, die die obersten 10 % der Wahrscheinlichkeitsmasse ausmachen. |
max_tokens | integer or null Die maximale Anzahl von Tokens, welche zur Generierung verwendet werden sollen. Die Tokenanzahl Ihrer Eingabeaufforderung plus max_tokens darf die Kontextlänge des Modells nicht überschreiten. Wir empfehlen generell, entweder diesen Wert oder die Temperatur zu ändern, aber nicht beides. |
random_seed | integer or null Der für die Zufallsstichprobe zu verwendende Startwert. Wenn dieser Wert festgelegt ist, führen verschiedene Aufrufe zu deterministischen Ergebnissen. |
safe_prompt | boolean or null |
anonymize | boolean or null |
stream | boolean or null |
messages SCHEMA:
Key | Value |
role | string Gibt die Rolle des Verfassers der Nachrichten an. |
content | string Nachricht(en) der KI-Unterhaltung |
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
}'
Mögliche Rückmeldungen
200 - Erfolgreich
200 - Erfolgreich
{
"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' \
Mögliche Rückmeldungen
200 - Erfolgreich
200 - Erfolgreich
{
"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 |
