mistralai 0.4.2__tar.gz → 0.5.5a50__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mistralai-0.4.2 → mistralai-0.5.5a50}/LICENSE +1 -1
- mistralai-0.5.5a50/PKG-INFO +626 -0
- mistralai-0.5.5a50/README.md +603 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/__init__.py +5 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/_hooks/__init__.py +5 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/_hooks/custom_user_agent.py +16 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/_hooks/registration.py +15 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/_hooks/sdkhooks.py +57 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/_hooks/types.py +76 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/basesdk.py +215 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/chat.py +475 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/httpclient.py +78 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/__init__.py +28 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/assistantmessage.py +58 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/chatcompletionchoice.py +33 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/chatcompletionrequest.py +114 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/chatcompletionresponse.py +27 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/chatcompletionstreamrequest.py +112 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/completionchunk.py +27 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/completionevent.py +15 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/completionresponsestreamchoice.py +53 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/contentchunk.py +17 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/deltamessage.py +52 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/function.py +19 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/functioncall.py +16 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/httpvalidationerror.py +23 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/responseformat.py +18 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/sdkerror.py +22 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/security.py +16 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/systemmessage.py +26 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/textchunk.py +17 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/tool.py +18 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/toolcall.py +20 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/toolmessage.py +55 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/usageinfo.py +18 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/usermessage.py +26 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/models/validationerror.py +24 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/py.typed +1 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/sdk.py +102 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/sdkconfiguration.py +53 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/types/__init__.py +21 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/types/basemodel.py +35 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/utils/__init__.py +80 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/utils/annotations.py +19 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/utils/enums.py +34 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/utils/eventstreaming.py +179 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/utils/forms.py +207 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/utils/headers.py +136 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/utils/metadata.py +118 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/utils/queryparams.py +203 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/utils/requestbodies.py +66 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/utils/retries.py +216 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/utils/security.py +168 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/utils/serializers.py +181 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/utils/url.py +150 -0
- mistralai-0.5.5a50/packages/mistralai_azure/src/mistralai_azure/utils/values.py +128 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/__init__.py +5 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/_hooks/__init__.py +5 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/_hooks/custom_user_agent.py +16 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/_hooks/registration.py +15 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/_hooks/sdkhooks.py +57 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/_hooks/types.py +76 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/basesdk.py +215 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/chat.py +463 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/fim.py +439 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/httpclient.py +78 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/__init__.py +31 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/assistantmessage.py +58 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/chatcompletionchoice.py +33 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/chatcompletionrequest.py +110 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/chatcompletionresponse.py +27 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/chatcompletionstreamrequest.py +108 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/completionchunk.py +27 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/completionevent.py +15 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/completionresponsestreamchoice.py +53 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/contentchunk.py +17 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/deltamessage.py +52 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/fimcompletionrequest.py +99 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/fimcompletionresponse.py +27 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/fimcompletionstreamrequest.py +97 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/function.py +19 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/functioncall.py +16 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/httpvalidationerror.py +23 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/responseformat.py +18 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/sdkerror.py +22 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/security.py +16 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/systemmessage.py +26 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/textchunk.py +17 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/tool.py +18 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/toolcall.py +20 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/toolmessage.py +55 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/usageinfo.py +18 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/usermessage.py +26 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/models/validationerror.py +24 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/py.typed +1 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/sdk.py +165 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/sdkconfiguration.py +53 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/types/__init__.py +21 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/types/basemodel.py +35 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/utils/__init__.py +80 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/utils/annotations.py +19 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/utils/enums.py +34 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/utils/eventstreaming.py +179 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/utils/forms.py +207 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/utils/headers.py +136 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/utils/metadata.py +118 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/utils/queryparams.py +203 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/utils/requestbodies.py +66 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/utils/retries.py +216 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/utils/security.py +168 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/utils/serializers.py +181 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/utils/url.py +150 -0
- mistralai-0.5.5a50/packages/mistralai_gcp/src/mistralai_gcp/utils/values.py +128 -0
- mistralai-0.5.5a50/py.typed +1 -0
- mistralai-0.5.5a50/pyproject.toml +53 -0
- mistralai-0.5.5a50/src/mistralai/__init__.py +5 -0
- mistralai-0.5.5a50/src/mistralai/_hooks/__init__.py +5 -0
- mistralai-0.5.5a50/src/mistralai/_hooks/custom_user_agent.py +16 -0
- mistralai-0.5.5a50/src/mistralai/_hooks/deprecation_warning.py +26 -0
- mistralai-0.5.5a50/src/mistralai/_hooks/registration.py +17 -0
- mistralai-0.5.5a50/src/mistralai/_hooks/sdkhooks.py +57 -0
- mistralai-0.5.5a50/src/mistralai/_hooks/types.py +76 -0
- mistralai-0.5.5a50/src/mistralai/async_client.py +15 -0
- mistralai-0.5.5a50/src/mistralai/basesdk.py +216 -0
- mistralai-0.5.5a50/src/mistralai/chat.py +475 -0
- mistralai-0.5.5a50/src/mistralai/client.py +14 -0
- mistralai-0.5.5a50/src/mistralai/embeddings.py +182 -0
- mistralai-0.5.5a50/src/mistralai/files.py +600 -0
- mistralai-0.5.5a50/src/mistralai/fim.py +439 -0
- mistralai-0.5.5a50/src/mistralai/fine_tuning.py +855 -0
- mistralai-0.5.5a50/src/mistralai/httpclient.py +78 -0
- mistralai-0.5.5a50/src/mistralai/models/__init__.py +80 -0
- mistralai-0.5.5a50/src/mistralai/models/archiveftmodelout.py +19 -0
- mistralai-0.5.5a50/src/mistralai/models/assistantmessage.py +58 -0
- mistralai-0.5.5a50/src/mistralai/models/chatcompletionchoice.py +33 -0
- mistralai-0.5.5a50/src/mistralai/models/chatcompletionrequest.py +114 -0
- mistralai-0.5.5a50/src/mistralai/models/chatcompletionresponse.py +27 -0
- mistralai-0.5.5a50/src/mistralai/models/chatcompletionstreamrequest.py +112 -0
- mistralai-0.5.5a50/src/mistralai/models/checkpointout.py +25 -0
- mistralai-0.5.5a50/src/mistralai/models/completionchunk.py +27 -0
- mistralai-0.5.5a50/src/mistralai/models/completionevent.py +15 -0
- mistralai-0.5.5a50/src/mistralai/models/completionresponsestreamchoice.py +53 -0
- mistralai-0.5.5a50/src/mistralai/models/contentchunk.py +17 -0
- mistralai-0.5.5a50/src/mistralai/models/delete_model_v1_models_model_id_deleteop.py +16 -0
- mistralai-0.5.5a50/src/mistralai/models/deletefileout.py +24 -0
- mistralai-0.5.5a50/src/mistralai/models/deletemodelout.py +25 -0
- mistralai-0.5.5a50/src/mistralai/models/deltamessage.py +52 -0
- mistralai-0.5.5a50/src/mistralai/models/detailedjobout.py +96 -0
- mistralai-0.5.5a50/src/mistralai/models/embeddingrequest.py +66 -0
- mistralai-0.5.5a50/src/mistralai/models/embeddingresponse.py +24 -0
- mistralai-0.5.5a50/src/mistralai/models/embeddingresponsedata.py +19 -0
- mistralai-0.5.5a50/src/mistralai/models/eventout.py +55 -0
- mistralai-0.5.5a50/src/mistralai/models/files_api_routes_delete_fileop.py +16 -0
- mistralai-0.5.5a50/src/mistralai/models/files_api_routes_retrieve_fileop.py +16 -0
- mistralai-0.5.5a50/src/mistralai/models/files_api_routes_upload_fileop.py +51 -0
- mistralai-0.5.5a50/src/mistralai/models/fileschema.py +76 -0
- mistralai-0.5.5a50/src/mistralai/models/fimcompletionrequest.py +99 -0
- mistralai-0.5.5a50/src/mistralai/models/fimcompletionresponse.py +27 -0
- mistralai-0.5.5a50/src/mistralai/models/fimcompletionstreamrequest.py +97 -0
- mistralai-0.5.5a50/src/mistralai/models/finetuneablemodel.py +8 -0
- mistralai-0.5.5a50/src/mistralai/models/ftmodelcapabilitiesout.py +21 -0
- mistralai-0.5.5a50/src/mistralai/models/ftmodelout.py +70 -0
- mistralai-0.5.5a50/src/mistralai/models/function.py +19 -0
- mistralai-0.5.5a50/src/mistralai/models/functioncall.py +16 -0
- mistralai-0.5.5a50/src/mistralai/models/githubrepositoryin.py +57 -0
- mistralai-0.5.5a50/src/mistralai/models/githubrepositoryout.py +57 -0
- mistralai-0.5.5a50/src/mistralai/models/httpvalidationerror.py +23 -0
- mistralai-0.5.5a50/src/mistralai/models/jobin.py +78 -0
- mistralai-0.5.5a50/src/mistralai/models/jobmetadataout.py +59 -0
- mistralai-0.5.5a50/src/mistralai/models/jobout.py +112 -0
- mistralai-0.5.5a50/src/mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +16 -0
- mistralai-0.5.5a50/src/mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +18 -0
- mistralai-0.5.5a50/src/mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +73 -0
- mistralai-0.5.5a50/src/mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobop.py +18 -0
- mistralai-0.5.5a50/src/mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +86 -0
- mistralai-0.5.5a50/src/mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +16 -0
- mistralai-0.5.5a50/src/mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +16 -0
- mistralai-0.5.5a50/src/mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +19 -0
- mistralai-0.5.5a50/src/mistralai/models/jobsout.py +20 -0
- mistralai-0.5.5a50/src/mistralai/models/legacyjobmetadataout.py +85 -0
- mistralai-0.5.5a50/src/mistralai/models/listfilesout.py +17 -0
- mistralai-0.5.5a50/src/mistralai/models/metricout.py +55 -0
- mistralai-0.5.5a50/src/mistralai/models/modelcapabilities.py +21 -0
- mistralai-0.5.5a50/src/mistralai/models/modelcard.py +71 -0
- mistralai-0.5.5a50/src/mistralai/models/modellist.py +18 -0
- mistralai-0.5.5a50/src/mistralai/models/responseformat.py +18 -0
- mistralai-0.5.5a50/src/mistralai/models/retrieve_model_v1_models_model_id_getop.py +16 -0
- mistralai-0.5.5a50/src/mistralai/models/retrievefileout.py +76 -0
- mistralai-0.5.5a50/src/mistralai/models/sampletype.py +7 -0
- mistralai-0.5.5a50/src/mistralai/models/sdkerror.py +22 -0
- mistralai-0.5.5a50/src/mistralai/models/security.py +16 -0
- mistralai-0.5.5a50/src/mistralai/models/source.py +7 -0
- mistralai-0.5.5a50/src/mistralai/models/systemmessage.py +26 -0
- mistralai-0.5.5a50/src/mistralai/models/textchunk.py +17 -0
- mistralai-0.5.5a50/src/mistralai/models/tool.py +18 -0
- mistralai-0.5.5a50/src/mistralai/models/toolcall.py +20 -0
- mistralai-0.5.5a50/src/mistralai/models/toolmessage.py +55 -0
- mistralai-0.5.5a50/src/mistralai/models/trainingfile.py +17 -0
- mistralai-0.5.5a50/src/mistralai/models/trainingparameters.py +53 -0
- mistralai-0.5.5a50/src/mistralai/models/trainingparametersin.py +61 -0
- mistralai-0.5.5a50/src/mistralai/models/unarchiveftmodelout.py +19 -0
- mistralai-0.5.5a50/src/mistralai/models/updateftmodelin.py +49 -0
- mistralai-0.5.5a50/src/mistralai/models/uploadfileout.py +76 -0
- mistralai-0.5.5a50/src/mistralai/models/usageinfo.py +18 -0
- mistralai-0.5.5a50/src/mistralai/models/usermessage.py +26 -0
- mistralai-0.5.5a50/src/mistralai/models/validationerror.py +24 -0
- mistralai-0.5.5a50/src/mistralai/models/wandbintegration.py +61 -0
- mistralai-0.5.5a50/src/mistralai/models/wandbintegrationout.py +57 -0
- mistralai-0.5.5a50/src/mistralai/models_.py +928 -0
- mistralai-0.5.5a50/src/mistralai/py.typed +1 -0
- mistralai-0.5.5a50/src/mistralai/sdk.py +111 -0
- mistralai-0.5.5a50/src/mistralai/sdkconfiguration.py +53 -0
- mistralai-0.5.5a50/src/mistralai/types/__init__.py +21 -0
- mistralai-0.5.5a50/src/mistralai/types/basemodel.py +35 -0
- mistralai-0.5.5a50/src/mistralai/utils/__init__.py +82 -0
- mistralai-0.5.5a50/src/mistralai/utils/annotations.py +19 -0
- mistralai-0.5.5a50/src/mistralai/utils/enums.py +34 -0
- mistralai-0.5.5a50/src/mistralai/utils/eventstreaming.py +179 -0
- mistralai-0.5.5a50/src/mistralai/utils/forms.py +207 -0
- mistralai-0.5.5a50/src/mistralai/utils/headers.py +136 -0
- mistralai-0.5.5a50/src/mistralai/utils/metadata.py +118 -0
- mistralai-0.5.5a50/src/mistralai/utils/queryparams.py +203 -0
- mistralai-0.5.5a50/src/mistralai/utils/requestbodies.py +66 -0
- mistralai-0.5.5a50/src/mistralai/utils/retries.py +216 -0
- mistralai-0.5.5a50/src/mistralai/utils/security.py +182 -0
- mistralai-0.5.5a50/src/mistralai/utils/serializers.py +181 -0
- mistralai-0.5.5a50/src/mistralai/utils/url.py +150 -0
- mistralai-0.5.5a50/src/mistralai/utils/values.py +128 -0
- mistralai-0.4.2/PKG-INFO +0 -82
- mistralai-0.4.2/README.md +0 -62
- mistralai-0.4.2/pyproject.toml +0 -42
- mistralai-0.4.2/src/mistralai/__init__.py +0 -0
- mistralai-0.4.2/src/mistralai/async_client.py +0 -423
- mistralai-0.4.2/src/mistralai/client.py +0 -423
- mistralai-0.4.2/src/mistralai/client_base.py +0 -211
- mistralai-0.4.2/src/mistralai/constants.py +0 -5
- mistralai-0.4.2/src/mistralai/exceptions.py +0 -54
- mistralai-0.4.2/src/mistralai/files.py +0 -84
- mistralai-0.4.2/src/mistralai/jobs.py +0 -172
- mistralai-0.4.2/src/mistralai/models/__init__.py +0 -0
- mistralai-0.4.2/src/mistralai/models/chat_completion.py +0 -93
- mistralai-0.4.2/src/mistralai/models/common.py +0 -9
- mistralai-0.4.2/src/mistralai/models/embeddings.py +0 -19
- mistralai-0.4.2/src/mistralai/models/files.py +0 -23
- mistralai-0.4.2/src/mistralai/models/jobs.py +0 -100
- mistralai-0.4.2/src/mistralai/models/models.py +0 -39
- mistralai-0.4.2/src/mistralai/py.typed +0 -0
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
same "printed page" as the copyright notice for easier
|
|
187
187
|
identification within third-party archives.
|
|
188
188
|
|
|
189
|
-
Copyright
|
|
189
|
+
Copyright 2024 Mistral AI
|
|
190
190
|
|
|
191
191
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
192
|
you may not use this file except in compliance with the License.
|
|
@@ -0,0 +1,626 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: mistralai
|
|
3
|
+
Version: 0.5.5a50
|
|
4
|
+
Summary: Python Client SDK for the Mistral AI API.
|
|
5
|
+
Author: Mistral
|
|
6
|
+
Requires-Python: >=3.8,<4.0
|
|
7
|
+
Classifier: Programming Language :: Python :: 3
|
|
8
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
9
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Provides-Extra: gcp
|
|
14
|
+
Requires-Dist: google-auth (>=2.31.0,<3.0.0) ; extra == "gcp"
|
|
15
|
+
Requires-Dist: httpx (>=0.27.0,<0.28.0)
|
|
16
|
+
Requires-Dist: jsonpath-python (>=1.0.6,<2.0.0)
|
|
17
|
+
Requires-Dist: pydantic (>=2.8.2,<2.9.0)
|
|
18
|
+
Requires-Dist: python-dateutil (>=2.9.0.post0,<3.0.0)
|
|
19
|
+
Requires-Dist: requests (>=2.32.3,<3.0.0) ; extra == "gcp"
|
|
20
|
+
Requires-Dist: typing-inspect (>=0.9.0,<0.10.0)
|
|
21
|
+
Description-Content-Type: text/markdown
|
|
22
|
+
|
|
23
|
+
# mistralai
|
|
24
|
+
|
|
25
|
+
<div align="left">
|
|
26
|
+
<a href="https://speakeasyapi.dev/"><img src="https://custom-icon-badges.demolab.com/badge/-Built%20By%20Speakeasy-212015?style=for-the-badge&logoColor=FBE331&logo=speakeasy&labelColor=545454" /></a>
|
|
27
|
+
</div>
|
|
28
|
+
|
|
29
|
+
## Migration warning
|
|
30
|
+
|
|
31
|
+
TODO: provide more details
|
|
32
|
+
This documentation is for Mistralai SDK v1. You can find more details on how to migrate from v0 to v1 [here](MIGRATION.md)
|
|
33
|
+
|
|
34
|
+
<!-- Start SDK Installation [installation] -->
|
|
35
|
+
## SDK Installation
|
|
36
|
+
|
|
37
|
+
PIP
|
|
38
|
+
```bash
|
|
39
|
+
pip install mistralai
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Poetry
|
|
43
|
+
```bash
|
|
44
|
+
poetry add mistralai
|
|
45
|
+
```
|
|
46
|
+
<!-- End SDK Installation [installation] -->
|
|
47
|
+
|
|
48
|
+
<!-- Start SDK Example Usage [usage] -->
|
|
49
|
+
## SDK Example Usage
|
|
50
|
+
|
|
51
|
+
### Create Chat Completions
|
|
52
|
+
|
|
53
|
+
This example shows how to create chat completions.
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
# Synchronous Example
|
|
57
|
+
from mistralai import Mistral
|
|
58
|
+
import os
|
|
59
|
+
|
|
60
|
+
s = Mistral(
|
|
61
|
+
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
res = s.chat.create(messages=[
|
|
66
|
+
{
|
|
67
|
+
"content": "Who is the best French painter? Answer in one short sentence.",
|
|
68
|
+
"role": "user",
|
|
69
|
+
},
|
|
70
|
+
], model="mistral-small-latest")
|
|
71
|
+
|
|
72
|
+
if res is not None:
|
|
73
|
+
# handle response
|
|
74
|
+
pass
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
</br>
|
|
78
|
+
|
|
79
|
+
The same SDK client can also be used to make asychronous requests by importing asyncio.
|
|
80
|
+
```python
|
|
81
|
+
# Asynchronous Example
|
|
82
|
+
import asyncio
|
|
83
|
+
from mistralai import Mistral
|
|
84
|
+
import os
|
|
85
|
+
|
|
86
|
+
async def main():
|
|
87
|
+
s = Mistral(
|
|
88
|
+
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
89
|
+
)
|
|
90
|
+
res = await s.chat.create_async(messages=[
|
|
91
|
+
{
|
|
92
|
+
"content": "Who is the best French painter? Answer in one short sentence.",
|
|
93
|
+
"role": "user",
|
|
94
|
+
},
|
|
95
|
+
], model="mistral-small-latest")
|
|
96
|
+
if res is not None:
|
|
97
|
+
# handle response
|
|
98
|
+
pass
|
|
99
|
+
|
|
100
|
+
asyncio.run(main())
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Upload a file
|
|
104
|
+
|
|
105
|
+
This example shows how to upload a file.
|
|
106
|
+
|
|
107
|
+
```python
|
|
108
|
+
# Synchronous Example
|
|
109
|
+
from mistralai import Mistral
|
|
110
|
+
import os
|
|
111
|
+
|
|
112
|
+
s = Mistral(
|
|
113
|
+
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
res = s.files.upload(file={
|
|
118
|
+
"file_name": "your_file_here",
|
|
119
|
+
"content": open("<file_path>", "rb"),
|
|
120
|
+
})
|
|
121
|
+
|
|
122
|
+
if res is not None:
|
|
123
|
+
# handle response
|
|
124
|
+
pass
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
</br>
|
|
128
|
+
|
|
129
|
+
The same SDK client can also be used to make asychronous requests by importing asyncio.
|
|
130
|
+
```python
|
|
131
|
+
# Asynchronous Example
|
|
132
|
+
import asyncio
|
|
133
|
+
from mistralai import Mistral
|
|
134
|
+
import os
|
|
135
|
+
|
|
136
|
+
async def main():
|
|
137
|
+
s = Mistral(
|
|
138
|
+
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
139
|
+
)
|
|
140
|
+
res = await s.files.upload_async(file={
|
|
141
|
+
"file_name": "your_file_here",
|
|
142
|
+
"content": open("<file_path>", "rb"),
|
|
143
|
+
})
|
|
144
|
+
if res is not None:
|
|
145
|
+
# handle response
|
|
146
|
+
pass
|
|
147
|
+
|
|
148
|
+
asyncio.run(main())
|
|
149
|
+
```
|
|
150
|
+
<!-- End SDK Example Usage [usage] -->
|
|
151
|
+
|
|
152
|
+
### Azure AI
|
|
153
|
+
|
|
154
|
+
TODO ADJUST LINKS
|
|
155
|
+
|
|
156
|
+
**Prerequisites**
|
|
157
|
+
Before you begin, ensure you have `AZUREAI_ENDPOINT` and an `AZURE_API_KEY`. To obtain these, you will need to deploy Mistral on Azure AI.
|
|
158
|
+
See [instructions for deploying Mistral on Azure AI here](https://docs.mistral.ai/deployment/cloud/azure/).
|
|
159
|
+
|
|
160
|
+
Here's a basic example to get you started. You can also run [the example in the `examples` directory](/examples/azure.py).
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
import asyncio
|
|
164
|
+
import os
|
|
165
|
+
|
|
166
|
+
from mistralai_azure import MistralAzure
|
|
167
|
+
|
|
168
|
+
client = MistralAzure(
|
|
169
|
+
azure_api_key=os.getenv("AZURE_API_KEY", ""),
|
|
170
|
+
azure_endpoint="your_azure_endpoint"
|
|
171
|
+
)
|
|
172
|
+
|
|
173
|
+
async def main() -> None:
|
|
174
|
+
res = await client.chat.create_async(
|
|
175
|
+
request={
|
|
176
|
+
"max_tokens": 100,
|
|
177
|
+
"temperature": 0.5,
|
|
178
|
+
"messages": [
|
|
179
|
+
{
|
|
180
|
+
"content": "Hello there!",
|
|
181
|
+
"role": "user"
|
|
182
|
+
}
|
|
183
|
+
]
|
|
184
|
+
}
|
|
185
|
+
)
|
|
186
|
+
print(res)
|
|
187
|
+
|
|
188
|
+
asyncio.run(main())
|
|
189
|
+
```
|
|
190
|
+
The documentation for the Azure SDK is available [GCP](packages/mistralai-azure/README.md).
|
|
191
|
+
|
|
192
|
+
### Google Cloud
|
|
193
|
+
|
|
194
|
+
TODO ADJUST LINKS
|
|
195
|
+
|
|
196
|
+
**Prerequisites**
|
|
197
|
+
|
|
198
|
+
Before you begin, you will need to create a Google Cloud project and enable the Mistral API. To do this, follow the instructions [here](https://docs.mistral.ai/deployment/cloud/google/).
|
|
199
|
+
|
|
200
|
+
To run this locally you will also need to ensure you are authenticated with Google Cloud. You can do this by running
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
gcloud auth application-default login
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**Step 1: Install**
|
|
207
|
+
|
|
208
|
+
Install the extras dependencies specific to Google Cloud:
|
|
209
|
+
|
|
210
|
+
```bash
|
|
211
|
+
pip install mistralai[gcp]
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
**Step 2: Example Usage**
|
|
215
|
+
|
|
216
|
+
Here's a basic example to get you started.
|
|
217
|
+
|
|
218
|
+
```python
|
|
219
|
+
import asyncio
|
|
220
|
+
from mistralai_gcp import MistralGoogleCloud
|
|
221
|
+
|
|
222
|
+
client = MistralGoogleCloud()
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
async def main() -> None:
|
|
226
|
+
res = await client.chat.create_async(
|
|
227
|
+
request={
|
|
228
|
+
"model": "mistral-small-2402",
|
|
229
|
+
"messages": [
|
|
230
|
+
{
|
|
231
|
+
"content": "Hello there!",
|
|
232
|
+
"role": "user"
|
|
233
|
+
}
|
|
234
|
+
]
|
|
235
|
+
}
|
|
236
|
+
)
|
|
237
|
+
print(res)
|
|
238
|
+
|
|
239
|
+
asyncio.run(main())
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
The documentation for the GCP SDK is available [GCP](packages/mistralai_gcp/README.md).
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
<!-- Start Available Resources and Operations [operations] -->
|
|
246
|
+
## Available Resources and Operations
|
|
247
|
+
|
|
248
|
+
### [models](docs/sdks/models/README.md)
|
|
249
|
+
|
|
250
|
+
* [list](docs/sdks/models/README.md#list) - List Models
|
|
251
|
+
* [retrieve](docs/sdks/models/README.md#retrieve) - Retrieve Model
|
|
252
|
+
* [delete](docs/sdks/models/README.md#delete) - Delete Model
|
|
253
|
+
* [update](docs/sdks/models/README.md#update) - Update Fine Tuned Model
|
|
254
|
+
* [archive](docs/sdks/models/README.md#archive) - Archive Fine Tuned Model
|
|
255
|
+
* [unarchive](docs/sdks/models/README.md#unarchive) - Unarchive Fine Tuned Model
|
|
256
|
+
|
|
257
|
+
### [files](docs/sdks/files/README.md)
|
|
258
|
+
|
|
259
|
+
* [upload](docs/sdks/files/README.md#upload) - Upload File
|
|
260
|
+
* [list](docs/sdks/files/README.md#list) - List Files
|
|
261
|
+
* [retrieve](docs/sdks/files/README.md#retrieve) - Retrieve File
|
|
262
|
+
* [delete](docs/sdks/files/README.md#delete) - Delete File
|
|
263
|
+
|
|
264
|
+
### [fine_tuning](docs/sdks/finetuning/README.md)
|
|
265
|
+
|
|
266
|
+
* [list_jobs](docs/sdks/finetuning/README.md#list_jobs) - Get Fine Tuning Jobs
|
|
267
|
+
* [create_job](docs/sdks/finetuning/README.md#create_job) - Create Fine Tuning Job
|
|
268
|
+
* [get_job](docs/sdks/finetuning/README.md#get_job) - Get Fine Tuning Job
|
|
269
|
+
* [cancel_job](docs/sdks/finetuning/README.md#cancel_job) - Cancel Fine Tuning Job
|
|
270
|
+
* [start_job](docs/sdks/finetuning/README.md#start_job) - Start Fine Tuning Job
|
|
271
|
+
|
|
272
|
+
### [chat](docs/sdks/chat/README.md)
|
|
273
|
+
|
|
274
|
+
* [create](docs/sdks/chat/README.md#create) - Chat Completion
|
|
275
|
+
* [stream](docs/sdks/chat/README.md#stream) - Stream chat completion
|
|
276
|
+
|
|
277
|
+
### [fim](docs/sdks/fim/README.md)
|
|
278
|
+
|
|
279
|
+
* [create](docs/sdks/fim/README.md#create) - Fim Completion
|
|
280
|
+
* [stream](docs/sdks/fim/README.md#stream) - Stream fim completion
|
|
281
|
+
|
|
282
|
+
### [embeddings](docs/sdks/embeddings/README.md)
|
|
283
|
+
|
|
284
|
+
* [create](docs/sdks/embeddings/README.md#create) - Embeddings
|
|
285
|
+
<!-- End Available Resources and Operations [operations] -->
|
|
286
|
+
|
|
287
|
+
<!-- Start Server-sent event streaming [eventstream] -->
|
|
288
|
+
## Server-sent event streaming
|
|
289
|
+
|
|
290
|
+
[Server-sent events][mdn-sse] are used to stream content from certain
|
|
291
|
+
operations. These operations will expose the stream as [Generator][generator] that
|
|
292
|
+
can be consumed using a simple `for` loop. The loop will
|
|
293
|
+
terminate when the server no longer has any events to send and closes the
|
|
294
|
+
underlying connection.
|
|
295
|
+
|
|
296
|
+
```python
|
|
297
|
+
from mistralai import Mistral
|
|
298
|
+
import os
|
|
299
|
+
|
|
300
|
+
s = Mistral(
|
|
301
|
+
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
302
|
+
)
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
res = s.chat.stream(messages=[
|
|
306
|
+
{
|
|
307
|
+
"content": "Who is the best French painter? Answer in one short sentence.",
|
|
308
|
+
"role": "user",
|
|
309
|
+
},
|
|
310
|
+
], model="mistral-small-latest")
|
|
311
|
+
|
|
312
|
+
if res is not None:
|
|
313
|
+
for event in res:
|
|
314
|
+
# handle event
|
|
315
|
+
print(event, flush=True)
|
|
316
|
+
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
[mdn-sse]: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events
|
|
320
|
+
[generator]: https://wiki.python.org/moin/Generators
|
|
321
|
+
<!-- End Server-sent event streaming [eventstream] -->
|
|
322
|
+
|
|
323
|
+
<!-- Start File uploads [file-upload] -->
|
|
324
|
+
## File uploads
|
|
325
|
+
|
|
326
|
+
Certain SDK methods accept file objects as part of a request body or multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.
|
|
327
|
+
|
|
328
|
+
> [!TIP]
|
|
329
|
+
>
|
|
330
|
+
> For endpoints that handle file uploads bytes arrays can also be used. However, using streams is recommended for large files.
|
|
331
|
+
>
|
|
332
|
+
|
|
333
|
+
```python
|
|
334
|
+
from mistralai import Mistral
|
|
335
|
+
import os
|
|
336
|
+
|
|
337
|
+
s = Mistral(
|
|
338
|
+
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
339
|
+
)
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
res = s.files.upload(file={
|
|
343
|
+
"file_name": "your_file_here",
|
|
344
|
+
"content": open("<file_path>", "rb"),
|
|
345
|
+
})
|
|
346
|
+
|
|
347
|
+
if res is not None:
|
|
348
|
+
# handle response
|
|
349
|
+
pass
|
|
350
|
+
|
|
351
|
+
```
|
|
352
|
+
<!-- End File uploads [file-upload] -->
|
|
353
|
+
|
|
354
|
+
<!-- Start Retries [retries] -->
|
|
355
|
+
## Retries
|
|
356
|
+
|
|
357
|
+
Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.
|
|
358
|
+
|
|
359
|
+
To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call:
|
|
360
|
+
```python
|
|
361
|
+
from mistral.utils import BackoffStrategy, RetryConfig
|
|
362
|
+
from mistralai import Mistral
|
|
363
|
+
import os
|
|
364
|
+
|
|
365
|
+
s = Mistral(
|
|
366
|
+
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
367
|
+
)
|
|
368
|
+
|
|
369
|
+
|
|
370
|
+
res = s.models.list(,
|
|
371
|
+
RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
|
|
372
|
+
|
|
373
|
+
if res is not None:
|
|
374
|
+
# handle response
|
|
375
|
+
pass
|
|
376
|
+
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
If you'd like to override the default retry strategy for all operations that support retries, you can use the `retry_config` optional parameter when initializing the SDK:
|
|
380
|
+
```python
|
|
381
|
+
from mistral.utils import BackoffStrategy, RetryConfig
|
|
382
|
+
from mistralai import Mistral
|
|
383
|
+
import os
|
|
384
|
+
|
|
385
|
+
s = Mistral(
|
|
386
|
+
retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
|
|
387
|
+
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
388
|
+
)
|
|
389
|
+
|
|
390
|
+
|
|
391
|
+
res = s.models.list()
|
|
392
|
+
|
|
393
|
+
if res is not None:
|
|
394
|
+
# handle response
|
|
395
|
+
pass
|
|
396
|
+
|
|
397
|
+
```
|
|
398
|
+
<!-- End Retries [retries] -->
|
|
399
|
+
|
|
400
|
+
<!-- Start Error Handling [errors] -->
|
|
401
|
+
## Error Handling
|
|
402
|
+
|
|
403
|
+
Handling errors in this SDK should largely match your expectations. All operations return a response object or raise an error. If Error objects are specified in your OpenAPI Spec, the SDK will raise the appropriate Error type.
|
|
404
|
+
|
|
405
|
+
| Error Object | Status Code | Content Type |
|
|
406
|
+
| -------------------------- | -------------------------- | -------------------------- |
|
|
407
|
+
| models.HTTPValidationError | 422 | application/json |
|
|
408
|
+
| models.SDKError | 4xx-5xx | */* |
|
|
409
|
+
|
|
410
|
+
### Example
|
|
411
|
+
|
|
412
|
+
```python
|
|
413
|
+
from mistralai import Mistral, models
|
|
414
|
+
import os
|
|
415
|
+
|
|
416
|
+
s = Mistral(
|
|
417
|
+
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
418
|
+
)
|
|
419
|
+
|
|
420
|
+
res = None
|
|
421
|
+
try:
|
|
422
|
+
res = s.models.list()
|
|
423
|
+
|
|
424
|
+
except models.HTTPValidationError as e:
|
|
425
|
+
# handle exception
|
|
426
|
+
raise(e)
|
|
427
|
+
except models.SDKError as e:
|
|
428
|
+
# handle exception
|
|
429
|
+
raise(e)
|
|
430
|
+
|
|
431
|
+
if res is not None:
|
|
432
|
+
# handle response
|
|
433
|
+
pass
|
|
434
|
+
|
|
435
|
+
```
|
|
436
|
+
<!-- End Error Handling [errors] -->
|
|
437
|
+
|
|
438
|
+
<!-- Start Server Selection [server] -->
|
|
439
|
+
## Server Selection
|
|
440
|
+
|
|
441
|
+
### Select Server by Name
|
|
442
|
+
|
|
443
|
+
You can override the default server globally by passing a server name to the `server: str` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the names associated with the available servers:
|
|
444
|
+
|
|
445
|
+
| Name | Server | Variables |
|
|
446
|
+
| ----- | ------ | --------- |
|
|
447
|
+
| `prod` | `https://api.mistral.ai` | None |
|
|
448
|
+
|
|
449
|
+
#### Example
|
|
450
|
+
|
|
451
|
+
```python
|
|
452
|
+
from mistralai import Mistral
|
|
453
|
+
import os
|
|
454
|
+
|
|
455
|
+
s = Mistral(
|
|
456
|
+
server="prod",
|
|
457
|
+
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
458
|
+
)
|
|
459
|
+
|
|
460
|
+
|
|
461
|
+
res = s.models.list()
|
|
462
|
+
|
|
463
|
+
if res is not None:
|
|
464
|
+
# handle response
|
|
465
|
+
pass
|
|
466
|
+
|
|
467
|
+
```
|
|
468
|
+
|
|
469
|
+
|
|
470
|
+
### Override Server URL Per-Client
|
|
471
|
+
|
|
472
|
+
The default server can also be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
|
|
473
|
+
```python
|
|
474
|
+
from mistralai import Mistral
|
|
475
|
+
import os
|
|
476
|
+
|
|
477
|
+
s = Mistral(
|
|
478
|
+
server_url="https://api.mistral.ai",
|
|
479
|
+
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
480
|
+
)
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
res = s.models.list()
|
|
484
|
+
|
|
485
|
+
if res is not None:
|
|
486
|
+
# handle response
|
|
487
|
+
pass
|
|
488
|
+
|
|
489
|
+
```
|
|
490
|
+
<!-- End Server Selection [server] -->
|
|
491
|
+
|
|
492
|
+
<!-- Start Custom HTTP Client [http-client] -->
|
|
493
|
+
## Custom HTTP Client
|
|
494
|
+
|
|
495
|
+
The Python SDK makes API calls using the [httpx](https://www.python-httpx.org/) HTTP library. In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance.
|
|
496
|
+
Depending on whether you are using the sync or async version of the SDK, you can pass an instance of `HttpClient` or `AsyncHttpClient` respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls.
|
|
497
|
+
This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of `httpx.Client` or `httpx.AsyncClient` directly.
|
|
498
|
+
|
|
499
|
+
For example, you could specify a header for every request that this sdk makes as follows:
|
|
500
|
+
```python
|
|
501
|
+
from mistralai import Mistral
|
|
502
|
+
import httpx
|
|
503
|
+
|
|
504
|
+
http_client = httpx.Client(headers={"x-custom-header": "someValue"})
|
|
505
|
+
s = Mistral(client=http_client)
|
|
506
|
+
```
|
|
507
|
+
|
|
508
|
+
or you could wrap the client with your own custom logic:
|
|
509
|
+
```python
|
|
510
|
+
from mistralai import Mistral
|
|
511
|
+
from mistralai.httpclient import AsyncHttpClient
|
|
512
|
+
import httpx
|
|
513
|
+
|
|
514
|
+
class CustomClient(AsyncHttpClient):
|
|
515
|
+
client: AsyncHttpClient
|
|
516
|
+
|
|
517
|
+
def __init__(self, client: AsyncHttpClient):
|
|
518
|
+
self.client = client
|
|
519
|
+
|
|
520
|
+
async def send(
|
|
521
|
+
self,
|
|
522
|
+
request: httpx.Request,
|
|
523
|
+
*,
|
|
524
|
+
stream: bool = False,
|
|
525
|
+
auth: Union[
|
|
526
|
+
httpx._types.AuthTypes, httpx._client.UseClientDefault, None
|
|
527
|
+
] = httpx.USE_CLIENT_DEFAULT,
|
|
528
|
+
follow_redirects: Union[
|
|
529
|
+
bool, httpx._client.UseClientDefault
|
|
530
|
+
] = httpx.USE_CLIENT_DEFAULT,
|
|
531
|
+
) -> httpx.Response:
|
|
532
|
+
request.headers["Client-Level-Header"] = "added by client"
|
|
533
|
+
|
|
534
|
+
return await self.client.send(
|
|
535
|
+
request, stream=stream, auth=auth, follow_redirects=follow_redirects
|
|
536
|
+
)
|
|
537
|
+
|
|
538
|
+
def build_request(
|
|
539
|
+
self,
|
|
540
|
+
method: str,
|
|
541
|
+
url: httpx._types.URLTypes,
|
|
542
|
+
*,
|
|
543
|
+
content: Optional[httpx._types.RequestContent] = None,
|
|
544
|
+
data: Optional[httpx._types.RequestData] = None,
|
|
545
|
+
files: Optional[httpx._types.RequestFiles] = None,
|
|
546
|
+
json: Optional[Any] = None,
|
|
547
|
+
params: Optional[httpx._types.QueryParamTypes] = None,
|
|
548
|
+
headers: Optional[httpx._types.HeaderTypes] = None,
|
|
549
|
+
cookies: Optional[httpx._types.CookieTypes] = None,
|
|
550
|
+
timeout: Union[
|
|
551
|
+
httpx._types.TimeoutTypes, httpx._client.UseClientDefault
|
|
552
|
+
] = httpx.USE_CLIENT_DEFAULT,
|
|
553
|
+
extensions: Optional[httpx._types.RequestExtensions] = None,
|
|
554
|
+
) -> httpx.Request:
|
|
555
|
+
return self.client.build_request(
|
|
556
|
+
method,
|
|
557
|
+
url,
|
|
558
|
+
content=content,
|
|
559
|
+
data=data,
|
|
560
|
+
files=files,
|
|
561
|
+
json=json,
|
|
562
|
+
params=params,
|
|
563
|
+
headers=headers,
|
|
564
|
+
cookies=cookies,
|
|
565
|
+
timeout=timeout,
|
|
566
|
+
extensions=extensions,
|
|
567
|
+
)
|
|
568
|
+
|
|
569
|
+
s = Mistral(async_client=CustomClient(httpx.AsyncClient()))
|
|
570
|
+
```
|
|
571
|
+
<!-- End Custom HTTP Client [http-client] -->
|
|
572
|
+
|
|
573
|
+
<!-- Start Authentication [security] -->
|
|
574
|
+
## Authentication
|
|
575
|
+
|
|
576
|
+
### Per-Client Security Schemes
|
|
577
|
+
|
|
578
|
+
This SDK supports the following security scheme globally:
|
|
579
|
+
|
|
580
|
+
| Name | Type | Scheme |
|
|
581
|
+
| ----------- | ----------- | ----------- |
|
|
582
|
+
| `api_key` | http | HTTP Bearer |
|
|
583
|
+
|
|
584
|
+
To authenticate with the API the `api_key` parameter must be set when initializing the SDK client instance. For example:
|
|
585
|
+
```python
|
|
586
|
+
from mistralai import Mistral
|
|
587
|
+
import os
|
|
588
|
+
|
|
589
|
+
s = Mistral(
|
|
590
|
+
api_key=os.getenv("MISTRAL_API_KEY", ""),
|
|
591
|
+
)
|
|
592
|
+
|
|
593
|
+
|
|
594
|
+
res = s.models.list()
|
|
595
|
+
|
|
596
|
+
if res is not None:
|
|
597
|
+
# handle response
|
|
598
|
+
pass
|
|
599
|
+
|
|
600
|
+
```
|
|
601
|
+
<!-- End Authentication [security] -->
|
|
602
|
+
## Providers Support
|
|
603
|
+
|
|
604
|
+
We also provide provider specific SDK for:
|
|
605
|
+
|
|
606
|
+
- [GCP](packages/mistralai_gcp/README.md)
|
|
607
|
+
- [Azure](packages/mistralai_azure/README.md)
|
|
608
|
+
|
|
609
|
+
|
|
610
|
+
<!-- Placeholder for Future Speakeasy SDK Sections -->
|
|
611
|
+
|
|
612
|
+
# Development
|
|
613
|
+
|
|
614
|
+
## Maturity
|
|
615
|
+
|
|
616
|
+
This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage
|
|
617
|
+
to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally
|
|
618
|
+
looking for the latest version.
|
|
619
|
+
|
|
620
|
+
## Contributions
|
|
621
|
+
|
|
622
|
+
While we value open-source contributions to this SDK, this library is generated programmatically. Any manual changes added to internal files will be overwritten on the next generation.
|
|
623
|
+
We look forward to hearing your feedback. Feel free to open a PR or an issue with a proof of concept and we'll do our best to include it in a future release.
|
|
624
|
+
|
|
625
|
+
### SDK Created by [Speakeasy](https://docs.speakeasyapi.dev/docs/using-speakeasy/client-sdks)
|
|
626
|
+
|