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
An array of messages used for generating completions.
max_tokens
integerOptional
The maximum number of tokens in the generated completion.
temperature
doubleOptional
The temperature parameter for controlling randomness in completions.
top_p
doubleOptional
The diversity of the generated text.
output
objectOptional
Options to affect the output of the response.
input
objectOptional
Options to affect the input of the request.

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
The set of result choices.

Errors

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": "Neural-Chat-7B",
6 "messages": [
7 {
8 "role": "user",
9 "content": "How do you feel about the world in general?"
10 }
11 ],
12 "max_tokens": 1000,
13 "temperature": 1.1,
14 "top_p": 0.1
15}'
1{
2 "id": "chat-IMT9tc2a3mqN5BabtfdjeFH1t1GAn",
3 "object": "chat_completion",
4 "created": 1717602741,
5 "model": "Neural-Chat-7B",
6 "choices": [
7 {
8 "index": 0,
9 "status": "success",
10 "message": {
11 "role": "assistant",
12 "content": "I feel that the world in general is a complex and ever-evolving place. It has its fair share of beauty, challenges, and opportunities. There are moments of joy, connection, and growth, as well as pain, conflict, and loss. The world is a reflection of the people who inhabit it, and it's essential to maintain a balance between appreciating its wonders and working towards making it a better place for all. It's a constant journey of learning, adapting, and striving for a more harmonious existence.",
13 "output": "null"
14 }
15 }
16 ]
17}