Completions
Create completions based on provided messages or prompt and sources.
Completions endpoint is used in scenarios where you need to generate text based on a given context, either provided through a conversation history (messages) or a specific starting prompt. The sources parameter helps to contextualize the completion by specifying the indexes to use.
The response should look something like this:
Body Parameters:
messages
array
An array of message objects. Each message object contains a role and content. This simulates a conversation history.
Yes (or prompt)
prompt
string
A string prompt to generate completions. This is used when there are no prior messages to base the completion on.
Yes (or messages)
sources
array
An array of strings representing index ID or DID to be used as a source for generating completions.
Yes
Note: Either messages or prompt must be provided, along with sources.
Example Request Body
Using Messages:
{
"messages": [{
"role": "user",
"content": "Tell me a joke."
}],
"sources": [
"kjzl6kcym7w8y8lefkkbpl44q6jh1zu78gaq2zp18we4wdgz1tz9vxyx213ochh"
]
}Completions created
Invalid request parameters
Unauthorized
Internal server error
POST /api/discovery/completions HTTP/1.1
Host: dev.index.network
Authorization: Bearer YOUR_SECRET_TOKEN
Content-Type: application/json
Accept: */*
Content-Length: 52
{
"messages": [
{}
],
"prompt": "text",
"sources": [
"text"
]
}{
"completion": "text"
}Last updated