Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4,109 changes: 2,187 additions & 1,922 deletions .speakeasy/gen.lock

Large diffs are not rendered by default.

41 changes: 40 additions & 1 deletion .speakeasy/gen.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ generation:
sharedErrorComponentsApr2025: true
sharedNestedComponentsJan2026: true
nameOverrideFeb2026: true
openSingleValueEnumsOct2026: false
methodSignaturesApr2024: true
auth:
oAuth2ClientCredentialsEnabled: true
Expand All @@ -32,7 +33,7 @@ generation:
generateNewTests: false
skipResponseBodyAssertions: false
python:
version: 3.7.0
version: 4.0.0
additionalDependencies:
dev:
pytest: ^8.2.2
Expand All @@ -49,6 +50,42 @@ python:
baseErrorName: MistralError
bodyVariantOverloads: false
clientServerStatusCodesAsErrors: true
compileCommands:
- - uv
- lock
- - uv
- run
- python
- scripts/prepare_readme.py
- - uv
- sync
- --dev
- - uv
- run
- python
- -m
- compileall
- -q
- .
- - uv
- run
- python
- -m
- pylint
- -j=1
- src/mistralai/client
- - uv
- run
- python
- -m
- mypy
- src/mistralai/client
- - uv
- run
- python
- -m
- pyright
- src/mistralai/client
constFieldCasing: normal
defaultErrorName: SDKError
description: Python Client SDK for the Mistral AI API.
Expand Down Expand Up @@ -87,13 +124,15 @@ python:
methodArguments: infer-optional-args
methodTimeoutArgument: timeout-ms
methodTimeoutUnits: milliseconds
modelSerializationMethods: false
moduleName: mistralai.client
multipartArrayFormat: standard
optionalDependencies: {}
outputModelSuffix: output
packageManager: uv
packageName: mistralai
preApplyUnionDiscriminators: true
preserveUnknownFields: false
pytestFilterWarnings: []
pytestTimeout: 0
rawResponseHelpers: false
Expand Down
14 changes: 7 additions & 7 deletions .speakeasy/workflow.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
speakeasyVersion: 1.796.4
speakeasyVersion: 1.807.0
sources:
mistral-azure-source:
sourceNamespace: mistral-azure-source
Expand All @@ -16,8 +16,8 @@ sources:
- 1.0.0
mistral-openapi:
sourceNamespace: mistral-openapi
sourceRevisionDigest: sha256:36a8b6581aacc9133bd49339da1d2410a9fa8ee2d3c51a5ec91dc12550cb4221
sourceBlobDigest: sha256:123b96271beeb26e8318ce2f49bb29a3969f6709eeb44d59bd9d754d75825d6a
sourceRevisionDigest: sha256:6441873fab21311e396b17c3470a67ba76f56913be59c79268c323a00bb4eea4
sourceBlobDigest: sha256:b411ae12070945d5822bc3e421566c8ffd00e28a234e3948b5ff41c1026836bd
tags:
- latest
- 1.0.0
Expand All @@ -39,13 +39,13 @@ targets:
mistralai-sdk:
source: mistral-openapi
sourceNamespace: mistral-openapi
sourceRevisionDigest: sha256:36a8b6581aacc9133bd49339da1d2410a9fa8ee2d3c51a5ec91dc12550cb4221
sourceBlobDigest: sha256:123b96271beeb26e8318ce2f49bb29a3969f6709eeb44d59bd9d754d75825d6a
sourceRevisionDigest: sha256:6441873fab21311e396b17c3470a67ba76f56913be59c79268c323a00bb4eea4
sourceBlobDigest: sha256:b411ae12070945d5822bc3e421566c8ffd00e28a234e3948b5ff41c1026836bd
codeSamplesNamespace: mistral-openapi-python-code-samples
codeSamplesRevisionDigest: sha256:d2a3d80cb1096f0c10b28e7574fb2df4889d9477d7e6972260b1b1b9c6c8c121
codeSamplesRevisionDigest: sha256:650e5e46f796ed806de0a697d0b8c705375ab2395cb22103d8ca67e30bff556f
workflow:
workflowVersion: 1.0.0
speakeasyVersion: 1.796.4
speakeasyVersion: 1.807.0
sources:
mistral-azure-source:
inputs:
Expand Down
79 changes: 46 additions & 33 deletions README-PYPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ import os


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

