(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.
libraries_documents_update_v1 - Update the metadata of a specific document. ⚠️ 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.
Given a library, lists the document that have been uploaded to that library.
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 )
Parameter
Type
Required
Description
library_id
str
✔️
N/A
search
OptionalNullable[str]
➖
N/A
page_size
Optional[int]
➖
N/A
page
Optional[int]
➖
N/A
filters_attributes
OptionalNullable[str]
➖
: 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_by
Optional[str]
➖
N/A
sort_order
Optional[str]
➖
N/A
retries
Optional[utils.RetryConfig]
➖
Configuration to override the default retry behavior of the client.
models.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
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 )
Parameter
Type
Required
Description
library_id
str
✔️
N/A
file
models.File
✔️
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/>
retries
Optional[utils.RetryConfig]
➖
Configuration to override the default retry behavior of the client.
models.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.
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 )
Parameter
Type
Required
Description
library_id
str
✔️
N/A
document_id
str
✔️
N/A
retries
Optional[utils.RetryConfig]
➖
Configuration to override the default retry behavior of the client.
models.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.
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 )
Parameter
Type
Required
Description
library_id
str
✔️
N/A
document_id
str
✔️
N/A
name
Optional[str]
➖
N/A
attributes
Dict[str, models.Attributes ]
➖
N/A
expires_at
date
➖
If set, the document will be automatically deleted after this date.
retries
Optional[utils.RetryConfig]
➖
Configuration to override the default retry behavior of the client.
models.Document
Error Type
Status Code
Content Type
errors.HTTPValidationError
422
application/json
errors.SDKError
4XX, 5XX
*/*
libraries_documents_update_v1
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..
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 )
Parameter
Type
Required
Description
library_id
str
✔️
N/A
document_id
str
✔️
N/A
name
Optional[str]
➖
N/A
attributes
Dict[str, models.Attributes ]
➖
N/A
expires_at
date
➖
If set, the document will be automatically deleted after this date.
retries
Optional[utils.RetryConfig]
➖
Configuration to override the default retry behavior of the client.
models.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.
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 ...
Parameter
Type
Required
Description
library_id
str
✔️
N/A
document_id
str
✔️
N/A
retries
Optional[utils.RetryConfig]
➖
Configuration to override the default retry behavior of the client.
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.
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 )
Parameter
Type
Required
Description
library_id
str
✔️
N/A
document_id
str
✔️
N/A
page_start
OptionalNullable[int]
➖
N/A
page_end
OptionalNullable[int]
➖
N/A
retries
Optional[utils.RetryConfig]
➖
Configuration to override the default retry behavior of the client.
models.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.
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 )
Parameter
Type
Required
Description
library_id
str
✔️
N/A
document_id
str
✔️
N/A
retries
Optional[utils.RetryConfig]
➖
Configuration to override the default retry behavior of the client.
models.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.
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 )
Parameter
Type
Required
Description
library_id
str
✔️
N/A
document_id
str
✔️
N/A
retries
Optional[utils.RetryConfig]
➖
Configuration to override the default retry behavior of the client.
str
Error Type
Status Code
Content Type
errors.HTTPValidationError
422
application/json
errors.SDKError
4XX, 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.
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 )
Parameter
Type
Required
Description
library_id
str
✔️
N/A
document_id
str
✔️
N/A
retries
Optional[utils.RetryConfig]
➖
Configuration to override the default retry behavior of the client.
str
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.
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 ...
Parameter
Type
Required
Description
library_id
str
✔️
N/A
document_id
str
✔️
N/A
retries
Optional[utils.RetryConfig]
➖
Configuration to override the default retry behavior of the client.
Error Type
Status Code
Content Type
errors.HTTPValidationError
422
application/json
errors.SDKError
4XX, 5XX
*/*