DEVSAIO

LangChain (Python) with Claude, GPT and Gemini through one endpoint

Use ChatOpenAI with a custom base_url to run any model in LangChain, including streaming and structured output.

DEVSAIO team · 1 min read
Share on X

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

bash
pip install langchain langchain-openai

Basic usage

python
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

python
for chunk in llm.stream("Write a short poem about databases."):
    print(chunk.content, end="", flush=True)

Structured output

python
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:

python
fast = ChatOpenAI(model="claude-haiku-5-5", base_url="https://devsaio.lol/v1", api_key=os.environ["DEVSAIO_API_KEY"])
strong = llm
Try it with one API key

Claude, GPT, Gemini, DeepSeek, image and video models through one OpenAI- and Anthropic-compatible endpoint. Prepaid, pay only for what you use.

Keep reading