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
$curl -X POST https://api.predictionguard.com/chat/completions \
> -H "x-api-key: <apiKey>" \
> -H "Content-Type: application/json" \
> -d '{
> "model": "model",
> "messages": [
> {
> "role": "role",
> "content": "content"
> }
> ],
> "max_tokens": 1,
> "temperature": 1.1
>}'
Response
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}