Skip to main content

Framework Integrations

The mutagent integrate command is a skill loader for AI coding agents. It generates ready-to-use SDK integration instructions that AI assistants (Claude Code, Cursor, etc.) can directly apply to a codebase. It does not auto-install packages.
For AI Agents: Use mutagent integrate <framework> --raw to get clean markdown that can be directly applied to a codebase.

Pre-Step: Framework Detection

Before generating integration code, you can use mutagent explore to auto-detect your framework by scanning the codebase:
# Scan your project to detect AI frameworks in use
mutagent explore
The explore command inspects your package.json dependencies and project structure to identify which AI frameworks you are using. This is especially useful when you are unsure which integration to generate.
After mutagent auth login, the CLI offers a guided post-onboarding flow that automatically runs mutagent explore and walks you through framework selection, package installation, and code generation.

Quick Start

# Detect your framework first
mutagent explore

# No framework specified - returns exploration instructions for AI agents
mutagent integrate

# Specify framework directly
mutagent integrate langchain

# Save integration guide to file
mutagent integrate langchain --output INTEGRATION.md

# Raw markdown output for AI agents (no terminal formatting)
mutagent integrate vercel-ai --raw

# Verify an existing integration
mutagent integrate openai --verify

# List all available frameworks
mutagent integrate list

# JSON output
mutagent integrate list --json

Supported Frameworks

FrameworkCommandMutagenT PackageDescription
LangChainmutagent integrate langchain@mutagent/langchainPopular LLM application framework
LangGraphmutagent integrate langgraph@mutagent/langchainAgent workflow framework built on LangChain
Vercel AImutagent integrate vercel-ai@mutagent/vercel-aiAI SDK for building streaming chat UIs
OpenAImutagent integrate openai@mutagent/openaiOfficial OpenAI SDK with automatic tracing
Python support: Python integrations are also available for OpenAI, LangChain, and LangGraph. See the Python Integrations section for details.

How It Works

When a framework is specified, the CLI:
  1. Verifies your API key is configured
  2. Detects your package manager (bun, npm, yarn, or pnpm) from lockfiles
  3. Generates a numbered integration guide with install commands, framework-specific code, and environment variable setup
  4. Optionally verifies the integration with --verify
When no framework is specified, the CLI returns exploration instructions that guide AI agents to detect the framework from package.json dependencies or ask the user.

Framework Examples

OpenAI

mutagent integrate openai
Generates a traced OpenAI client wrapper:
import OpenAI from 'openai';
import { observeOpenAI } from '@mutagent/openai';
import { initTracing } from '@mutagent/sdk/tracing';

// Initialize tracing (or set MUTAGENT_API_KEY env var for auto-init)
initTracing({
  apiKey: process.env.MUTAGENT_API_KEY!,
  endpoint: process.env.MUTAGENT_ENDPOINT,
});

// Wrap the OpenAI client for automatic tracing
const openai = observeOpenAI(new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
}));

const completion = await openai.chat.completions.create({
  model: 'gpt-4o',
  messages: [{ role: 'user', content: 'Hello!' }],
});

LangChain

mutagent integrate langchain
Generates a callback handler for LangChain chains and LLMs:
import { ChatOpenAI } from '@langchain/openai';
import { MutagentCallbackHandler } from '@mutagent/langchain';
import { initTracing } from '@mutagent/sdk/tracing';

initTracing({
  apiKey: process.env.MUTAGENT_API_KEY!,
  endpoint: process.env.MUTAGENT_ENDPOINT,
});

// Create callback handler (no args needed - uses SDK tracing)
const handler = new MutagentCallbackHandler();

const llm = new ChatOpenAI({
  callbacks: [handler],
});

const result = await llm.invoke('Hello world');
// Traces automatically captured via LangChain callbacks

LangGraph

mutagent integrate langgraph
Generates a traced LangGraph setup using the LangChain callback handler (which works for LangGraph too):
import { StateGraph, Annotation } from '@langchain/langgraph';
import { MutagentCallbackHandler } from '@mutagent/langchain';
import { initTracing } from '@mutagent/sdk/tracing';

initTracing({
  apiKey: process.env.MUTAGENT_API_KEY!,
  endpoint: process.env.MUTAGENT_ENDPOINT,
});

// Create callback handler (works for both LangChain and LangGraph)
const handler = new MutagentCallbackHandler();

const graph = new StateGraph(StateAnnotation)
  .addNode('agent', agentNode)
  .addNode('tools', toolNode)
  .addEdge('__start__', 'agent')
  .compile();

const result = await graph.invoke(
  { input: 'Hello' },
  { callbacks: [handler] },
);

Vercel AI SDK

mutagent integrate vercel-ai
Generates middleware for the Vercel AI SDK:
import { streamText, wrapLanguageModel } from 'ai';
import { openai } from '@ai-sdk/openai';
import { createMutagentMiddleware } from '@mutagent/vercel-ai';
import { initTracing } from '@mutagent/sdk/tracing';

initTracing({
  apiKey: process.env.MUTAGENT_API_KEY!,
  endpoint: process.env.MUTAGENT_ENDPOINT,
});

// Create middleware (no args needed - uses SDK tracing)
const middleware = createMutagentMiddleware();

// Wrap your model with MutagenT middleware
const model = wrapLanguageModel({
  model: openai('gpt-4o'),
  middleware,
});

const result = streamText({ model, messages });

Options

OptionDescription
-o, --output <path>Save integration guide to file
--rawOutput raw markdown without terminal formatting (ideal for AI agents)
--verifyVerify the integration after generation
--jsonOutput in JSON format (on the parent command)

Exploration Mode (No Framework)

When run without a framework argument, the CLI returns exploration instructions designed for AI agents:
mutagent integrate
The exploration instructions guide AI agents to:
  1. Check package.json for known framework dependencies (langchain, @langchain/core, @langchain/langgraph, ai, openai)
  2. Or ask the user which framework they are using
  3. Then re-run mutagent integrate <framework> with the detected framework
This design keeps the CLI stateless and lets the AI agent handle the detection logic.

List Available Frameworks

mutagent integrate list
Returns metadata for all supported frameworks including the name, display name, description, npm package, and MutagenT adapter package. Supports --json output for programmatic use:
mutagent integrate list --json