mistralai 1.0.2__py3-none-any.whl → 1.1.0__py3-none-any.whl

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.
Files changed (199) hide show
  1. mistralai/_hooks/sdkhooks.py +23 -4
  2. mistralai/_hooks/types.py +27 -9
  3. mistralai/agents.py +286 -150
  4. mistralai/basesdk.py +90 -5
  5. mistralai/chat.py +260 -144
  6. mistralai/embeddings.py +73 -53
  7. mistralai/files.py +252 -192
  8. mistralai/fim.py +174 -110
  9. mistralai/fine_tuning.py +3 -2
  10. mistralai/jobs.py +372 -263
  11. mistralai/models/__init__.py +499 -46
  12. mistralai/models/agentscompletionrequest.py +47 -11
  13. mistralai/models/agentscompletionstreamrequest.py +49 -11
  14. mistralai/models/archiveftmodelout.py +6 -2
  15. mistralai/models/assistantmessage.py +11 -4
  16. mistralai/models/{modelcard.py → basemodelcard.py} +37 -14
  17. mistralai/models/chatcompletionchoice.py +4 -2
  18. mistralai/models/chatcompletionrequest.py +57 -11
  19. mistralai/models/chatcompletionresponse.py +6 -2
  20. mistralai/models/chatcompletionstreamrequest.py +59 -11
  21. mistralai/models/checkpointout.py +3 -2
  22. mistralai/models/completionchunk.py +10 -3
  23. mistralai/models/completionevent.py +1 -2
  24. mistralai/models/completionresponsestreamchoice.py +13 -5
  25. mistralai/models/contentchunk.py +13 -10
  26. mistralai/models/delete_model_v1_models_model_id_deleteop.py +4 -3
  27. mistralai/models/deletefileout.py +3 -2
  28. mistralai/models/deletemodelout.py +3 -2
  29. mistralai/models/deltamessage.py +9 -4
  30. mistralai/models/detailedjobout.py +59 -7
  31. mistralai/models/embeddingrequest.py +9 -4
  32. mistralai/models/embeddingresponse.py +5 -2
  33. mistralai/models/embeddingresponsedata.py +3 -2
  34. mistralai/models/eventout.py +9 -4
  35. mistralai/models/files_api_routes_delete_fileop.py +4 -3
  36. mistralai/models/files_api_routes_retrieve_fileop.py +4 -3
  37. mistralai/models/files_api_routes_upload_fileop.py +27 -8
  38. mistralai/models/fileschema.py +26 -5
  39. mistralai/models/fimcompletionrequest.py +26 -5
  40. mistralai/models/fimcompletionresponse.py +6 -2
  41. mistralai/models/fimcompletionstreamrequest.py +26 -5
  42. mistralai/models/finetuneablemodel.py +7 -1
  43. mistralai/models/ftmodelcapabilitiesout.py +4 -2
  44. mistralai/models/ftmodelcard.py +103 -0
  45. mistralai/models/ftmodelout.py +32 -6
  46. mistralai/models/function.py +3 -2
  47. mistralai/models/functioncall.py +2 -2
  48. mistralai/models/functionname.py +17 -0
  49. mistralai/models/githubrepositoryin.py +15 -4
  50. mistralai/models/githubrepositoryout.py +15 -4
  51. mistralai/models/httpvalidationerror.py +2 -2
  52. mistralai/models/imageurl.py +48 -0
  53. mistralai/models/imageurlchunk.py +32 -0
  54. mistralai/models/jobin.py +22 -5
  55. mistralai/models/jobmetadataout.py +31 -6
  56. mistralai/models/jobout.py +55 -7
  57. mistralai/models/jobs_api_routes_fine_tuning_archive_fine_tuned_modelop.py +4 -3
  58. mistralai/models/jobs_api_routes_fine_tuning_cancel_fine_tuning_jobop.py +4 -3
  59. mistralai/models/jobs_api_routes_fine_tuning_create_fine_tuning_jobop.py +3 -2
  60. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobop.py +4 -3
  61. mistralai/models/jobs_api_routes_fine_tuning_get_fine_tuning_jobsop.py +83 -16
  62. mistralai/models/jobs_api_routes_fine_tuning_start_fine_tuning_jobop.py +4 -3
  63. mistralai/models/jobs_api_routes_fine_tuning_unarchive_fine_tuned_modelop.py +4 -3
  64. mistralai/models/jobs_api_routes_fine_tuning_update_fine_tuned_modelop.py +9 -4
  65. mistralai/models/jobsout.py +6 -2
  66. mistralai/models/legacyjobmetadataout.py +45 -6
  67. mistralai/models/listfilesout.py +2 -2
  68. mistralai/models/metricout.py +11 -6
  69. mistralai/models/modelcapabilities.py +7 -2
  70. mistralai/models/modellist.py +21 -7
  71. mistralai/models/responseformat.py +6 -7
  72. mistralai/models/responseformats.py +8 -0
  73. mistralai/models/retrieve_model_v1_models_model_id_getop.py +24 -5
  74. mistralai/models/retrievefileout.py +26 -5
  75. mistralai/models/security.py +12 -3
  76. mistralai/models/systemmessage.py +6 -5
  77. mistralai/models/textchunk.py +9 -4
  78. mistralai/models/tool.py +9 -8
  79. mistralai/models/toolcall.py +9 -7
  80. mistralai/models/toolchoice.py +29 -0
  81. mistralai/models/toolchoiceenum.py +7 -0
  82. mistralai/models/toolmessage.py +11 -4
  83. mistralai/models/tooltypes.py +8 -0
  84. mistralai/models/trainingfile.py +2 -2
  85. mistralai/models/trainingparameters.py +27 -6
  86. mistralai/models/trainingparametersin.py +29 -8
  87. mistralai/models/unarchiveftmodelout.py +6 -2
  88. mistralai/models/updateftmodelin.py +8 -4
  89. mistralai/models/uploadfileout.py +26 -5
  90. mistralai/models/usageinfo.py +3 -2
  91. mistralai/models/usermessage.py +6 -5
  92. mistralai/models/validationerror.py +3 -2
  93. mistralai/models/wandbintegration.py +14 -4
  94. mistralai/models/wandbintegrationout.py +13 -4
  95. mistralai/models_.py +392 -294
  96. mistralai/sdk.py +24 -19
  97. mistralai/sdkconfiguration.py +6 -8
  98. mistralai/utils/__init__.py +6 -1
  99. mistralai/utils/logger.py +4 -1
  100. mistralai/utils/retries.py +2 -1
  101. mistralai/utils/security.py +13 -6
  102. {mistralai-1.0.2.dist-info → mistralai-1.1.0.dist-info}/METADATA +103 -74
  103. mistralai-1.1.0.dist-info/RECORD +254 -0
  104. mistralai_azure/_hooks/sdkhooks.py +23 -4
  105. mistralai_azure/_hooks/types.py +27 -9
  106. mistralai_azure/basesdk.py +91 -6
  107. mistralai_azure/chat.py +252 -144
  108. mistralai_azure/models/__init__.py +157 -15
  109. mistralai_azure/models/assistantmessage.py +18 -5
  110. mistralai_azure/models/chatcompletionchoice.py +7 -3
  111. mistralai_azure/models/chatcompletionrequest.py +65 -12
  112. mistralai_azure/models/chatcompletionresponse.py +6 -2
  113. mistralai_azure/models/chatcompletionstreamrequest.py +67 -12
  114. mistralai_azure/models/completionchunk.py +10 -3
  115. mistralai_azure/models/completionevent.py +1 -2
  116. mistralai_azure/models/completionresponsestreamchoice.py +10 -4
  117. mistralai_azure/models/contentchunk.py +4 -11
  118. mistralai_azure/models/deltamessage.py +16 -5
  119. mistralai_azure/models/function.py +3 -2
  120. mistralai_azure/models/functioncall.py +2 -2
  121. mistralai_azure/models/functionname.py +17 -0
  122. mistralai_azure/models/httpvalidationerror.py +2 -2
  123. mistralai_azure/models/responseformat.py +6 -7
  124. mistralai_azure/models/responseformats.py +8 -0
  125. mistralai_azure/models/security.py +12 -3
  126. mistralai_azure/models/systemmessage.py +6 -5
  127. mistralai_azure/models/textchunk.py +9 -4
  128. mistralai_azure/models/tool.py +9 -8
  129. mistralai_azure/models/toolcall.py +9 -7
  130. mistralai_azure/models/toolchoice.py +29 -0
  131. mistralai_azure/models/toolchoiceenum.py +7 -0
  132. mistralai_azure/models/toolmessage.py +18 -5
  133. mistralai_azure/models/tooltypes.py +8 -0
  134. mistralai_azure/models/usageinfo.py +3 -2
  135. mistralai_azure/models/usermessage.py +6 -5
  136. mistralai_azure/models/validationerror.py +3 -2
  137. mistralai_azure/sdkconfiguration.py +6 -8
  138. mistralai_azure/utils/__init__.py +8 -3
  139. mistralai_azure/utils/forms.py +10 -9
  140. mistralai_azure/utils/headers.py +8 -8
  141. mistralai_azure/utils/logger.py +6 -0
  142. mistralai_azure/utils/queryparams.py +16 -14
  143. mistralai_azure/utils/retries.py +2 -1
  144. mistralai_azure/utils/security.py +12 -6
  145. mistralai_azure/utils/serializers.py +17 -8
  146. mistralai_azure/utils/url.py +13 -8
  147. mistralai_azure/utils/values.py +6 -0
  148. mistralai_gcp/_hooks/sdkhooks.py +23 -4
  149. mistralai_gcp/_hooks/types.py +27 -9
  150. mistralai_gcp/basesdk.py +91 -6
  151. mistralai_gcp/chat.py +252 -144
  152. mistralai_gcp/fim.py +166 -110
  153. mistralai_gcp/models/__init__.py +179 -17
  154. mistralai_gcp/models/assistantmessage.py +18 -5
  155. mistralai_gcp/models/chatcompletionchoice.py +7 -3
  156. mistralai_gcp/models/chatcompletionrequest.py +62 -12
  157. mistralai_gcp/models/chatcompletionresponse.py +6 -2
  158. mistralai_gcp/models/chatcompletionstreamrequest.py +64 -12
  159. mistralai_gcp/models/completionchunk.py +10 -3
  160. mistralai_gcp/models/completionevent.py +1 -2
  161. mistralai_gcp/models/completionresponsestreamchoice.py +10 -4
  162. mistralai_gcp/models/contentchunk.py +4 -11
  163. mistralai_gcp/models/deltamessage.py +16 -5
  164. mistralai_gcp/models/fimcompletionrequest.py +33 -6
  165. mistralai_gcp/models/fimcompletionresponse.py +6 -2
  166. mistralai_gcp/models/fimcompletionstreamrequest.py +33 -6
  167. mistralai_gcp/models/function.py +3 -2
  168. mistralai_gcp/models/functioncall.py +2 -2
  169. mistralai_gcp/models/functionname.py +17 -0
  170. mistralai_gcp/models/httpvalidationerror.py +2 -2
  171. mistralai_gcp/models/responseformat.py +6 -7
  172. mistralai_gcp/models/responseformats.py +8 -0
  173. mistralai_gcp/models/security.py +12 -3
  174. mistralai_gcp/models/systemmessage.py +6 -5
  175. mistralai_gcp/models/textchunk.py +9 -4
  176. mistralai_gcp/models/tool.py +9 -8
  177. mistralai_gcp/models/toolcall.py +9 -7
  178. mistralai_gcp/models/toolchoice.py +29 -0
  179. mistralai_gcp/models/toolchoiceenum.py +7 -0
  180. mistralai_gcp/models/toolmessage.py +18 -5
  181. mistralai_gcp/models/tooltypes.py +8 -0
  182. mistralai_gcp/models/usageinfo.py +3 -2
  183. mistralai_gcp/models/usermessage.py +6 -5
  184. mistralai_gcp/models/validationerror.py +3 -2
  185. mistralai_gcp/sdk.py +14 -10
  186. mistralai_gcp/sdkconfiguration.py +6 -8
  187. mistralai_gcp/utils/__init__.py +8 -3
  188. mistralai_gcp/utils/forms.py +10 -9
  189. mistralai_gcp/utils/headers.py +8 -8
  190. mistralai_gcp/utils/logger.py +6 -0
  191. mistralai_gcp/utils/queryparams.py +16 -14
  192. mistralai_gcp/utils/retries.py +2 -1
  193. mistralai_gcp/utils/security.py +12 -6
  194. mistralai_gcp/utils/serializers.py +17 -8
  195. mistralai_gcp/utils/url.py +13 -8
  196. mistralai_gcp/utils/values.py +6 -0
  197. mistralai-1.0.2.dist-info/RECORD +0 -236
  198. {mistralai-1.0.2.dist-info → mistralai-1.1.0.dist-info}/LICENSE +0 -0
  199. {mistralai-1.0.2.dist-info → mistralai-1.1.0.dist-info}/WHEEL +0 -0
