Skip to main content

How To Integrate with LangChain

What is LangChain?

LangChain is the most popular framework for building applications powered by large language models. It provides a standard interface for chains, agents, and memory, making it easy to build complex AI applications. Since the Morpheus Inference API is fully OpenAI-compatible, you can use it with LangChain by simply configuring the OpenAI provider with a custom base URL.

Prerequisites

  • Morpheus API Key from app.mor.org
  • Python 3.8+ or Node.js 18+
  • LangChain installed

Python Integration

Installation

Basic Setup

Streaming

Using with Chains

Using with Agents

Embeddings

JavaScript/TypeScript Integration

Installation

Basic Setup

Streaming

Using with Chains

Environment Variables

Store your API key securely:
Never commit API keys to version control. Add .env to your .gitignore file.

Next Steps

Available Models

See all models available through Morpheus.

OpenAI Python SDK

Direct OpenAI SDK integration guide.

Chat Completions API

Full API reference for chat completions.

Embeddings API

Create embeddings for RAG applications.