LangChain
LangChain
LangChain’s OpenAI integration accepts a custom base URL, so fremai plugs into any LangChain app (chains, agents, RAG) with a two-field change.
Python
pip install langchain-openaiimport os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="glm-5.2",
base_url="https://api.fremai.eu/v1",
api_key=os.environ["FREMAI_API_KEY"], # "sk-fremai-…"
)
resp = llm.invoke("Explain EU data sovereignty in two sentences.")
print(resp.content)Use it anywhere a chat model is expected — for example in a chain:
from langchain_core.prompts import ChatPromptTemplate
prompt = ChatPromptTemplate.from_messages([
("system", "You are a concise assistant."),
("human", "{question}"),
])
chain = prompt | llm
print(chain.invoke({"question": "What is an embedding?"}).content)Embeddings
from langchain_openai import OpenAIEmbeddings
embeddings = OpenAIEmbeddings(
model="<embedding-model-id>", # see GET /models
base_url="https://api.fremai.eu/v1",
api_key=os.environ["FREMAI_API_KEY"],
)
vectors = embeddings.embed_documents(["EU-sovereign inference"])JavaScript / TypeScript
npm install @langchain/openaiimport { ChatOpenAI } from "@langchain/openai";
const llm = new ChatOpenAI({
model: "glm-5.2",
apiKey: process.env.FREMAI_API_KEY, // "sk-fremai-…"
configuration: { baseURL: "https://api.fremai.eu/v1" },
});
const resp = await llm.invoke("Explain EU data sovereignty in two sentences.");
console.log(resp.content);Notes
- Model ids come from the catalog or
GET /models. - fremai speaks the OpenAI wire format, so LangChain features that rely on it — streaming, tool calling where the model supports it, structured output — work through the same integration.