Framework

LangChain

Chains and agents, European providers.

Point `ChatOpenAI` at our base URL. The LangChain patterns most people use, chains, agents, RAG, structured outputs, all on European infrastructure.

Python
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    base_url=class="s">"https://api.melious.ai/v1",
    api_key=class="s">"sk-mel-<YOUR_API_KEY>",
    model=class="s">"glm-5.1",
)

response = llm.invoke(class="s">"Name three Hanseatic cities.")
print(response.content)
About

What is LangChain?

LangChain is a Python and JavaScript framework for composing LLM apps. Chains, agents, tool calling, retrieval, and structured outputs behind uniform interfaces. The langchain-openai package is the path we recommend: maintained by the LangChain team, updated the day OpenAI ships something new.

Visit the official site python.langchain.com
Setup

How to use LangChain with Melious?

  1. Install LangChain

    Install langchain and langchain-openai for Chat Completions, plus langchain-community and duckduckgo-search if you want to follow the agent example. We track the OpenAI shape, so LangChain's core OpenAI integration is the right entry point.

    Shell
    pip install langchain langchain-openai langchain-community duckduckgo-search
    export MELIOUS_API_KEY=sk-mel-<YOUR_API_KEY>
  2. Create an LLM

    ChatOpenAI takes the Melious base URL, your key, and a model ID. Wire it into any chain, runnable, or agent. LangChain doesn't know anything's different.

    Python
    import os
    from langchain_openai import ChatOpenAI
    
    llm = ChatOpenAI(
        base_url=class="s">"https://api.melious.ai/v1",
        api_key=os.environ[class="s">"MELIOUS_API_KEY"],
        model=class="s">"glm-5.1",
    )
  3. Build an agent

    Tool-calling agents work unchanged because Melious mirrors OpenAI's tool_calls schema. Wrap the LLM in create_tool_calling_agent, hand it a list of tools, and go.

    Python
    from langchain.agents import AgentExecutor, create_tool_calling_agent
    from langchain_core.prompts import ChatPromptTemplate
    from langchain_community.tools import DuckDuckGoSearchRun
    
    tools = [DuckDuckGoSearchRun()]
    prompt = ChatPromptTemplate.from_messages([
        (class="s">"system", class="s">"You are a careful researcher."),
        (class="s">"human", class="s">"{input}"),
        (class="s">"placeholder", class="s">"{agent_scratchpad}"),
    ])
    agent = create_tool_calling_agent(llm, tools, prompt)
    executor = AgentExecutor(agent=agent, tools=tools)
    executor.invoke({class="s">"input": class="s">"What's the capital of the Hanseatic League?"})
Ready?

Three steps from here.

Grab a Melious key. Pick your tool. Follow the guide. Same client, now answering from Europe.