Skip to main content
Use this guide when you want LangChain chains, agents, or LangGraph workflows to call models through Phaseo.

Install

pip install -U langchain langchain-openai

Configure ChatOpenAI

import os
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="openai/gpt-5-nano",
    api_key=os.environ["PHASEO_API_KEY"],
    base_url="https://api.phaseo.ai/v1",
)

result = llm.invoke("Write one sentence about routing reliability.")
print(result.content)

Use with LangGraph

Pass the same llm into your graph nodes or agent builder:
def call_model(state):
    response = llm.invoke(state["messages"])
    return {"messages": [response]}

Notes

  • LangChain’s OpenAI-compatible path targets Chat Completions. Use Phaseo features that are available on /v1/chat/completions.
  • If you need Responses-only server tools such as phaseo:apply_patch, call Phaseo directly or use the OpenAI SDK guide.
  • For tracing, pair this with Observability.
Last modified on July 9, 2026