mistralai/sdk.py CHANGED
@@ -18,8 +18,10 @@ from mistralai.models_ import Models
18
18
  from mistralai.types import OptionalNullable, UNSET
19
19
  from typing import Any, Callable, Dict, Optional, Union
20
20
 
21
+
21
22
  class Mistral(BaseSDK):
22
23
  r"""Mistral AI API: Our Chat Completion and Embeddings APIs specification. Create your account on [La Plateforme](https://console.mistral.ai) to get access and read the [docs](https://docs.mistral.ai) to learn how to use it."""
24
+
23
25
  models: Models
24
26
  r"""Model Management API"""
25
27
  files: Files
@@ -33,6 +35,7 @@ class Mistral(BaseSDK):
33
35
  r"""Agents API."""
34
36
  embeddings: Embeddings
35
37
  r"""Embeddings API."""
38
+
36
39
  def __init__(
37
40
  self,
38
41
  api_key: Optional[Union[Optional[str], Callable[[], Optional[str]]]] = None,
@@ -43,7 +46,7 @@ class Mistral(BaseSDK):
43
46
  async_client: Optional[AsyncHttpClient] = None,
44
47
  retry_config: OptionalNullable[RetryConfig] = UNSET,
45
48
  timeout_ms: Optional[int] = None,
46
- debug_logger: Optional[Logger] = None
49
+ debug_logger: Optional[Logger] = None,
47
50
  ) -> None:
