MongoDB Knowledge Service API (1.0.0)
Download OpenAPI specification:Download
The Knowledge Service is a RESTful API.
The API is designed to be used by the MongoDB RAG UI frontend, but can also be used by other clients.
If you have a use case not currently supported by the API, please reach out to the MongoDB EAI team.
Search content
Authorizations:
Request Body schema: application/jsonrequired
query | string The search query string. |
Array of objects An array of data sources to search. If not provided, latest version of all data sources will be searched. | |
limit | integer [ 1 .. 100 ] Default: 5 The maximum number of results to return. |
Responses
Request samples
- Payload
{- "query": "string",
- "dataSources": [
- {
- "name": "string",
- "type": "string",
- "versionLabel": "string"
}
], - "limit": 5
}
Response samples
- 200
- 400
- 500
{- "results": [
- {
- "url": "string",
- "title": "string",
- "text": "string",
- "metadata": {
- "sourceName": "string",
- "sourceType": "string",
- "tags": [
- "string"
]
}
}
]
}
Start new conversation Deprecated
Start a new conversation.
This endpoint is deprecated. Use the createResponse endpoint instead.
Authorizations:
Responses
Response samples
- 200
- 400
- 500
{- "_id": "string",
- "messages": [
- {
- "id": "string",
- "conversationId": "string",
- "role": "user",
- "content": "string",
- "rating": true,
- "userComment": "string",
- "createdAt": 0,
}
], - "createdAt": 0
}
Add message to the conversation Deprecated
Add a message to the conversation and get a response back from chatbot.
This endpoint is deprecated. Use the createResponse endpoint instead.
You can configure your server to create new conversations
when you set the conversation ID to null
.
If you do this, the server creates a new conversation
and returns the conversation ID in the response's metadata.conversationId
field.
Authorizations:
path Parameters
conversationId required | string The unique identifier for a conversation. |
query Parameters
stream | boolean Default: false If |
Request Body schema: application/json
message required | string <markdown> Markdown-formatted message from the user. |
object Additional context provided by the client. This is useful for passing information to the chatbot that is not part of the user's message but may be relevant to the chatbot's response. For example, the client may pass information about the user's preferences, location, preferred language, etc. |
Responses
Request samples
- Payload
{- "message": "string",
- "clientContext": { }
}
Response samples
- 200
- 400
- 404
- 500
{- "id": "string",
- "conversationId": "string",
- "role": "user",
- "content": "string",
- "rating": true,
- "userComment": "string",
- "createdAt": 0,
}
Rate message Deprecated
Rate a message.
This endpoint is deprecated. Use the rateStandaloneMessage endpoint instead.
Authorizations:
path Parameters
conversationId required | string The unique identifier for a conversation. |
messageId required | string The unique identifier for a message. |
Request Body schema: application/json
rating | boolean Set to |
Responses
Request samples
- Payload
{- "rating": true
}
Response samples
- 400
- 404
- 500
{ }
Rate message
Authorizations:
path Parameters
messageId required | string The unique identifier for a message. |
Request Body schema: application/json
rating | boolean Set to |
Responses
Request samples
- Payload
{- "rating": true
}
Response samples
- 400
- 404
- 500
{ }
Add comment to assistant message Deprecated
Add a comment to an assistant message that clarifies a thumbs up/down rating.
You can only rate an an assistant message that has a thumbs up/down rating. You can only rate a message once. The server returns a 400
error response if the message is not from the assistant, is not rated, or has already been rated.
Authorizations:
path Parameters
conversationId required | string The unique identifier for a conversation. |
messageId required | string The unique identifier for a message. |
Request Body schema: application/json
comment | string Comment from the user clarifying why they liked or disliked the message. |
Responses
Request samples
- Payload
{- "comment": "string"
}
Response samples
- 400
- 404
- 500
{ }
Add comment to assistant message
Add a comment to an assistant message that clarifies a thumbs up/down rating.
You can only rate an an assistant message that has a thumbs up/down rating. You can only rate a message once. The server returns a 400
error response if the message is not from the assistant, is not rated, or has already been rated.
Authorizations:
path Parameters
messageId required | string The unique identifier for a message. |
Request Body schema: application/json
comment | string Comment from the user clarifying why they liked or disliked the message. |
Responses
Request samples
- Payload
{- "comment": "string"
}
Response samples
- 400
- 404
- 500
{ }
Create response
Create a response from an LLM. Follows the specification of the OpenAI Responses API.
You can rate or comment on a message using the rateMessage and commentMessage endpoints.
For more information on using the Responses API, refer to the Responses API documentation.
Authorizations:
Request Body schema: application/json
model required | string The model to use for generating the response |
instructions | string [ 1 .. 50000 ] characters System instructions for the model (1-50,000 characters, ~10,000 tokens) |
required | StringInput (string) or (Array of MessageArrayInput (MessageItem (object) or FunctionCallItem (object) or FunctionCallOutputItem (object))) |
max_output_tokens | integer >= 0 Default: 1000 Maximum number of tokens to generate |
object <= 16 properties Additional metadata with max 16 fields, each value max 512 chars. These are stored in the database. Note that the | |
previous_response_id | string The unique ID of the previous response to the model.
Including Note that conversations support a maximum of 50 Usage notes:
|
store | boolean Default: true Whether to store the response in the database. If store is
If store is
|
stream required | boolean Value: true Stream response. Must always be |
temperature | number Default: 0 Value: 0 Temperature for the model. Must be |
string or object Default: "auto" Tool choice for the model. Note that the OpenAI Responses API options | |
Array of objects <= 10 items Tools for the model to use. Limitations:
| |
user | string The ID of the user. Can be any arbitrary string. If used in combination with |
Responses
Request samples
- Payload
{- "model": "string",
- "instructions": "string",
- "input": "string",
- "max_output_tokens": 1000,
- "metadata": {
- "property1": "string",
- "property2": "string"
}, - "previous_response_id": "string",
- "store": true,
- "stream": true,
- "temperature": 0,
- "tool_choice": "auto",
- "tools": [
- {
- "type": "function",
- "strict": true,
- "name": "string",
- "description": "string",
- "parameters": { }
}
], - "user": "string"
}
Response samples
- 400
- 404
- 500
{ }