npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@flink-app/mistral-adapter

v2.0.0-alpha.103

Published

Mistral AI adapter for Flink AI framework

Readme

@flink-app/mistral-adapter

Mistral AI adapter for the Flink AI framework. Provides integration with Mistral's models via the Chat Completions API using the official @mistralai/mistralai SDK.

Installation

npm install @flink-app/mistral-adapter
# or
pnpm add @flink-app/mistral-adapter

The @mistralai/mistralai package is included as a dependency, so you don't need to install it separately.

Usage

Basic Setup

import { MistralAdapter } from "@flink-app/mistral-adapter";
import { FlinkApp } from "@flink-app/flink";

const app = new FlinkApp({
  ai: {
    llms: {
      default: new MistralAdapter({
        apiKey: process.env.MISTRAL_API_KEY!,
        model: "mistral-medium-latest"
      }),
    },
  },
});

await app.start();

Legacy API (still supported):

// Backward-compatible constructor
new MistralAdapter(process.env.MISTRAL_API_KEY!, "mistral-medium-latest")

Agent Instructions

Define your agent's behavior using the instructions property:

// src/agents/support_agent.ts
export const Agent: FlinkAgentProps = {
  name: "support_agent",
  instructions: "You are a helpful customer support agent.",
  tools: ["get_order_status"],
  model: { adapterId: "default" },
};

How it works:

  • Instructions are prepended as a system message to every conversation
  • Follows Vercel AI SDK pattern for consistency
  • Additional system messages in the conversation are passed through as-is

Multiple Adapters

You can register multiple Mistral adapters with different configurations:

const app = new FlinkApp({
  ai: {
    llms: {
      // Frontier model - best for agentic and coding use cases
      default: new MistralAdapter({
        apiKey: process.env.MISTRAL_API_KEY!,
        model: "mistral-medium-latest"
      }),

      // Efficient model - good balance of capability and cost
      fast: new MistralAdapter({
        apiKey: process.env.MISTRAL_API_KEY!,
        model: "mistral-small-latest"
      }),

      // Code completion specialist
      code: new MistralAdapter({
        apiKey: process.env.MISTRAL_API_KEY!,
        model: "codestral-latest"
      }),
    },
  },
});

Debug Logging

const adapter = new MistralAdapter({
  apiKey: process.env.MISTRAL_API_KEY!,
  model: "mistral-medium-latest",
  debug: true // Enable debug logging for this adapter
});

When debug: true, the adapter logs full request parameters and tool call decisions made by the LLM.

Supported Models

This adapter works with all Mistral chat models. As of 2026:

| Use Case | Recommended Model | Why | |----------|------------------|-----| | General / agentic / coding | mistral-medium-latest | Mistral Medium 3.5 - frontier-class multimodal model optimized for agentic and coding use cases | | Cost-efficient tasks | mistral-small-latest | Mistral Small 4 - hybrid model unifying instruct, reasoning, and coding | | General-purpose (open weights) | mistral-large-latest | Mistral Large 3 - general-purpose multimodal model (Apache 2.0) | | Code completion | codestral-latest | Codestral - code completion specialist | | Edge / small footprint | Ministral 3 series (3B, 8B, 14B) | Compact text and vision models |

See the Mistral models overview for the full, up-to-date list of model IDs.

Features

  • Full tool calling support - including parallel tool calls in a single response
  • Event-based streaming - via the SDK's chat.stream()
  • Multimodal input - text + image content blocks (https URLs and base64 data URLs)
  • Tool call ID normalization - Mistral requires tool call IDs to be exactly 9 alphanumeric characters; IDs from conversation history that originated with another provider are deterministically remapped
  • Token usage tracking - prompt and completion tokens reported per request
  • Schema sanitization - tool input schemas cleaned for Mistral compatibility

Architecture Notes

Flink Integration

The adapter implements Flink's LLMAdapter interface:

  • Flink's instructions → prepended as { role: "system" } message
  • Flink's messages → converted to Mistral chat messages (system/user/assistant/tool roles)
  • Flink's tool schema → converted to Mistral's function format ({ type: "function", function: {...} })
  • Streamed deltas → mapped to Flink's LLMStreamChunk events (text, tool_call, usage, done)

Each API call is one turn:

  • Flink's AgentRunner handles the multi-turn loop (call API → execute tools → call API again)
  • Tool results are sent back as { role: "tool", toolCallId, content } messages

ESM-only SDK

The @mistralai/mistralai SDK v2 is ESM-only. This adapter is compiled to CommonJS (like the rest of the Flink ecosystem) and loads the SDK via a dynamic import(), so it works in both CommonJS and ESM applications without configuration.

Temperature

Temperature is only sent to the API when the agent explicitly configured one — Mistral recommends values between 0.0 and 0.7, and the default varies by model.

Requirements

  • Node.js >= 18
  • @flink-app/flink >= 2.0.0-alpha.102

License

MIT

Resources