48
51
  r"""Instantiates the SDK configuring it with the provided parameters.
49
52
 
@@ -72,33 +75,37 @@ class Mistral(BaseSDK):
72
75
  assert issubclass(
73
76
  type(async_client), AsyncHttpClient
74
77
  ), "The provided async_client must implement the AsyncHttpClient protocol."
75
-
78
+
76
79
  security: Any = None
77
80
  if callable(api_key):
78
- security = lambda: models.Security(api_key = api_key()) # pylint: disable=unnecessary-lambda-assignment
81
+ security = lambda: models.Security(api_key=api_key()) # pylint: disable=unnecessary-lambda-assignment
79
82
  else:
80
- security = models.Security(api_key = api_key)
83
+ security = models.Security(api_key=api_key)
81
84
 
82
85
  if server_url is not None:
83
86
  if url_params is not None:
84
87
  server_url = utils.template_url(server_url, url_params)
85
-
86
-
87
- BaseSDK.__init__(self, SDKConfiguration(
88
- client=client,
89
- async_client=async_client,
90
- security=security,
91
- server_url=server_url,
92
- server=server,
93
- retry_config=retry_config,
94
- timeout_ms=timeout_ms,
95
- debug_logger=debug_logger
96
- ))
88
+
89
+ BaseSDK.__init__(
90
+ self,
91
+ SDKConfiguration(
92
+ client=client,
93
+ async_client=async_client,
94
+ security=security,
95
+ server_url=server_url,
96
+ server=server,
97
+ retry_config=retry_config,
98
+ timeout_ms=timeout_ms,
99
+ debug_logger=debug_logger,
100
+ ),
101
+ )
97
102
 
98
103
  hooks = SDKHooks()
99
104
 
100
105
  current_server_url, *_ = self.sdk_configuration.get_server_details()
101
- server_url, self.sdk_configuration.client = hooks.sdk_init(current_server_url, self.sdk_configuration.client)
106
+ server_url, self.sdk_configuration.client = hooks.sdk_init(
107
+ current_server_url, self.sdk_configuration.client
108
+ )
102
109
  if current_server_url != server_url:
103
110
  self.sdk_configuration.server_url = server_url
104
111
 
@@ -107,7 +114,6 @@ class Mistral(BaseSDK):
107
114
 
108
115
  self._init_sdks()
109
116
 
110
-
111
117
  def _init_sdks(self):
112
118
  self.models = Models(self.sdk_configuration)
113
119
  self.files = Files(self.sdk_configuration)
@@ -116,4 +122,3 @@ class Mistral(BaseSDK):
116
122
  self.fim = Fim(self.sdk_configuration)
117
123
  self.agents = Agents(self.sdk_configuration)
118
124
  self.embeddings = Embeddings(self.sdk_configuration)
119
-
@@ -1,6 +1,5 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
-
4
3
  from ._hooks import SDKHooks
5
4
  from .httpclient import AsyncHttpClient, HttpClient
6
5
  from .utils import Logger, RetryConfig, remove_suffix
@@ -14,7 +13,7 @@ from typing import Callable, Dict, Optional, Tuple, Union
14
13
  SERVER_PROD = "prod"
15
14
  r"""Production server"""
16
15
  SERVERS = {
17
- SERVER_PROD: "https://api.mistral.ai",
16
+ SERVER_PROD: "https://api.mistral.ai",
18
17
  }
19
18
  """Contains the list of servers available to the SDK"""
20
19
 
@@ -24,14 +23,14 @@ class SDKConfiguration:
24
23
  client: HttpClient
25
24
  async_client: AsyncHttpClient
26
25
  debug_logger: Logger
27
- security: Optional[Union[models.Security,Callable[[], models.Security]]] = None
26
+ security: Optional[Union[models.Security, Callable[[], models.Security]]] = None
28
27
  server_url: Optional[str] = ""
29
28
  server: Optional[str] = ""
30
29
  language: str = "python"
31
30
  openapi_doc_version: str = "0.0.2"
32
- sdk_version: str = "1.0.2"
33
- gen_version: str = "2.402.5"
34
- user_agent: str = "speakeasy-sdk/python 1.0.2 2.402.5 0.0.2 mistralai"
31
+ sdk_version: str = "1.1.0"
32
+ gen_version: str = "2.415.8"
33
+ user_agent: str = "speakeasy-sdk/python 1.1.0 2.415.8 0.0.2 mistralai"
35
34
  retry_config: OptionalNullable[RetryConfig] = Field(default_factory=lambda: UNSET)
36
35
  timeout_ms: Optional[int] = None
37
36
 
@@ -45,10 +44,9 @@ class SDKConfiguration:
45
44
  self.server = SERVER_PROD
46
45
 
47
46
  if self.server not in SERVERS:
48
- raise ValueError(f"Invalid server \"{self.server}\"")
47
+ raise ValueError(f'Invalid server "{self.server}"')
49
48
 
50
49
  return SERVERS[self.server], {}
51
50
 
52
-
53
51
  def get_hooks(self) -> SDKHooks:
54
52
  return self._hooks
@@ -34,7 +34,12 @@ from .serializers import (
34
34
  validate_open_enum,
35
35
  )
36
36
  from .url import generate_url, template_url, remove_suffix
37
- from .values import get_global_from_env, match_content_type, match_status_codes, match_response
37
+ from .values import (
38
+ get_global_from_env,
39
+ match_content_type,
40
+ match_status_codes,
41
+ match_response,
42
+ )
38
43
  from .logger import Logger, get_body_content, get_default_logger
39
44
 
40
45
  __all__ = [
mistralai/utils/logger.py CHANGED
@@ -5,20 +5,23 @@ import logging
5
5
  import os
6
6
  from typing import Any, Protocol
7
7
 
8
+
8
9
  class Logger(Protocol):
9
10
  def debug(self, msg: str, *args: Any, **kwargs: Any) -> None:
10
11
  pass
11
12
 
13
+
12
14
  class NoOpLogger:
13
15
  def debug(self, msg: str, *args: Any, **kwargs: Any) -> None:
14
16
  pass
15
17
 
18
+
16
19
  def get_body_content(req: httpx.Request) -> str:
17
20
  return "<streaming body>" if not hasattr(req, "_content") else str(req.content)
18
21
 
22
+
19
23
  def get_default_logger() -> Logger:
20
24
  if os.getenv("MISTRAL_DEBUG"):
21
25
  logging.basicConfig(level=logging.DEBUG)
22
26
  return logging.getLogger("mistralai")
23
27
  return NoOpLogger()
24
-
@@ -1,5 +1,6 @@
1
1
  """Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT."""
2
2
 
3
+ import asyncio
3
4
  import random
4
5
  import time
5
6
  from typing import List
@@ -212,5 +213,5 @@ async def retry_with_backoff_async(
212
213
  raise
213
214
  sleep = (initial_interval / 1000) * exponent**retries + random.uniform(0, 1)
214
215
  sleep = min(sleep, max_interval / 1000)
215
- time.sleep(sleep)
216
+ await asyncio.sleep(sleep)
216
217
  retries += 1
@@ -44,8 +44,10 @@ def get_security(security: Any) -> Tuple[Dict[str, str], Dict[str, List[str]]]:
44
44
  _parse_security_option(headers, query_params, value)
45
45
  return headers, query_params
46
46
  if metadata.scheme:
47
- # Special case for basic auth which could be a flattened model
48
- if metadata.sub_type == "basic" and not isinstance(value, BaseModel):
47
+ # Special case for basic auth or custom auth which could be a flattened model
48
+ if metadata.sub_type in ["basic", "custom"] and not isinstance(
49
+ value, BaseModel
50
+ ):
49
51
  _parse_security_scheme(headers, query_params, metadata, name, security)
50
52
  else:
51
53
  _parse_security_scheme(headers, query_params, metadata, name, value)
@@ -64,7 +66,7 @@ def get_security_from_env(security: Any, security_class: Any) -> Optional[BaseMo
64
66
 
65
67
  if os.getenv("MISTRAL_API_KEY"):
66
68
  security_dict["api_key"] = os.getenv("MISTRAL_API_KEY")
67
-
69
+
68
70
  return security_class(**security_dict) if security_dict else None
69
71
 
70
72
 
@@ -97,9 +99,12 @@ def _parse_security_scheme(
97
99
  sub_type = scheme_metadata.sub_type
98
100
 
99
101
  if isinstance(scheme, BaseModel):
100
- if scheme_type == "http" and sub_type == "basic":
101
- _parse_basic_auth_scheme(headers, scheme)
102
- return
102
+ if scheme_type == "http":
103
+ if sub_type == "basic":
104
+ _parse_basic_auth_scheme(headers, scheme)
105
+ return
106
+ if sub_type == "custom":
107
+ return
103
108
 
104
109
  scheme_fields: Dict[str, FieldInfo] = scheme.__class__.model_fields
105
110
  for name in scheme_fields:
@@ -148,6 +153,8 @@ def _parse_security_scheme_value(
148
153
  elif scheme_type == "http":
149
154
  if sub_type == "bearer":
150
155
  headers[header_name] = _apply_bearer(value)
156
+ elif sub_type == "custom":
157
+ return
151
158
  else:
152
159
  raise ValueError("sub type {sub_type} not supported")
153
160
  else:
@@ -1,7 +1,8 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mistralai
3
- Version: 1.0.2
3
+ Version: 1.1.0
4
4
  Summary: Python Client SDK for the Mistral AI API.
5
+ Home-page: https://github.com/mistralai/client-python.git
5
6
  Author: Mistral
6
7
  Requires-Python: >=3.8,<4.0
7
8
  Classifier: Programming Language :: Python :: 3
@@ -11,20 +12,22 @@ Classifier: Programming Language :: Python :: 3.10
11
12
  Classifier: Programming Language :: Python :: 3.11
12
13
  Classifier: Programming Language :: Python :: 3.12
13
14
  Provides-Extra: gcp
14
- Requires-Dist: google-auth (>=2.31.0,<3.0.0) ; extra == "gcp"
15
+ Requires-Dist: eval-type-backport (>=0.2.0,<0.3.0)
16
+ Requires-Dist: google-auth (==2.27.0) ; extra == "gcp"
15
17
  Requires-Dist: httpx (>=0.27.0,<0.28.0)
16
18
  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: pydantic (>=2.9.0,<3.0.0)
20
+ Requires-Dist: python-dateutil (==2.8.2)
19
21
  Requires-Dist: requests (>=2.32.3,<3.0.0) ; extra == "gcp"
20
22
  Requires-Dist: typing-inspect (>=0.9.0,<0.10.0)
23
+ Project-URL: Repository, https://github.com/mistralai/client-python.git
21
24
  Description-Content-Type: text/markdown
22
25
 
23
26
  # Mistral Python Client
24
27
 
25
28
  ## Migration warning
26
29
 
27
- This documentation is for Mistral AI SDK v1. You can find more details on how to migrate from v0 to v1 [here](MIGRATION.md)
30
+ This documentation is for Mistral AI SDK v1. You can find more details on how to migrate from v0 to v1 [here](https://github.com/mistralai/client-python/blob/master/MIGRATION.md)
28
31
 
29
32
  ## API Key Setup
30
33
 
@@ -41,15 +44,46 @@ $ echo 'export MISTRAL_API_KEY=[your_key_here]' >> ~/.zshenv
41
44
  $ source ~/.zshenv
42
45
  ```
43
46
 
47
+ <!-- Start Summary [summary] -->
48
+ ## Summary
49
+
50
+ Mistral AI API: Our Chat Completion and Embeddings APIs specification. Create your account on [La Plateforme](https://console.mistral.ai) to get access and read the [docs](https://docs.mistral.ai) to learn how to use it.
51
+ <!-- End Summary [summary] -->
52
+
53
+ <!-- Start Table of Contents [toc] -->
54
+ ## Table of Contents
55
+
56
+ * [SDK Installation](https://github.com/mistralai/client-python/blob/master/#sdk-installation)
57
+ * [IDE Support](https://github.com/mistralai/client-python/blob/master/#ide-support)
58
+ * [SDK Example Usage](https://github.com/mistralai/client-python/blob/master/#sdk-example-usage)
59
+ * [Available Resources and Operations](https://github.com/mistralai/client-python/blob/master/#available-resources-and-operations)
60
+ * [Server-sent event streaming](https://github.com/mistralai/client-python/blob/master/#server-sent-event-streaming)
61
+ * [File uploads](https://github.com/mistralai/client-python/blob/master/#file-uploads)
62
+ * [Retries](https://github.com/mistralai/client-python/blob/master/#retries)
63
+ * [Error Handling](https://github.com/mistralai/client-python/blob/master/#error-handling)
64
+ * [Server Selection](https://github.com/mistralai/client-python/blob/master/#server-selection)
65
+ * [Custom HTTP Client](https://github.com/mistralai/client-python/blob/master/#custom-http-client)
66
+ * [Authentication](https://github.com/mistralai/client-python/blob/master/#authentication)
67
+ * [Debugging](https://github.com/mistralai/client-python/blob/master/#debugging)
68
+ <!-- End Table of Contents [toc] -->
69
+
44
70
  <!-- Start SDK Installation [installation] -->
45
71
  ## SDK Installation
46
72
 
47
- PIP
73
+ The SDK can be installed with either *pip* or *poetry* package managers.
74
+
75
+ ### PIP
76
+
77
+ *PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.
78
+
48
79
  ```bash
49
80
  pip install mistralai
50
81
  ```
51
82
 
52
- Poetry
83
+ ### Poetry
84
+
85
+ *Poetry* is a modern tool that simplifies dependency management and package publishing by using a single `pyproject.toml` file to handle project metadata and dependencies.
86
+
53
87
  ```bash
54
88
  poetry add mistralai
55
89
  ```
@@ -71,7 +105,6 @@ s = Mistral(
71
105
  api_key=os.getenv("MISTRAL_API_KEY", ""),
72
106
  )
73
107
 
74
-
75
108
  res = s.chat.complete(model="mistral-small-latest", messages=[
76
109
  {
77
110
  "content": "Who is the best French painter? Answer in one short sentence.",
@@ -123,10 +156,9 @@ s = Mistral(
123
156
  api_key=os.getenv("MISTRAL_API_KEY", ""),
124
157
  )
125
158
 
126
-
127
159
  res = s.files.upload(file={
128
- "file_name": "your_file_here",
129
- "content": open("<file_path>", "rb"),
160
+ "file_name": "example.file",
161
+ "content": open("example.file", "rb"),
130
162
  })
131
163
 
132
164
  if res is not None:
@@ -148,8 +180,8 @@ async def main():
148
180
  api_key=os.getenv("MISTRAL_API_KEY", ""),
149
181
  )
150
182
  res = await s.files.upload_async(file={
151
- "file_name": "your_file_here",
152
- "content": open("<file_path>", "rb"),
183
+ "file_name": "example.file",
184
+ "content": open("example.file", "rb"),
153
185
  })
154
186
  if res is not None:
155
187
  # handle response
@@ -171,11 +203,9 @@ s = Mistral(
171
203
  api_key=os.getenv("MISTRAL_API_KEY", ""),
172
204
  )
173
205
 
174
-
175
206
  res = s.agents.complete(messages=[
176
207
  {
177
- "content": "Who is the best French painter? Answer in one short sentence.",
178
- "role": "user",
208
+ "content": "<value>",
179
209
  },
180
210
  ], agent_id="<value>")
181
211
 
@@ -226,7 +256,7 @@ You can run the examples in the `examples/` directory using `poetry run` or by e
226
256
  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.
227
257
  See [instructions for deploying Mistral on Azure AI here](https://docs.mistral.ai/deployment/cloud/azure/).
228
258
 
229
- Here's a basic example to get you started. You can also run [the example in the `examples` directory](/examples/azure).
259
+ Here's a basic example to get you started. You can also run [the example in the `examples` directory](https://github.com/mistralai/client-python/blob/master//examples/azure).
230
260
 
231
261
  ```python
232
262
  import asyncio
@@ -254,7 +284,7 @@ async def main() -> None:
254
284
 
255
285
  asyncio.run(main())
256
286
  ```
257
- The documentation for the Azure SDK is available [here](packages/mistralai_azure/README.md).
287
+ The documentation for the Azure SDK is available [here](https://github.com/mistralai/client-python/blob/master/packages/mistralai_azure/README.md).
258
288
 
259
289
  ### Google Cloud
260
290
 
@@ -303,55 +333,63 @@ async def main() -> None:
303
333
  asyncio.run(main())
304
334
  ```
305
335
 
306
- The documentation for the GCP SDK is available [here](packages/mistralai_gcp/README.md).
336
+ The documentation for the GCP SDK is available [here](https://github.com/mistralai/client-python/blob/master/packages/mistralai_gcp/README.md).
307
337
 
308
338
 
309
339
  <!-- Start Available Resources and Operations [operations] -->
310
340
  ## Available Resources and Operations
311
341
 
312
- ### [models](docs/sdks/models/README.md)
342
+ <details open>
343
+ <summary>Available methods</summary>
344
+
345
+ ### [agents](https://github.com/mistralai/client-python/blob/master/docs/sdks/agents/README.md)
346
+
347
+ * [complete](https://github.com/mistralai/client-python/blob/master/docs/sdks/agents/README.md#complete) - Agents Completion
348
+ * [stream](https://github.com/mistralai/client-python/blob/master/docs/sdks/agents/README.md#stream) - Stream Agents completion
313
349
 
314
- * [list](docs/sdks/models/README.md#list) - List Models
315
- * [retrieve](docs/sdks/models/README.md#retrieve) - Retrieve Model
316
- * [delete](docs/sdks/models/README.md#delete) - Delete Model
317
- * [update](docs/sdks/models/README.md#update) - Update Fine Tuned Model
318
- * [archive](docs/sdks/models/README.md#archive) - Archive Fine Tuned Model
319
- * [unarchive](docs/sdks/models/README.md#unarchive) - Unarchive Fine Tuned Model
350
+ ### [chat](https://github.com/mistralai/client-python/blob/master/docs/sdks/chat/README.md)
320
351
 
321
- ### [files](docs/sdks/files/README.md)
352
+ * [complete](https://github.com/mistralai/client-python/blob/master/docs/sdks/chat/README.md#complete) - Chat Completion
353
+ * [stream](https://github.com/mistralai/client-python/blob/master/docs/sdks/chat/README.md#stream) - Stream chat completion
322
354
 
323
- * [upload](docs/sdks/files/README.md#upload) - Upload File
324
- * [list](docs/sdks/files/README.md#list) - List Files
325
- * [retrieve](docs/sdks/files/README.md#retrieve) - Retrieve File
326
- * [delete](docs/sdks/files/README.md#delete) - Delete File
355
+ ### [embeddings](https://github.com/mistralai/client-python/blob/master/docs/sdks/embeddings/README.md)
327
356
 
357
+ * [create](https://github.com/mistralai/client-python/blob/master/docs/sdks/embeddings/README.md#create) - Embeddings
328
358
 
329
- ### [fine_tuning.jobs](docs/sdks/jobs/README.md)
359
+ ### [files](https://github.com/mistralai/client-python/blob/master/docs/sdks/files/README.md)
330
360
 
331
- * [list](docs/sdks/jobs/README.md#list) - Get Fine Tuning Jobs
332
- * [create](docs/sdks/jobs/README.md#create) - Create Fine Tuning Job
333
- * [get](docs/sdks/jobs/README.md#get) - Get Fine Tuning Job
334
- * [cancel](docs/sdks/jobs/README.md#cancel) - Cancel Fine Tuning Job
335
- * [start](docs/sdks/jobs/README.md#start) - Start Fine Tuning Job
361
+ * [upload](https://github.com/mistralai/client-python/blob/master/docs/sdks/files/README.md#upload) - Upload File
362
+ * [list](https://github.com/mistralai/client-python/blob/master/docs/sdks/files/README.md#list) - List Files
363
+ * [retrieve](https://github.com/mistralai/client-python/blob/master/docs/sdks/files/README.md#retrieve) - Retrieve File
364
+ * [delete](https://github.com/mistralai/client-python/blob/master/docs/sdks/files/README.md#delete) - Delete File
336
365
 
337
- ### [chat](docs/sdks/chat/README.md)
366
+ ### [fim](https://github.com/mistralai/client-python/blob/master/docs/sdks/fim/README.md)
338
367
 
339
- * [complete](docs/sdks/chat/README.md#complete) - Chat Completion
340
- * [stream](docs/sdks/chat/README.md#stream) - Stream chat completion
368
+ * [complete](https://github.com/mistralai/client-python/blob/master/docs/sdks/fim/README.md#complete) - Fim Completion
369
+ * [stream](https://github.com/mistralai/client-python/blob/master/docs/sdks/fim/README.md#stream) - Stream fim completion
341
370
 
342
- ### [fim](docs/sdks/fim/README.md)
371
+ ### [fine_tuning](https://github.com/mistralai/client-python/blob/master/docs/sdks/finetuning/README.md)
343
372
 
344
- * [complete](docs/sdks/fim/README.md#complete) - Fim Completion
345
- * [stream](docs/sdks/fim/README.md#stream) - Stream fim completion
346
373
 
347
- ### [agents](docs/sdks/agents/README.md)
374
+ #### [fine_tuning.jobs](https://github.com/mistralai/client-python/blob/master/docs/sdks/jobs/README.md)
348
375
 
349
- * [complete](docs/sdks/agents/README.md#complete) - Agents Completion
350
- * [stream](docs/sdks/agents/README.md#stream) - Stream Agents completion
376
+ * [list](https://github.com/mistralai/client-python/blob/master/docs/sdks/jobs/README.md#list) - Get Fine Tuning Jobs
377
+ * [create](https://github.com/mistralai/client-python/blob/master/docs/sdks/jobs/README.md#create) - Create Fine Tuning Job
378
+ * [get](https://github.com/mistralai/client-python/blob/master/docs/sdks/jobs/README.md#get) - Get Fine Tuning Job
379
+ * [cancel](https://github.com/mistralai/client-python/blob/master/docs/sdks/jobs/README.md#cancel) - Cancel Fine Tuning Job
380
+ * [start](https://github.com/mistralai/client-python/blob/master/docs/sdks/jobs/README.md#start) - Start Fine Tuning Job
351
381
 
352
- ### [embeddings](docs/sdks/embeddings/README.md)
353
382
 
354
- * [create](docs/sdks/embeddings/README.md#create) - Embeddings
383
+ ### [models](https://github.com/mistralai/client-python/blob/master/docs/sdks/models/README.md)
384
+
385
+ * [list](https://github.com/mistralai/client-python/blob/master/docs/sdks/models/README.md#list) - List Models
386
+ * [retrieve](https://github.com/mistralai/client-python/blob/master/docs/sdks/models/README.md#retrieve) - Retrieve Model
387
+ * [delete](https://github.com/mistralai/client-python/blob/master/docs/sdks/models/README.md#delete) - Delete Model
388
+ * [update](https://github.com/mistralai/client-python/blob/master/docs/sdks/models/README.md#update) - Update Fine Tuned Model
389
+ * [archive](https://github.com/mistralai/client-python/blob/master/docs/sdks/models/README.md#archive) - Archive Fine Tuned Model
390
+ * [unarchive](https://github.com/mistralai/client-python/blob/master/docs/sdks/models/README.md#unarchive) - Unarchive Fine Tuned Model
391
+
392
+ </details>
355
393
  <!-- End Available Resources and Operations [operations] -->
356
394
 
357
395
  <!-- Start Server-sent event streaming [eventstream] -->
@@ -371,7 +409,6 @@ s = Mistral(
371
409
  api_key=os.getenv("MISTRAL_API_KEY", ""),
372
410
  )
373
411
 
374
-
375
412
  res = s.chat.stream(model="mistral-small-latest", messages=[
376
413
  {
377
414
  "content": "Who is the best French painter? Answer in one short sentence.",
@@ -408,10 +445,9 @@ s = Mistral(
408
445
  api_key=os.getenv("MISTRAL_API_KEY", ""),
409
446
  )
410
447
 
411
-
412
448
  res = s.files.upload(file={
413
- "file_name": "your_file_here",
414
- "content": open("<file_path>", "rb"),
449
+ "file_name": "example.file",
450
+ "content": open("example.file", "rb"),
415
451
  })
416
452
 
417
453
  if res is not None:
@@ -436,7 +472,6 @@ s = Mistral(
436
472
  api_key=os.getenv("MISTRAL_API_KEY", ""),
437
473
  )
438
474
 
439
-
440
475
  res = s.models.list(,
441
476
  RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))
442
477
 
@@ -457,7 +492,6 @@ s = Mistral(
457
492
  api_key=os.getenv("MISTRAL_API_KEY", ""),
458
493
  )
459
494
 
460
-
461
495
  res = s.models.list()
462
496
 
463
497
  if res is not None:
@@ -472,10 +506,10 @@ if res is not None:
472
506
 
473
507
  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.
474
508
 
475
- | Error Object | Status Code | Content Type |
476
- | -------------------------- | -------------------------- | -------------------------- |
477
- | models.HTTPValidationError | 422 | application/json |
478
- | models.SDKError | 4xx-5xx | */* |
509
+ | Error Object | Status Code | Content Type |
510
+ | -------------------------- | ----------- | ---------------- |
511
+ | models.HTTPValidationError | 422 | application/json |
512
+ | models.SDKError | 4xx-5xx | */* |
479
513
 
480
514
  ### Example
481
515
 
@@ -491,17 +525,16 @@ res = None
491
525
  try:
492
526
  res = s.models.list()
493
527
 
528
+ if res is not None:
529
+ # handle response
530
+ pass
531
+
494
532
  except models.HTTPValidationError as e:
495
- # handle exception
533
+ # handle e.data: models.HTTPValidationErrorData
496
534
  raise(e)
497
535
  except models.SDKError as e:
498
536
  # handle exception
499
537
  raise(e)
500
-
501
- if res is not None:
502
- # handle response
503
- pass
504
-
505
538
  ```
506
539
  <!-- End Error Handling [errors] -->
507
540
 
@@ -512,9 +545,9 @@ if res is not None:
512
545
 
513
546
  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:
514
547
 
515
- | Name | Server | Variables |
516
- | ----- | ------ | --------- |
517
- | `prod` | `https://api.mistral.ai` | None |
548
+ | Name | Server | Variables |
549
+ | ------ | ------------------------ | --------- |
550
+ | `prod` | `https://api.mistral.ai` | None |
518
551
 
519
552
  #### Example
520
553
 
@@ -527,7 +560,6 @@ s = Mistral(
527
560
  api_key=os.getenv("MISTRAL_API_KEY", ""),
528
561
  )
529
562
 
530
-
531
563
  res = s.models.list()
532
564
 
533
565
  if res is not None:
@@ -549,7 +581,6 @@ s = Mistral(
549
581
  api_key=os.getenv("MISTRAL_API_KEY", ""),
550
582
  )
551
583
 
552
-
553
584
  res = s.models.list()
554
585
 
555
586
  if res is not None:
@@ -647,9 +678,9 @@ s = Mistral(async_client=CustomClient(httpx.AsyncClient()))
647
678
 
648
679
  This SDK supports the following security scheme globally:
649
680
 
650
- | Name | Type | Scheme | Environment Variable |
651
- | -------------------- | -------------------- | -------------------- | -------------------- |
652
- | `api_key` | http | HTTP Bearer | `MISTRAL_API_KEY` |
681
+ | Name | Type | Scheme | Environment Variable |
682
+ | --------- | ---- | ----------- | -------------------- |
683
+ | `api_key` | http | HTTP Bearer | `MISTRAL_API_KEY` |
653
684
 
654
685
  To authenticate with the API the `api_key` parameter must be set when initializing the SDK client instance. For example:
655
686
  ```python
@@ -660,7 +691,6 @@ s = Mistral(
660
691
  api_key=os.getenv("MISTRAL_API_KEY", ""),
661
692
  )
662
693
 
663
-
664
694
  res = s.models.list()
665
695
 
666
696
  if res is not None:
@@ -705,4 +735,3 @@ Generally, the SDK will work well with most IDEs out of the box. However, when u
705
735
 
706
736
  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.
707
737
  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.
708
-