Chat Completions Vision

POST
Generate chat completions based on a text and images.

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.

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 - Vision Version \
2 -H "x-api-key: <apiKey>" \
3 -H "Content-Type: application/json" \
4 -d '{
5 "model": "llava-1.5-7b-hf",
6 "messages": [
7 {
8 "role": "user",
9 "content": [
10 {
11 "type": "text",
12 "text": "input.question"
13 },
14 {
15 "type": "image_url",
16 "image_url": {
17 "url": "data:image/jpeg;base64,<DATA>"
18 }
19 }
20 ]
21 }
22 ],
23 "max_tokens": 1000,
24 "temperature": 0.1,
25 "top_p": 0.1
26}'
1{
2 "id": "chat-8qptYQ1EC1cPhHIKh7ArD5OxKN01N",
3 "object": "chat_completion",
4 "created": 1717681459,
5 "model": "llava-1.5-7b-hf",
6 "choices": [
7 {
8 "index": 0,
9 "status": "success",
10 "message": {
11 "role": "assistant",
12 "content": "No, there is no deer in this picture. The image features a man wearing a hat and glasses, smiling for the camera.",
13 "output": "null"
14 }
15 }
16 ]
17}