Chat Completion

POST

Given a list of messages comprising a conversation, return a response.

Optionally include an initial role: system message to influence the way the LLM answers.

If use_context is set to true, the model will use context coming from the ingested documents to create the response. The documents being used can be filtered using the context_filter and passing the document IDs to be used. Ingested documents IDs can be found using /ingest/list endpoint. If you want all ingested documents to be used, remove context_filter altogether.

When using 'include_sources': true, the API will return the source Chunks used to create the response, which come from the context provided.

When using 'stream': true, the API will return data chunks following OpenAI’s streaming model:

{"id":"12345","object":"completion.chunk","created":1694268190,
"model":"private-gpt","choices":[{"index":0,"delta":{"content":"Hello"},
"finish_reason":null}]}

Request

This endpoint expects an object.
messageslist of objectsRequired
streamtrueRequired
use_contextbooleanOptional
context_filterobjectOptional
include_sourcesbooleanOptional

Response

This endpoint returns a stream of object.
idstring
createdinteger
model"private-gpt"
choiceslist of objects
object"completion" or "completion.chunk"Optional
Allowed values: completioncompletion.chunk