res = mistral.chat.complete(model="mistral-large-latest", messages=[
Expand Down Expand Up @@ -199,7 +199,7 @@ import os
async def main():

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

res = await mistral.chat.complete_async(model="mistral-large-latest", messages=[
Expand Down Expand Up @@ -228,7 +228,7 @@ import os


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

res = mistral.files.upload(file={
Expand All @@ -253,7 +253,7 @@ import os
async def main():

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

res = await mistral.files.upload_async(file={
Expand All @@ -278,7 +278,7 @@ import os


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

res = mistral.agents.complete(messages=[
Expand Down Expand Up @@ -307,7 +307,7 @@ import os
async def main():

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

res = await mistral.agents.complete_async(messages=[
Expand Down Expand Up @@ -336,7 +336,7 @@ import os


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

res = mistral.embeddings.create(model="mistral-embed", inputs=[
Expand All @@ -361,7 +361,7 @@ import os
async def main():

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

res = await mistral.embeddings.create_async(model="mistral-embed", inputs=[
Expand Down Expand Up @@ -502,6 +502,7 @@ print(res.choices[0].message.content)

* [create](https://github.com/mistralai/client-python/blob/main/docs/sdks/audiosessions/README.md#create) - Create an agent session
* [get](https://github.com/mistralai/client-python/blob/main/docs/sdks/audiosessions/README.md#get) - Get session status
* [update](https://github.com/mistralai/client-python/blob/main/docs/sdks/audiosessions/README.md#update) - Update a live agent session
* [close](https://github.com/mistralai/client-python/blob/main/docs/sdks/audiosessions/README.md#close) - Stop an agent session

### [Audio.Speech](https://github.com/mistralai/client-python/blob/main/docs/sdks/speech/README.md)
Expand Down Expand Up @@ -546,6 +547,11 @@ print(res.choices[0].message.content)
* [list_version_aliases](https://github.com/mistralai/client-python/blob/main/docs/sdks/betaagents/README.md#list_version_aliases) - List all aliases for an agent.
* [delete_version_alias](https://github.com/mistralai/client-python/blob/main/docs/sdks/betaagents/README.md#delete_version_alias) - Delete an agent version alias.

### [Beta.Billing](https://github.com/mistralai/client-python/blob/main/docs/sdks/billing/README.md)

* [get_budget](https://github.com/mistralai/client-python/blob/main/docs/sdks/billing/README.md#get_budget) - Get Budget
* [get_subscription](https://github.com/mistralai/client-python/blob/main/docs/sdks/billing/README.md#get_subscription) - Get Subscription

### [Beta.Connectors](https://github.com/mistralai/client-python/blob/main/docs/sdks/connectors/README.md)

* [create](https://github.com/mistralai/client-python/blob/main/docs/sdks/connectors/README.md#create) - Create a new connector.
Expand Down Expand Up @@ -654,7 +660,6 @@ print(res.choices[0].message.content)
* [fetch](https://github.com/mistralai/client-python/blob/main/docs/sdks/datasetsrecords/README.md#fetch) - Get the content of a given dataset record
* [delete](https://github.com/mistralai/client-python/blob/main/docs/sdks/datasetsrecords/README.md#delete) - Delete a record from a dataset
* [bulk_delete](https://github.com/mistralai/client-python/blob/main/docs/sdks/datasetsrecords/README.md#bulk_delete) - Delete multiple records from datasets
* [judge](https://github.com/mistralai/client-python/blob/main/docs/sdks/datasetsrecords/README.md#judge) - Run Judge on a dataset record based on the given options
* [update_payload](https://github.com/mistralai/client-python/blob/main/docs/sdks/datasetsrecords/README.md#update_payload) - Update a dataset record payload
* [update_properties](https://github.com/mistralai/client-python/blob/main/docs/sdks/datasetsrecords/README.md#update_properties) - Update dataset record properties

Expand Down Expand Up @@ -692,14 +697,12 @@ print(res.choices[0].message.content)
* [get_statistics](https://github.com/mistralai/client-python/blob/main/docs/sdks/evaluationsruns/README.md#get_statistics) - Get statistics for a specific evaluation run
* [compute_statistics](https://github.com/mistralai/client-python/blob/main/docs/sdks/evaluationsruns/README.md#compute_statistics) - Compute statistics for a specific evaluation run with optional filters

### [Beta.Observability.Judges](https://github.com/mistralai/client-python/blob/main/docs/sdks/judges/README.md)
#### [Beta.Observability.Evaluations.Scorers](https://github.com/mistralai/client-python/blob/main/docs/sdks/scorers/README.md)

* [create](https://github.com/mistralai/client-python/blob/main/docs/sdks/judges/README.md#create) - Create a new judge
* [list](https://github.com/mistralai/client-python/blob/main/docs/sdks/judges/README.md#list) - Get judges with optional filtering and search
* [fetch](https://github.com/mistralai/client-python/blob/main/docs/sdks/judges/README.md#fetch) - Get judge by id
* [delete](https://github.com/mistralai/client-python/blob/main/docs/sdks/judges/README.md#delete) - Delete a judge
* [update](https://github.com/mistralai/client-python/blob/main/docs/sdks/judges/README.md#update) - Update a judge
* [judge_conversation](https://github.com/mistralai/client-python/blob/main/docs/sdks/judges/README.md#judge_conversation) - Run a saved judge on a conversation
* [list](https://github.com/mistralai/client-python/blob/main/docs/sdks/scorers/README.md#list) - List scorers
* [create](https://github.com/mistralai/client-python/blob/main/docs/sdks/scorers/README.md#create) - Create a scorer
* [get](https://github.com/mistralai/client-python/blob/main/docs/sdks/scorers/README.md#get) - Get a scorer by slug
* [update](https://github.com/mistralai/client-python/blob/main/docs/sdks/scorers/README.md#update) - Edit a scorer

### [Beta.Observability.Logs](https://github.com/mistralai/client-python/blob/main/docs/sdks/logs/README.md)

Expand All @@ -715,6 +718,7 @@ print(res.choices[0].message.content)
* [search_span_evaluations](https://github.com/mistralai/client-python/blob/main/docs/sdks/spans/README.md#search_span_evaluations) - Search span evaluations
* [search_latest_span_evaluations](https://github.com/mistralai/client-python/blob/main/docs/sdks/spans/README.md#search_latest_span_evaluations) - Search latest span evaluations
* [search_pipeline_results](https://github.com/mistralai/client-python/blob/main/docs/sdks/spans/README.md#search_pipeline_results) - Search pipeline results
* [list_pipeline_result_fields](https://github.com/mistralai/client-python/blob/main/docs/sdks/spans/README.md#list_pipeline_result_fields) - Get pipeline result field definitions
* [list_span_fields](https://github.com/mistralai/client-python/blob/main/docs/sdks/spans/README.md#list_span_fields) - Get span field definitions
* [list_span_eval_fields](https://github.com/mistralai/client-python/blob/main/docs/sdks/spans/README.md#list_span_eval_fields) - Get span evaluation field definitions
* [fetch_span_field_options](https://github.com/mistralai/client-python/blob/main/docs/sdks/spans/README.md#fetch_span_field_options) - Get options for a span field
Expand Down Expand Up @@ -956,7 +960,7 @@ import os


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

res = mistral.beta.conversations.start_stream(inputs=[
Expand Down Expand Up @@ -1001,7 +1005,7 @@ import os


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

res = mistral.beta.context.search_indexes.generate_index_summary(language="en", index_name="<value>", force=False)
Expand Down Expand Up @@ -1033,7 +1037,7 @@ import os


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

res = mistral.beta.prompts.list()
Expand Down Expand Up @@ -1062,7 +1066,7 @@ import os


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

res = mistral.beta.libraries.documents.upload(library_id="a02150d9-5ee0-4877-b62c-28b1fcdf3b76", file={
Expand All @@ -1089,7 +1093,7 @@ import os


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

res = mistral.beta.prompts.list(,
Expand All @@ -1111,7 +1115,7 @@ import os

with Mistral(
retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
api_key=os.getenv("MISTRAL_API_KEY", ""),
api_key=os.getenv("MISTRAL_API_KEY"),
) as mistral:

res = mistral.beta.prompts.list()
Expand Down Expand Up @@ -1145,7 +1149,7 @@ import os


with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
api_key=os.getenv("MISTRAL_API_KEY"),
) as mistral:
res = None
try:
Expand Down Expand Up @@ -1173,7 +1177,7 @@ with Mistral(
**Primary error:**
* [`MistralError`](https://github.com/mistralai/client-python/blob/main/src/mistralai/client/errors/mistralerror.py): The base class for HTTP error responses.

<details><summary>Less common errors (7)</summary>
<details><summary>Less common errors (8)</summary>

<br />

Expand All @@ -1184,8 +1188,9 @@ with Mistral(


**Inherit from [`MistralError`](https://github.com/mistralai/client-python/blob/main/src/mistralai/client/errors/mistralerror.py)**:
* [`HTTPValidationError`](https://github.com/mistralai/client-python/blob/main/src/mistralai/client/errors/httpvalidationerror.py): Validation Error. Status code `422`. Applicable to 189 of 302 methods.*
* [`ObservabilityError`](https://github.com/mistralai/client-python/blob/main/src/mistralai/client/errors/observabilityerror.py): Bad Request - Invalid request parameters or data. Applicable to 65 of 302 methods.*
* [`HTTPValidationError`](https://github.com/mistralai/client-python/blob/main/src/mistralai/client/errors/httpvalidationerror.py): Validation Error. Status code `422`. Applicable to 190 of 303 methods.*
* [`ObservabilityError`](https://github.com/mistralai/client-python/blob/main/src/mistralai/client/errors/observabilityerror.py): Bad Request - Invalid request parameters or data. Applicable to 63 of 303 methods.*
* [`ConnectorErrorResponse`](https://github.com/mistralai/client-python/blob/main/src/mistralai/client/errors/connectorerrorresponse.py): Applicable to 4 of 303 methods.*
* [`ResponseValidationError`](https://github.com/mistralai/client-python/blob/main/src/mistralai/client/errors/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute.

</details>
Expand Down Expand Up @@ -1215,7 +1220,7 @@ import os

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

res = mistral.beta.prompts.list()
Expand All @@ -1237,7 +1242,7 @@ import os

with Mistral(
server_url="https://api.mistral.ai",
api_key=os.getenv("MISTRAL_API_KEY", ""),
api_key=os.getenv("MISTRAL_API_KEY"),
) as mistral:

res = mistral.beta.prompts.list()
Expand Down Expand Up @@ -1352,7 +1357,7 @@ import os


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

res = mistral.beta.prompts.list()
Expand Down Expand Up @@ -1396,18 +1401,20 @@ import os
def main():

with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
api_key=os.getenv("MISTRAL_API_KEY"),
) as mistral:
# Rest of application here...
pass


# Or when using async:
async def amain():

async with Mistral(
api_key=os.getenv("MISTRAL_API_KEY", ""),
api_key=os.getenv("MISTRAL_API_KEY"),
) as mistral:
# Rest of application here...
pass
```
<!-- End Resource Management [resource-management] -->

Expand Down Expand Up @@ -1483,6 +1490,12 @@ with Mistral(api_key=os.environ["MISTRAL_API_KEY"]) as client:
)
```

In dedicated mode, traces go to `/telemetry/v1/traces` on the client's `server_url` if one is set, otherwise to `https://api.mistral.ai`, including for the named `eu`/`us` servers. The regional hosts do not serve that route, so use `server="eu"` rather than `server_url="https://api.eu.mistral.ai"`. Set `MISTRAL_OTLP_TRACES_ENDPOINT` to send traces to a separate collector.

The exporter authenticates like API calls: an explicit `api_key`, then the token at `MISTRAL_SA_TOKEN_PATH` (re-read on every export, so rotation is picked up), then `MISTRAL_API_KEY`.

Telemetry never fails an API call. If telemetry enabled through `MISTRAL_SDK_TELEMETRY` cannot be set up, for example because no credential is available or the `telemetry` extra is not installed, the client logs one warning and keeps working without telemetry. An explicit `configure_telemetry(client)` call raises instead.

### Provider modes

`configure_telemetry(client, provider=...)` selects where spans go and who owns the export pipeline:
Expand Down Expand Up @@ -1570,9 +1583,9 @@ configure_telemetry(
| Variable | Description | Default |
| -------- | ----------- | ------- |
| `MISTRAL_SDK_TELEMETRY` | Auto-enable telemetry: `dedicated`, `global`, or `false`. | unset (disabled) |
| `MISTRAL_OTLP_TRACES_ENDPOINT` | Override the OTLP traces endpoint used in dedicated mode. | `https://api.mistral.ai/telemetry/v1/traces` |
| `MISTRAL_OTLP_TRACES_ENDPOINT` | Override the OTLP traces endpoint used in dedicated mode. | Client `server_url` + `/telemetry/v1/traces` if set, otherwise `https://api.mistral.ai/telemetry/v1/traces` |
| `MISTRAL_SDK_DEBUG_TRACING` | Set to `true` for verbose tracing logs. | `false` |
| `MISTRAL_API_KEY` | Used as the bearer token for the dedicated-mode exporter. | — |
| `MISTRAL_API_KEY` | Used as the bearer token for the dedicated-mode exporter when the client has no `api_key` and no service-account token. | — |

Runnable examples live in [`examples/mistral/observability`](https://github.com/mistralai/client-python/blob/main/examples/mistral/observability).

Expand Down
Loading
Loading