Generate Chat Completions

POST
Generate chat completions based on a conversation history.

Request

This endpoint expects an object.
model
stringRequired
The chat model to use for generating completions.
messages
list of objectsRequired
The conversation history with roles (user, assistant) and messages.
max_tokens
integerRequired
The maximum number of tokens in the generated completion.
temperature
doubleRequired
The temperature parameter for controlling randomness in completions.

Response

This endpoint returns an object
id
stringOptional
Unique ID for the chat completion.
object
stringOptional
Type of object (chat completion).
created
integerOptional
Timestamp of when the chat completion was created.
model
stringOptional
The chat model used for generating completions.
choices
list of objectsOptional
POST
1curl -X POST https://api.predictionguard.com/chat/completions \
2 -H "x-api-key: <apiKey>" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "model": "model",
6 "messages": [
7 {
8 "role": "role",
9 "content": "content"
10 }
11 ],
12 "max_tokens": 1,
13 "temperature": 1.1
14}'
200
Successful
1{
2 "id": "chat-d7aBqSetFRtmXHaaHwlXXlKF39Lfx",
3 "object": "chat_completion",
4 "created": 1706909024,
5 "model": "Neural-Chat-7B",
6 "choices": [
7 {
8 "message": {
9 "role": "assistant",
10 "content": "Thanks for appreciating my attempt at humor. Now, if you meant to ask about my current emotional state or the general situation, I'm doing alright and things seem to be going on as usual. How about you?\n\n(Note: I'm always open to making people laugh, but I also try to be helpful and empathetic when needed.)"
11 },
12 "index": 0
13 }
14 ]
15}