(beta) Libraries API - manage documents in a library.
- list - List documents in a given library.
- upload - Upload a new document.
- get - Retrieve the metadata of a specific document.
- update - Update the metadata of a specific document.
librariesDocumentsUpdateV1- Update the metadata of a specific document.⚠️ Deprecated- delete - Delete a document.
- textContent - Retrieve the text content of a specific document.
- status - Retrieve the processing status of a specific document.
- getSignedUrl - Retrieve the signed URL of a specific document.
- extractedTextSignedUrl - Retrieve the signed URL of text extracted from a given document.
- reprocess - Reprocess a document.
Given a library, lists the document that have been uploaded to that library.
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const result = await mistral.beta.libraries.documents.list({
libraryId: "5c3ca4cd-62bc-4c71-ad8a-1531ae80d078",
});
console.log(result);
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaLibrariesDocumentsList } from "@mistralai/mistralai/funcs/betaLibrariesDocumentsList.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 betaLibrariesDocumentsList(mistral, {
libraryId: "5c3ca4cd-62bc-4c71-ad8a-1531ae80d078",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("betaLibrariesDocumentsList failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.LibrariesDocumentsListV1Request | ✔️ | 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.ListDocumentsResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Given a library, upload a new document to that library. It is queued for processing, it status will change it has been processed. The processing has to be completed in order be discoverable for the library search
import { Mistral } from "@mistralai/mistralai";
import { openAsBlob } from "node:fs";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const result = await mistral.beta.libraries.documents.upload({
libraryId: "a02150d9-5ee0-4877-b62c-28b1fcdf3b76",
requestBody: {
file: await openAsBlob("example.file"),
},
});
console.log(result);
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaLibrariesDocumentsUpload } from "@mistralai/mistralai/funcs/betaLibrariesDocumentsUpload.js";
import { openAsBlob } from "node:fs";
// 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 betaLibrariesDocumentsUpload(mistral, {
libraryId: "a02150d9-5ee0-4877-b62c-28b1fcdf3b76",
requestBody: {
file: await openAsBlob("example.file"),
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("betaLibrariesDocumentsUpload failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.LibrariesDocumentsUploadV1Request | ✔️ | 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.Document>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Given a library and a document in this library, you can retrieve the metadata of that document.
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const result = await mistral.beta.libraries.documents.get({
libraryId: "03d908c8-90a1-44fd-bf3a-8490fb7c9a03",
documentId: "90973aec-0508-4375-8b00-91d732414745",
});
console.log(result);
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaLibrariesDocumentsGet } from "@mistralai/mistralai/funcs/betaLibrariesDocumentsGet.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 betaLibrariesDocumentsGet(mistral, {
libraryId: "03d908c8-90a1-44fd-bf3a-8490fb7c9a03",
documentId: "90973aec-0508-4375-8b00-91d732414745",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("betaLibrariesDocumentsGet failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.LibrariesDocumentsGetV1Request | ✔️ | 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.Document>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Given a library and a document in that library, update the name and/or attributes of that document.
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const result = await mistral.beta.libraries.documents.update({
libraryId: "2a41249e-52ca-4436-b755-25ce3a9bfb53",
documentId: "bc26fa54-e5d9-4269-bedf-86bed5471c7d",
updateDocumentRequest: {},
});
console.log(result);
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaLibrariesDocumentsUpdate } from "@mistralai/mistralai/funcs/betaLibrariesDocumentsUpdate.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 betaLibrariesDocumentsUpdate(mistral, {
libraryId: "2a41249e-52ca-4436-b755-25ce3a9bfb53",
documentId: "bc26fa54-e5d9-4269-bedf-86bed5471c7d",
updateDocumentRequest: {},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("betaLibrariesDocumentsUpdate failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.LibrariesDocumentsPatchV1Request | ✔️ | 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.Document>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Given a library and a document in that library, update the name of that document.
⚠️ DEPRECATED: Use the PATCH method instead. This PUT endpoint will be removed in a future version..
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const result = await mistral.beta.libraries.documents.librariesDocumentsUpdateV1({
libraryId: "3ddd8d93-dca5-4a6d-980d-173226c35742",
documentId: "2a25e44c-b160-40ca-b5c2-b65fb2fcae34",
updateDocumentRequest: {},
});
console.log(result);
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaLibrariesDocumentsLibrariesDocumentsUpdateV1 } from "@mistralai/mistralai/funcs/betaLibrariesDocumentsLibrariesDocumentsUpdateV1.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 betaLibrariesDocumentsLibrariesDocumentsUpdateV1(mistral, {
libraryId: "3ddd8d93-dca5-4a6d-980d-173226c35742",
documentId: "2a25e44c-b160-40ca-b5c2-b65fb2fcae34",
updateDocumentRequest: {},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("betaLibrariesDocumentsLibrariesDocumentsUpdateV1 failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.LibrariesDocumentsUpdateV1Request | ✔️ | 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.Document>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Given a library and a document in that library, delete that document. The document will be deleted from the library and the search index.
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
await mistral.beta.libraries.documents.delete({
libraryId: "005daae9-d42e-407d-82d7-2261c6a1496c",
documentId: "edc236b0-baff-49a9-884b-4ca36a258da4",
});
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaLibrariesDocumentsDelete } from "@mistralai/mistralai/funcs/betaLibrariesDocumentsDelete.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 betaLibrariesDocumentsDelete(mistral, {
libraryId: "005daae9-d42e-407d-82d7-2261c6a1496c",
documentId: "edc236b0-baff-49a9-884b-4ca36a258da4",
});
if (res.ok) {
const { value: result } = res;
} else {
console.log("betaLibrariesDocumentsDelete failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.LibrariesDocumentsDeleteV1Request | ✔️ | 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 | */* |
Given a library and a document in that library, you can retrieve the text content of that document if it exists. For documents like pdf, docx and pptx the text content results from our processing using Mistral OCR.
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const result = await mistral.beta.libraries.documents.textContent({
libraryId: "1d177215-3b6b-45ba-9fa9-baf773223bec",
documentId: "60214c91-2aba-4692-a4e6-a53365de8caf",
});
console.log(result);
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaLibrariesDocumentsTextContent } from "@mistralai/mistralai/funcs/betaLibrariesDocumentsTextContent.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 betaLibrariesDocumentsTextContent(mistral, {
libraryId: "1d177215-3b6b-45ba-9fa9-baf773223bec",
documentId: "60214c91-2aba-4692-a4e6-a53365de8caf",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("betaLibrariesDocumentsTextContent failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.LibrariesDocumentsGetTextContentV1Request | ✔️ | 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.DocumentTextContent>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Given a library and a document in that library, retrieve the processing status of that document.
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const result = await mistral.beta.libraries.documents.status({
libraryId: "e6906f70-368f-4155-80da-c1718f01bc43",
documentId: "2c904915-d831-4e9d-a345-8ce405bcef66",
});
console.log(result);
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaLibrariesDocumentsStatus } from "@mistralai/mistralai/funcs/betaLibrariesDocumentsStatus.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 betaLibrariesDocumentsStatus(mistral, {
libraryId: "e6906f70-368f-4155-80da-c1718f01bc43",
documentId: "2c904915-d831-4e9d-a345-8ce405bcef66",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("betaLibrariesDocumentsStatus failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.LibrariesDocumentsGetStatusV1Request | ✔️ | 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.ProcessingStatus>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Given a library and a document in that library, retrieve the signed URL of a specific document.The url will expire after 30 minutes and can be accessed by anyone with the link.
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const result = await mistral.beta.libraries.documents.getSignedUrl({
libraryId: "23cf6904-a602-4ee8-9f5b-8efc557c336d",
documentId: "48598486-df71-4994-acbb-1133c72efa8c",
});
console.log(result);
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaLibrariesDocumentsGetSignedUrl } from "@mistralai/mistralai/funcs/betaLibrariesDocumentsGetSignedUrl.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 betaLibrariesDocumentsGetSignedUrl(mistral, {
libraryId: "23cf6904-a602-4ee8-9f5b-8efc557c336d",
documentId: "48598486-df71-4994-acbb-1133c72efa8c",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("betaLibrariesDocumentsGetSignedUrl failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.LibrariesDocumentsGetSignedUrlV1Request | ✔️ | 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<string>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Given a library and a document in that library, retrieve the signed URL of text extracted. For documents that are sent to the OCR this returns the result of the OCR queries.
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
const result = await mistral.beta.libraries.documents.extractedTextSignedUrl({
libraryId: "a6f15de3-1e82-4f95-af82-851499042ef8",
documentId: "9749d4f9-24e5-4ca2-99a3-a406863f805d",
});
console.log(result);
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaLibrariesDocumentsExtractedTextSignedUrl } from "@mistralai/mistralai/funcs/betaLibrariesDocumentsExtractedTextSignedUrl.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 betaLibrariesDocumentsExtractedTextSignedUrl(mistral, {
libraryId: "a6f15de3-1e82-4f95-af82-851499042ef8",
documentId: "9749d4f9-24e5-4ca2-99a3-a406863f805d",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("betaLibrariesDocumentsExtractedTextSignedUrl failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.LibrariesDocumentsGetExtractedTextSignedUrlV1Request | ✔️ | 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<string>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.HTTPValidationError | 422 | application/json |
| errors.SDKError | 4XX, 5XX | */* |
Given a library and a document in that library, reprocess that document, it will be billed again.
import { Mistral } from "@mistralai/mistralai";
const mistral = new Mistral({
apiKey: process.env["MISTRAL_API_KEY"] ?? "",
});
async function run() {
await mistral.beta.libraries.documents.reprocess({
libraryId: "51b29371-de8f-4ba4-932b-a0bafb3a7f64",
documentId: "3052422c-49ca-45ac-a918-cadb35d61fd8",
});
}
run();The standalone function version of this method:
import { MistralCore } from "@mistralai/mistralai/core.js";
import { betaLibrariesDocumentsReprocess } from "@mistralai/mistralai/funcs/betaLibrariesDocumentsReprocess.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 betaLibrariesDocumentsReprocess(mistral, {
libraryId: "51b29371-de8f-4ba4-932b-a0bafb3a7f64",
documentId: "3052422c-49ca-45ac-a918-cadb35d61fd8",
});
if (res.ok) {
const { value: result } = res;
} else {
console.log("betaLibrariesDocumentsReprocess failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.LibrariesDocumentsReprocessV1Request | ✔️ | 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 | */* |