LangChain's ChatOpenAI class works with any OpenAI-compatible API. Set base_url, and every model on DEVSAIO becomes available to your chains and agents.
Install
pip install langchain langchain-openaiBasic usage
import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="claude-sonnet-4-6",
base_url="https://devsaio.lol/v1",
api_key=os.environ["DEVSAIO_API_KEY"],
temperature=0.3,
)
print(llm.invoke("Give me three test cases for a login form.").content)Streaming
for chunk in llm.stream("Write a short poem about databases."):
print(chunk.content, end="", flush=True)Structured output
from pydantic import BaseModel
class Ticket(BaseModel):
category: str
urgency: int
summary: str
parser_llm = llm.with_structured_output(Ticket)
t = parser_llm.invoke("My invoice is wrong and I need it fixed before Friday's audit.")
print(t)Swapping models
Because only model changes, you can keep a dictionary of models for different steps, such as a cheap model for routing and a strong one for the final answer:
fast = ChatOpenAI(model="claude-haiku-5-5", base_url="https://devsaio.lol/v1", api_key=os.environ["DEVSAIO_API_KEY"])
strong = llmClaude, GPT, Gemini, DeepSeek, image and video models through one OpenAI- and Anthropic-compatible endpoint. Prepaid, pay only for what you use.