Setu Recipes: reusable digital workers across every app.Browse templates

Integrations / Mistral AI

Mistral AI

Mistral AI models through the Mistral API: chat completions, agent completions, embeddings, text moderation, OCR of documents and images, and model listings. Calls use your Mistral API credits.

9 actions API key 9 read0 write Calls api.mistral.ai

Connect

TypeScript
const conn = await setu.connections.initiate({ userId: "user_1", toolkit: "mistralai" });
console.log(conn.connectUrl); // show this to your user
await conn.waitUntilActive();

Permissions requested

This toolkit uses a single credential and requests no scopes.

Actions

Agent completionreadmistralai.agent_completionGet a reply from a Mistral agent you created in AI Studio (agents completions): the agent's own model, instructions and tools are applied to your messages. Uses paid API tokens.
InputTypeDescription
agent_idstringRequiredID of the agent, from list_agents
messagesarray of objectRequiredThe conversation: objects with role (system, user, assistant) and content (text)
max_tokensintegerOptionalMaximum tokens to generate
random_seedintegerOptionalSeed for repeatable output
TypeScript
await setu.execute({
  userId: "user_1",
  action: "mistralai.agent_completion",
  input: {
    "agent_id": "<agent_id>",
    "messages": []
  },
});
Chat completionreadmistralai.chatSend a conversation to a Mistral model and get the reply (chat completions). Uses paid API tokens but changes no stored data. Set response_format to {"type":"json_object"} for JSON output.
InputTypeDescription
modelstringRequiredModel id, e.g. mistral-large-latest, mistral-small-latest; list_models shows all
messagesarray of objectRequiredThe conversation: objects with role (system, user, assistant) and content (text)
temperaturenumberOptionalRandomness (0.0 to 1.5 recommended)
top_pnumberOptionalNucleus sampling, 0 to 1
max_tokensintegerOptionalMaximum tokens to generate
random_seedintegerOptionalSeed for repeatable output
response_formatobjectOptionalOutput format, e.g. {"type":"json_object"}
safe_promptbooleanOptionalAdd Mistral's safety prompt before the conversation
TypeScript
await setu.execute({
  userId: "user_1",
  action: "mistralai.chat",
  input: {
    "model": "<model>",
    "messages": []
  },
});
Create embeddingsreadmistralai.create_embeddingsTurn one or more texts into embedding vectors (numbers) for search, clustering or similarity, with mistral-embed or codestral-embed. Returns one vector per input text, in order. Uses paid API tokens.
InputTypeDescription
modelstringRequiredEmbedding model, e.g. mistral-embed
inputarray of stringRequiredThe texts to embed
TypeScript
await setu.execute({
  userId: "user_1",
  action: "mistralai.create_embeddings",
  input: {
    "model": "<model>",
    "input": []
  },
});
Get modelreadmistralai.get_modelGet one model's details: context length, capabilities, aliases and deprecation date.
InputTypeDescription
model_idstringRequiredModel id, e.g. mistral-small-latest
TypeScript
await setu.execute({
  userId: "user_1",
  action: "mistralai.get_model",
  input: {
    "model_id": "<model_id>"
  },
});
List agentsreadmistralai.list_agentsList the agents created in the Mistral workspace (name, model, instructions, version), so an agent_id can be used with agent_completion.
InputTypeDescription
pageintegerOptionalPage number, starting at 0
page_sizeintegerOptionalAgents per page (1-1000)
searchstringOptionalOnly agents whose name matches
TypeScript
await setu.execute({
  userId: "user_1",
  action: "mistralai.list_agents",
  input: {},
});
List modelsreadmistralai.list_modelsList the models the API key can use, with context length and capabilities (chat, vision, function calling, fine-tuning).

No input.

TypeScript
await setu.execute({
  userId: "user_1",
  action: "mistralai.list_models",
  input: {},
});
Moderate textreadmistralai.moderate_textCheck texts for harmful or sensitive content with Mistral's moderation model: per text, which categories apply (sexual, hate and discrimination, violence and threats, dangerous and criminal content, self-harm, health, financial, law, pii) and a score for each. Uses paid API tokens.
InputTypeDescription
modelstringRequiredModeration model, e.g. mistral-moderation-latest
inputarray of stringRequiredThe texts to check
TypeScript
await setu.execute({
  userId: "user_1",
  action: "mistralai.moderate_text",
  input: {
    "model": "<model>",
    "input": []
  },
});
OCR a documentreadmistralai.ocr_documentExtract the text of a PDF or other document at a public https address as markdown, one entry per page, keeping headings and tables (Mistral OCR). Uses paid API tokens; the file is fetched by Mistral from the address.
InputTypeDescription
document_urlstringRequiredPublic https address of the PDF or document
modelstringRequiredOCR model, e.g. mistral-ocr-latest
pagesarray of integerOptionalOnly these page numbers, starting at 0 (documents only)
table_formatstringOptionalReturn tables as markdown or html
TypeScript
await setu.execute({
  userId: "user_1",
  action: "mistralai.ocr_document",
  input: {
    "document_url": "<document_url>",
    "model": "<model>"
  },
});
OCR an imagereadmistralai.ocr_imageExtract the text of an image at a public https address (a scan, screenshot or photo of a page) as markdown (Mistral OCR). Uses paid API tokens; the image is fetched by Mistral from the address.
InputTypeDescription
image_urlstringRequiredPublic https address of the image (png, jpg...)
modelstringRequiredOCR model, e.g. mistral-ocr-latest
pagesarray of integerOptionalOnly these page numbers, starting at 0 (documents only)
table_formatstringOptionalReturn tables as markdown or html
TypeScript
await setu.execute({
  userId: "user_1",
  action: "mistralai.ocr_image",
  input: {
    "image_url": "<image_url>",
    "model": "<model>"
  },
});