Engineering
LangChain
LangChain Framework Integration Guide
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
LangChain Framework Integration Guide
pip install langchain langchain-openai
import os
from langchain_openai import ChatOpenAI
os.environ["OPENAI_API_KEY"] = "YOUR_MIXROUTE_API_KEY"
os.environ["OPENAI_BASE_URL"] = "https://api.mixroute.ai/v1"
llm = ChatOpenAI(
model="gpt-5.5",
temperature=0.7
)
from langchain.schema import HumanMessage, SystemMessage
messages = [
SystemMessage(content="You are a helpful assistant"),
HumanMessage(content="Explain Python's main features")
]
response = llm.invoke(messages)
print(response.content)
from langchain.memory import ConversationBufferMemory
from langchain.chains import ConversationChain
memory = ConversationBufferMemory()
conversation = ConversationChain(llm=llm, memory=memory)
conversation.predict(input="I want to learn machine learning")
conversation.predict(input="Recommend some resources")
from langchain.callbacks.streaming_stdout import StreamingStdOutCallbackHandler
streaming_llm = ChatOpenAI(
model="gpt-5.5",
streaming=True,
callbacks=[StreamingStdOutCallbackHandler()]
)
streaming_llm.invoke("Write a poem about spring")