Beta.Libraries.Documents

May 22, 2026 ยท View on GitHub

Overview

(beta) Libraries API - manage documents in a library.

Available Operations

  • 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.
  • libraries_documents_update_v1 - Update the metadata of a specific document. :warning: Deprecated
  • delete - Delete a document.
  • text_content - Retrieve the text content of a specific document.
  • status - Retrieve the processing status of a specific document.
  • get_signed_url - Retrieve the signed URL of a specific document.
  • extracted_text_signed_url - Retrieve the signed URL of text extracted from a given document.
  • reprocess - Reprocess a document.

list

Given a library, lists the document that have been uploaded to that library.

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.documents.list(library_id="5c3ca4cd-62bc-4c71-ad8a-1531ae80d078", page_size=100, page=0, sort_by="created_at", sort_order="desc")

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
library_idstr:heavy_check_mark:N/A
searchOptionalNullable[str]:heavy_minus_sign:N/A
page_sizeOptional[int]:heavy_minus_sign:N/A
pageOptional[int]:heavy_minus_sign:N/A
filters_attributesOptionalNullable[str]:heavy_minus_sign:: warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

Deprecated: this parameter will be removed in a future version.
sort_byOptional[str]:heavy_minus_sign:N/A
sort_orderOptional[str]:heavy_minus_sign:N/A
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.ListDocumentsResponse

Errors

Error TypeStatus CodeContent Type
errors.HTTPValidationError422application/json
errors.SDKError4XX, 5XX*/*

upload

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

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.documents.upload(library_id="a02150d9-5ee0-4877-b62c-28b1fcdf3b76", file={
        "file_name": "example.file",
        "content": open("example.file", "rb"),
    })

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
library_idstr:heavy_check_mark:N/A
filemodels.File:heavy_check_mark:The File object (not file name) to be uploaded.
To upload a file and specify a custom file name you should format your request as such:
bash<br/> file=@path/to/your/file.jsonl;filename=custom_name.jsonl<br/>
Otherwise, you can just keep the original file name:
bash<br/> file=@path/to/your/file.jsonl<br/>
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.Document

Errors

Error TypeStatus CodeContent Type
errors.HTTPValidationError422application/json
errors.SDKError4XX, 5XX*/*

get

Given a library and a document in this library, you can retrieve the metadata of that document.

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.documents.get(library_id="03d908c8-90a1-44fd-bf3a-8490fb7c9a03", document_id="90973aec-0508-4375-8b00-91d732414745")

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
library_idstr:heavy_check_mark:N/A
document_idstr:heavy_check_mark:N/A
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.Document

Errors

Error TypeStatus CodeContent Type
errors.HTTPValidationError422application/json
errors.SDKError4XX, 5XX*/*

update

Given a library and a document in that library, update the name and/or attributes of that document.

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.documents.update(library_id="2a41249e-52ca-4436-b755-25ce3a9bfb53", document_id="bc26fa54-e5d9-4269-bedf-86bed5471c7d")

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
library_idstr:heavy_check_mark:N/A
document_idstr:heavy_check_mark:N/A
nameOptional[str]:heavy_minus_sign:N/A
attributesDict[str, models.Attributes]:heavy_minus_sign:N/A
expires_atdate:heavy_minus_sign:If set, the document will be automatically deleted after this date.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.Document

Errors

Error TypeStatus CodeContent Type
errors.HTTPValidationError422application/json
errors.SDKError4XX, 5XX*/*

libraries_documents_update_v1

Given a library and a document in that library, update the name of that document.

:warning: DEPRECATED: Use the PATCH method instead. This PUT endpoint will be removed in a future version..

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.documents.libraries_documents_update_v1(library_id="3ddd8d93-dca5-4a6d-980d-173226c35742", document_id="2a25e44c-b160-40ca-b5c2-b65fb2fcae34")

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
library_idstr:heavy_check_mark:N/A
document_idstr:heavy_check_mark:N/A
nameOptional[str]:heavy_minus_sign:N/A
attributesDict[str, models.Attributes]:heavy_minus_sign:N/A
expires_atdate:heavy_minus_sign:If set, the document will be automatically deleted after this date.
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.Document

