# Watermarking ## Overview ### Available Operations * [detect](#detect) - Detections * [detectMultipart](#detectmultipart) - Detections ## detect Detect whether content was produced with a Mistral watermark. Accepts exactly one input: a JSON body (``{"text": ...}``) for text, or a multipart ``file`` upload. Returns the watermark-detector verdict (``watermarked`` + ``watermarked_reason``) and the content-metadata verdict (``metadata_valid`` + ``metadata_reason``) separately; each flag is ``"true"`` / ``"false"`` / ``null`` (null = not tested, see the matching ``*_reason``). ### Example Usage ```typescript import { Mistral } from "@mistralai/mistralai"; const mistral = new Mistral({ apiKey: process.env["MISTRAL_API_KEY"] ?? "", }); async function run() { const result = await mistral.watermarking.detect({ text: "", }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript import { MistralCore } from "@mistralai/mistralai/core.js"; import { watermarkingDetect } from "@mistralai/mistralai/funcs/watermarkingDetect.js"; // Use `MistralCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const mistral = new MistralCore({ apiKey: process.env["MISTRAL_API_KEY"] ?? "", }); async function run() { const res = await watermarkingDetect(mistral, { text: "", }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("watermarkingDetect failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `request` | [operations.DetectionTextRequest](../../models/operations/detectiontextrequest.md) | :heavy_check_mark: | The request object to use for the request. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[components.DetectionResponse](../../models/components/detectionresponse.md)\>** ### Errors | Error Type | Status Code | Content Type | | --------------- | --------------- | --------------- | | errors.SDKError | 4XX, 5XX | \*/\* | ## detectMultipart Detect whether content was produced with a Mistral watermark. Accepts exactly one input: a JSON body (``{"text": ...}``) for text, or a multipart ``file`` upload. Returns the watermark-detector verdict (``watermarked`` + ``watermarked_reason``) and the content-metadata verdict (``metadata_valid`` + ``metadata_reason``) separately; each flag is ``"true"`` / ``"false"`` / ``null`` (null = not tested, see the matching ``*_reason``). ### Example Usage ```typescript import { Mistral } from "@mistralai/mistralai"; import { openAsBlob } from "node:fs"; const mistral = new Mistral({ apiKey: process.env["MISTRAL_API_KEY"] ?? "", }); async function run() { const result = await mistral.watermarking.detectMultipart({ file: await openAsBlob("example.file"), }); console.log(result); } run(); ``` ### Standalone function The standalone function version of this method: ```typescript import { MistralCore } from "@mistralai/mistralai/core.js"; import { watermarkingDetectMultipart } from "@mistralai/mistralai/funcs/watermarkingDetectMultipart.js"; import { openAsBlob } from "node:fs"; // Use `MistralCore` for best tree-shaking performance. // You can create one instance of it to use across an application. const mistral = new MistralCore({ apiKey: process.env["MISTRAL_API_KEY"] ?? "", }); async function run() { const res = await watermarkingDetectMultipart(mistral, { file: await openAsBlob("example.file"), }); if (res.ok) { const { value: result } = res; console.log(result); } else { console.log("watermarkingDetectMultipart failed:", res.error); } } run(); ``` ### Parameters | Parameter | Type | Required | Description | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `request` | [operations.DetectionFileRequest](../../models/operations/detectionfilerequest.md) | :heavy_check_mark: | The request object to use for the request. | | `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. | | `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. | | `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. | ### Response **Promise\<[components.DetectionResponse](../../models/components/detectionresponse.md)\>** ### Errors | Error Type | Status Code | Content Type | | --------------- | --------------- | --------------- | | errors.SDKError | 4XX, 5XX | \*/\* |