(beta) Conversations API
- start - Create a conversation and append entries to it.
- list - List all created conversations.
- get - Retrieve a conversation information.
- delete - Delete a conversation.
- append - Append new entries to an existing conversation.
- getHistory - Retrieve all entries in a conversation.
- getMessages - Retrieve all messages in a conversation.
- restart - Restart a conversation starting from a given entry.
- startStream - Create a conversation and append entries to it.
- appendStream - Append new entries to an existing conversation.
- restartStream - Restart a conversation starting from a given entry.
Create a new conversation, using a base model or an agent and append entries. Completion and tool executions are run and the response is appended to the conversation.Use the returned conversation_id to continue the conversation.
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const result = await mistral.beta.conversations.start({
inputs: "<value>",
completionArgs: {
responseFormat: {
type: "text",
},
},
});
console.log(result);
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaConversationsStart } from "@mistralai/mistralai/funcs/betaConversationsStart.js";
// Use `MistralCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const mistral = new MistralCore({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const res = await betaConversationsStart(mistral, {
inputs: "<value>",
completionArgs: {
responseFormat: {
type: "text",
},
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("betaConversationsStart failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
components.ConversationRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.ConversationResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Retrieve a list of conversation entities sorted by creation time.
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const result = await mistral.beta.conversations.list({});
console.log(result);
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaConversationsList } from "@mistralai/mistralai/funcs/betaConversationsList.js";
// Use `MistralCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const mistral = new MistralCore({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const res = await betaConversationsList(mistral, {});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("betaConversationsList failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.AgentsApiV1ConversationsListRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.AgentsApiV1ConversationsListResponse[]>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Given a conversation_id retrieve a conversation entity with its attributes.
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const result = await mistral.beta.conversations.get({
conversationId: "<id>",
});
console.log(result);
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaConversationsGet } from "@mistralai/mistralai/funcs/betaConversationsGet.js";
// Use `MistralCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const mistral = new MistralCore({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const res = await betaConversationsGet(mistral, {
conversationId: "<id>",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("betaConversationsGet failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.AgentsApiV1ConversationsGetRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.ResponseV1ConversationsGet>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Delete a conversation given a conversation_id.
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
await mistral.beta.conversations.delete({
conversationId: "<id>",
});
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaConversationsDelete } from "@mistralai/mistralai/funcs/betaConversationsDelete.js";
// Use `MistralCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const mistral = new MistralCore({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const res = await betaConversationsDelete(mistral, {
conversationId: "<id>",
});
if (res.ok) {
const { value: result } = res;
} else {
console.log("betaConversationsDelete failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.AgentsApiV1ConversationsDeleteRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<void>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Run completion on the history of the conversation and the user entries. Return the new created entries.
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const result = await mistral.beta.conversations.append({
conversationId: "<id>",
conversationAppendRequest: {
completionArgs: {
responseFormat: {
type: "text",
},
},
},
});
console.log(result);
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaConversationsAppend } from "@mistralai/mistralai/funcs/betaConversationsAppend.js";
// Use `MistralCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const mistral = new MistralCore({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const res = await betaConversationsAppend(mistral, {
conversationId: "<id>",
conversationAppendRequest: {
completionArgs: {
responseFormat: {
type: "text",
},
},
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("betaConversationsAppend failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.AgentsApiV1ConversationsAppendRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.ConversationResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Given a conversation_id retrieve all the entries belonging to that conversation. The entries are sorted in the order they were appended, those can be messages, connectors or function_call.
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const result = await mistral.beta.conversations.getHistory({
conversationId: "<id>",
});
console.log(result);
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaConversationsGetHistory } from "@mistralai/mistralai/funcs/betaConversationsGetHistory.js";
// Use `MistralCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const mistral = new MistralCore({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const res = await betaConversationsGetHistory(mistral, {
conversationId: "<id>",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("betaConversationsGetHistory failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.AgentsApiV1ConversationsHistoryRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.ConversationHistory>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Given a conversation_id retrieve all the messages belonging to that conversation. This is similar to retrieving all entries except we filter the messages only.
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const result = await mistral.beta.conversations.getMessages({
conversationId: "<id>",
});
console.log(result);
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaConversationsGetMessages } from "@mistralai/mistralai/funcs/betaConversationsGetMessages.js";
// Use `MistralCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const mistral = new MistralCore({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const res = await betaConversationsGetMessages(mistral, {
conversationId: "<id>",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("betaConversationsGetMessages failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.AgentsApiV1ConversationsMessagesRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.ConversationMessages>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Given a conversation_id and an id, recreate a conversation from this point and run completion. A new conversation is returned with the new entries returned.
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const result = await mistral.beta.conversations.restart({
conversationId: "<id>",
conversationRestartRequest: {
completionArgs: {
responseFormat: {
type: "text",
},
},
fromEntryId: "<id>",
},
});
console.log(result);
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaConversationsRestart } from "@mistralai/mistralai/funcs/betaConversationsRestart.js";
// Use `MistralCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const mistral = new MistralCore({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const res = await betaConversationsRestart(mistral, {
conversationId: "<id>",
conversationRestartRequest: {
completionArgs: {
responseFormat: {
type: "text",
},
},
fromEntryId: "<id>",
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("betaConversationsRestart failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.AgentsApiV1ConversationsRestartRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<components.ConversationResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Create a new conversation, using a base model or an agent and append entries. Completion and tool executions are run and the response is appended to the conversation.Use the returned conversation_id to continue the conversation.
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const result = await mistral.beta.conversations.startStream({
inputs: [
{
object: "entry",
type: "agent.handoff",
previousAgentId: "<id>",
previousAgentName: "<value>",
nextAgentId: "<id>",
nextAgentName: "<value>",
},
],
completionArgs: {
responseFormat: {
type: "text",
},
},
});
for await (const event of result) {
console.log(event);
}
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaConversationsStartStream } from "@mistralai/mistralai/funcs/betaConversationsStartStream.js";
// Use `MistralCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const mistral = new MistralCore({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const res = await betaConversationsStartStream(mistral, {
inputs: [
{
object: "entry",
type: "agent.handoff",
previousAgentId: "<id>",
previousAgentName: "<value>",
nextAgentId: "<id>",
nextAgentName: "<value>",
},
],
completionArgs: {
responseFormat: {
type: "text",
},
},
});
if (res.ok) {
const { value: result } = res;
for await (const event of result) {
console.log(event);
}
} else {
console.log("betaConversationsStartStream failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
components.ConversationStreamRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<EventStream<components.ConversationEvents>>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Run completion on the history of the conversation and the user entries. Return the new created entries.
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const result = await mistral.beta.conversations.appendStream({
conversationId: "<id>",
conversationAppendStreamRequest: {
completionArgs: {
responseFormat: {
type: "text",
},
},
},
});
for await (const event of result) {
console.log(event);
}
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaConversationsAppendStream } from "@mistralai/mistralai/funcs/betaConversationsAppendStream.js";
// Use `MistralCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const mistral = new MistralCore({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const res = await betaConversationsAppendStream(mistral, {
conversationId: "<id>",
conversationAppendStreamRequest: {
completionArgs: {
responseFormat: {
type: "text",
},
},
},
});
if (res.ok) {
const { value: result } = res;
for await (const event of result) {
console.log(event);
}
} else {
console.log("betaConversationsAppendStream failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.AgentsApiV1ConversationsAppendStreamRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<EventStream<components.ConversationEvents>>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Given a conversation_id and an id, recreate a conversation from this point and run completion. A new conversation is returned with the new entries returned.
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const result = await mistral.beta.conversations.restartStream({
conversationId: "<id>",
conversationRestartStreamRequest: {
completionArgs: {
responseFormat: {
type: "text",
},
},
fromEntryId: "<id>",
},
});
for await (const event of result) {
console.log(event);
}
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaConversationsRestartStream } from "@mistralai/mistralai/funcs/betaConversationsRestartStream.js";
// Use `MistralCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const mistral = new MistralCore({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const res = await betaConversationsRestartStream(mistral, {
conversationId: "<id>",
conversationRestartStreamRequest: {
completionArgs: {
responseFormat: {
type: "text",
},
},
fromEntryId: "<id>",
},
});
if (res.ok) {
const { value: result } = res;
for await (const event of result) {
console.log(event);
}
} else {
console.log("betaConversationsRestartStream failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.AgentsApiV1ConversationsRestartStreamRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<EventStream<components.ConversationEvents>>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |