Skip to content

Latest commit

 

History

History
178 lines (113 loc) · 10.5 KB

README.md

File metadata and controls

178 lines (113 loc) · 10.5 KB

Files

(files)

Overview

Files API

Available Operations

upload

Upload a file that can be used across various endpoints.

The size of individual files can be a maximum of 512 MB. The Fine-tuning API only supports .jsonl files.

Please contact us if you need to increase these storage limits.

Example Usage

from mistralai import Mistral
import os

s = Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
)

res = s.files.upload(file={
    "file_name": "example.file",
    "content": open("example.file", "rb"),
})

if res is not None:
    # handle response
    pass

Parameters

Parameter Type Required Description
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.

Response

models.UploadFileOut

Errors

Error Object Status Code Content Type
models.SDKError 4xx-5xx /

list

Returns a list of files that belong to the user's organization.

Example Usage

from mistralai import Mistral
import os

s = Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
)

res = s.files.list()

if res is not None:
    # handle response
    pass

Parameters

Parameter Type Required Description
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.ListFilesOut

Errors

Error Object Status Code Content Type
models.SDKError 4xx-5xx /

retrieve

Returns information about a specific file.

Example Usage

from mistralai import Mistral
import os

s = Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
)

res = s.files.retrieve(file_id="<value>")

if res is not None:
    # handle response
    pass

Parameters

Parameter Type Required Description
file_id str ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.RetrieveFileOut

Errors

Error Object Status Code Content Type
models.SDKError 4xx-5xx /

delete

Delete a file.

Example Usage

from mistralai import Mistral
import os

s = Mistral(
    api_key=os.getenv("MISTRAL_API_KEY", ""),
)

res = s.files.delete(file_id="<value>")

if res is not None:
    # handle response
    pass

Parameters

Parameter Type Required Description
file_id str ✔️ N/A
retries Optional[utils.RetryConfig] Configuration to override the default retry behavior of the client.

Response

models.DeleteFileOut

Errors

Error Object Status Code Content Type
models.SDKError 4xx-5xx /