docs/minds/rest_api/chat.mdx
This API endpoint creates a model response for the given chat conversation using the POST method.
A list of messages comprising the conversation so far.
</ParamField> <ParamField body='model' type='string' required>Name of the Mind that you created.
</ParamField> <ParamField body='stream' type='boolean'>If set, Minds' thoughts will be streamed before the final response.
</ParamField> <ParamField body='frequency_penalty' type='number'>This setting ranges from -2.0 to 2.0. Positive values make the model less likely to repeat phrases it has already used.
</ParamField> <ParamField body='max_tokens' type='integer'>This parameter sets the maximum number of tokens that can be generated in the chat completion.
</ParamField> <ParamField body='temperature' type='number'>This parameter controls the randomness of the output with values ranging from 0 to 2. A higher value increases randomness in the output, while a lower value, like 0.1, results in more focused and deterministic output.
</ParamField> <ParamField body='tools' type='array'>This setting allows you to specify a list of tools that the model can call, currently limited to functions.
</ParamField>A valid API key must be passed in the Authorization header:
Authorization: Bearer MINDS_API_KEY
Generate your API key here.
None.
<RequestExample>curl https://mdb.ai/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $MINDS_API_KEY" \
-d '{
"model": "<name of the mind that you created>",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Can you summarize the data you have access to?"
}
],
"stream": false
}'
from openai import OpenAI
client = OpenAI(
api_key="MINDS_API_KEY",
base_url="https://mdb.ai"
)
completion = client.chat.completions.create(
model="<name of the mind that you created>",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Can you summarize the data you have access to?"}
],
stream=False
)
print(completion.choices[0].message)
# if stream=True, then print chunks, as below
# for chunk in completion:
# print(chunk.choices[0].delta)
import OpenAI from "openai";
const openai = new OpenAI(
apiKey="MINDS_API_KEY",
baseURL="https://mdb.ai"
);
async function main() {
const completion = await openai.chat.completions.create({
messages: [{ role: "system", content: "You are a helpful assistant." }],
model: "<name of the mind that you created>",
stream: false,
});
console.log(completion.choices[0]);
// if stream: true, then print chunks, as below
// for await (const chunk of completion) {
// console.log(chunk.choices[0].delta.content);
}
}
main();
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1702685778,
"model": "<name of the mind that you created>",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "I have access to sales data, customer info, and website analytics. Let me know if you need details!"
}
}
],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 9,
"total_tokens": 18
},
"system_fingerprint": null
}