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

mirage-langchain

v1.0.6

Published

LangChain adapter for Mirage AI.

Readme

mirage-langchain

NPM Downloads

The Mirage LangChain adapter. Use Mirage AI models with LangChain.

Copyright 2025 Crisp IM SAS. See LICENSE for copying information.

Usage

Install the library:

npm install mirage-langchain --save

Then, import it:

import { ChatMirage } from "mirage-langchain";

Construct a new authenticated ChatMirage client with your user_id and secret_key tokens:

const model = new ChatMirage({
  userId: "ui_xxxxxx",
  secretKey: "sk_xxxxxx",
  model: "medium"
});

Then, use it with LangChain:

import { HumanMessage } from "@langchain/core/messages";

const response = await model.invoke([
  new HumanMessage("What is the capital of France?")
]);

console.log(response.content);

Authentication

To authenticate against the API, get your tokens (user_id and secret_key).

Then, pass those tokens when you instantiate the ChatMirage client:

const model = new ChatMirage({
  userId: "user_id",
  secretKey: "secret_key"
});

Configuration Options

The ChatMirage constructor accepts the following options:

| Option | Type | Description | |--------|------|-------------| | userId | string | Required. Your Mirage API user ID | | secretKey | string | Required. Your Mirage API secret key | | model | "small" \| "medium" \| "large" | Model size to use (default: "medium") | | temperature | number | Sampling temperature | | maxTokens | number | Maximum tokens to generate | | logprobs | boolean | Whether to return log probabilities | | topLogprobs | number | Number of top log probabilities to return |

Features

Streaming

ChatMirage supports streaming responses:

const stream = await model.stream([
  new HumanMessage("Tell me a story")
]);

for await (const chunk of stream) {
  process.stdout.write(chunk.content);
}

Tool Calling

ChatMirage supports tool calling:

import { tool } from "@langchain/core/tools";
import { z } from "zod";

const weatherTool = tool(
  async ({ location }) => {
    return `The weather in ${location} is sunny.`;
  },
  {
    name: "get_weather",
    description: "Get the weather for a location",
    schema: z.object({
      location: z.string().describe("The city name")
    })
  }
);

const modelWithTools = model.bindTools([weatherTool]);

const response = await modelWithTools.invoke([
  new HumanMessage("What's the weather in Paris?")
]);

Structured Output

ChatMirage supports structured output with Zod schemas:

import { z } from "zod";

const schema = z.object({
  name: z.string(),
  age: z.number()
});

const structuredModel = model.withStructuredOutput(schema);

const result = await structuredModel.invoke([
  new HumanMessage("John is 25 years old")
]);

console.log(result); // { name: "John", age: 25 }

Peer Dependencies

This package requires @langchain/core version 1.0.0 or higher as a peer dependency:

npm install @langchain/core