node-red-contrib-mistral 0.1.1

Node-RED nodes for the Mistral AI API: chat (text + vision + streaming), embeddings, and OCR.

npm install node-red-contrib-mistral

node-red-contrib-mistral

npm version npm downloads license

Node-RED nodes for the Mistral AI API — chat completions (with vision and streaming), embeddings, and OCR.

Table of contents


Install

From the Node-RED editor:

  1. Open the palette manager (hamburger menu → Manage palette).
  2. Switch to the Install tab.
  3. Search for node-red-contrib-mistral and click Install.

Or from the command line in your Node-RED user directory (typically ~/.node-red):

npm install node-red-contrib-mistral

Then restart Node-RED. Requires Node.js ≥ 18 and Node-RED ≥ 3.0.

Quick start

  1. Drag a mistral chat node onto your flow.
  2. Double-click it. In the Server field, click the pencil to create a new mistral-config entry.
  3. Paste your Mistral API key (get one at console.mistral.ai) and save.
  4. Wire an inject node (string payload) → mistral chatdebug.
  5. Deploy, click inject, watch the response in the debug sidebar.

The config node is shared across all Mistral nodes — set it up once, reuse it everywhere.


Nodes

mistral-config

Holds the API key (stored encrypted in Node-RED's credentials store) and base URL. Not visible in the palette — it's only accessible from the editor panel of action nodes via the Server dropdown.

Field Default Notes
API Key Required. Stored encrypted.
Base URL https://api.mistral.ai/v1 Override for proxies or self-hosted gateways.

mistral-chat

Calls POST /chat/completions. Supports text, vision (image inputs), and streaming.

Inputs

Property Type Description
msg.payload string | ChatMessage[] User prompt as string, or full conversation array.
msg.image string | string[] Optional. Image URL(s) or data: base64. Requires a vision model (e.g. pixtral-large-latest).
msg.model string Optional. Override the configured model.
msg.temperature number Optional.
msg.max_tokens number Optional.
msg.stream boolean Optional. Force streaming on/off for this call.

Outputs (non-streaming)

Property Type
msg.payload string — assistant reply
msg.mistral full API response (id, model, choices, usage)
msg.complete true

Outputs (streaming) — one msg per chunk plus a final summary:

Property Chunks Final
msg.payload delta text full accumulated text
msg.complete false true
msg.mistral last SSE event with usage

mistral-embeddings

Calls POST /embeddings to vectorize text. Default model: mistral-embed (1024 dims).

Inputs

Property Type
msg.payload string | string[]
msg.model optional string override

Outputs

Property Type
msg.payload number[] if single input, number[][] if array input — aligned to input order
msg.mistral full API response

mistral-ocr

Calls POST /ocr to extract markdown from PDFs and images. Default model: mistral-ocr-latest.

Inputs

Property Value
msg.payload URL string (https or data:), OR an object { document_url } / { image_url } / { url }

The node auto-detects document vs image from the URL extension by default. You can force a type in the editor.

Outputs

Property Type
msg.payload concatenated markdown across all pages
msg.pages per-page array { index, markdown, images?, dimensions? }
msg.mistral full API response

Example flows

Importable JSON flows are in examples/:

Import in Node-RED: hamburger menu → Importselect a file to import (or paste the JSON content).

⚠️ The mistral-config ID in each example may collide with an existing config in your flow. Node-RED will prompt to Replace or Copy. Choose Replace to reuse your existing config (with your saved API key), or Copy and re-attach manually.


Recipes

RAG with embeddings

The rag-flow.json example shows the canonical pattern in 6 steps:

  1. Index — inject array of documents → mistral-embeddings → function node stores {text, vec} pairs in flow.context.
  2. Query — inject question → mistral-embeddings (single string → single vector).
  3. Retrieve — function node computes cosine similarity vs the stored vectors and keeps the top-K.
  4. Build prompt — same function node concatenates retrieved chunks into a context block.
  5. Generatemistral-chat answers from the context with a system prompt enforcing context-grounding.
  6. Debug — final answer + the retrieved chunks for traceability.

For production, replace the in-memory flow.context store with a proper vector database (Qdrant, pgvector, Pinecone, Chroma) — the only nodes you need from this package are mistral-embeddings and mistral-chat.

Streaming to a dashboard

For a live-typing UI:

inject → mistral-chat (stream=true) → function (route by msg.complete) → ui-template (append chunk)
                                                                       → ui-template (mark complete)

Filter chunks (msg.complete === false) to your "append" UI handler, and the final message (msg.complete === true) to a "done" handler that displays usage stats.


Contributing

Issues and pull requests welcome on the project repository.

License

MIT © Damien Lachambre

Node Info

Version: 0.1.1
Updated 21 hours ago
License: MIT
Rating: 5.0 2

Categories

Actions

Rate:

Downloads

239 in the last week

Nodes

  • mistral-config
  • mistral-chat
  • mistral-embeddings
  • mistral-ocr

Keywords

  • node-red
  • mistral
  • mistralai
  • llm
  • ai
  • chat
  • embeddings
  • ocr
  • vision
  • rag

Maintainers