Errors

Error TypeStatus CodeContent Type
errors.HTTPValidationError422application/json
errors.SDKError4XX, 5XX*/*

delete

Given a library and a document in that library, delete that document. The document will be deleted from the library and the search index.

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    mistral.beta.libraries.documents.delete(library_id="005daae9-d42e-407d-82d7-2261c6a1496c", document_id="edc236b0-baff-49a9-884b-4ca36a258da4")

    # Use the SDK ...

Parameters

ParameterTypeRequiredDescription
library_idstr:heavy_check_mark:N/A
document_idstr:heavy_check_mark:N/A
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Errors

Error TypeStatus CodeContent Type
errors.HTTPValidationError422application/json
errors.SDKError4XX, 5XX*/*

text_content

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.

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.documents.text_content(library_id="1d177215-3b6b-45ba-9fa9-baf773223bec", document_id="60214c91-2aba-4692-a4e6-a53365de8caf")

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
library_idstr:heavy_check_mark:N/A
document_idstr:heavy_check_mark:N/A
page_startOptionalNullable[int]:heavy_minus_sign:N/A
page_endOptionalNullable[int]:heavy_minus_sign:N/A
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.DocumentTextContent

Errors

Error TypeStatus CodeContent Type
errors.HTTPValidationError422application/json
errors.SDKError4XX, 5XX*/*

status

Given a library and a document in that library, retrieve the processing status of that document.

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.documents.status(library_id="e6906f70-368f-4155-80da-c1718f01bc43", document_id="2c904915-d831-4e9d-a345-8ce405bcef66")

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
library_idstr:heavy_check_mark:N/A
document_idstr:heavy_check_mark:N/A
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

models.ProcessingStatus

Errors

Error TypeStatus CodeContent Type
errors.HTTPValidationError422application/json
errors.SDKError4XX, 5XX*/*

get_signed_url

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.

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.documents.get_signed_url(library_id="23cf6904-a602-4ee8-9f5b-8efc557c336d", document_id="48598486-df71-4994-acbb-1133c72efa8c")

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
library_idstr:heavy_check_mark:N/A
document_idstr:heavy_check_mark:N/A
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

str

Errors

Error TypeStatus CodeContent Type
errors.HTTPValidationError422application/json
errors.SDKError4XX, 5XX*/*

extracted_text_signed_url

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.

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    res = mistral.beta.libraries.documents.extracted_text_signed_url(library_id="a6f15de3-1e82-4f95-af82-851499042ef8", document_id="9749d4f9-24e5-4ca2-99a3-a406863f805d")

    # Handle response
    print(res)

Parameters

ParameterTypeRequiredDescription
library_idstr:heavy_check_mark:N/A
document_idstr:heavy_check_mark:N/A
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Response

str

Errors

Error TypeStatus CodeContent Type
errors.HTTPValidationError422application/json
errors.SDKError4XX, 5XX*/*

reprocess

Given a library and a document in that library, reprocess that document, it will be billed again.

Example Usage

from mistralai.client import Mistral
import os


with Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
) as mistral:

    mistral.beta.libraries.documents.reprocess(library_id="51b29371-de8f-4ba4-932b-a0bafb3a7f64", document_id="3052422c-49ca-45ac-a918-cadb35d61fd8")

    # Use the SDK ...

Parameters

ParameterTypeRequiredDescription
library_idstr:heavy_check_mark:N/A
document_idstr:heavy_check_mark:N/A
retriesOptional[utils.RetryConfig]:heavy_minus_sign:Configuration to override the default retry behavior of the client.

Errors

Error TypeStatus CodeContent Type
errors.HTTPValidationError422application/json
errors.SDKError4XX, 5XX*/*