Home/Integrations/LangChain
Frameworks

Use Qai with LangChain

LangChain's ChatOpenAI accepts a custom base URL, so chains, agents and tool calling run on Qai with one setting.

Connect LangChain to Qai

Install the OpenAI integration

Python needs langchain-openai; JavaScript needs @langchain/openai and @langchain/core.

Install
pip install -U langchain-openai
# or
npm install @langchain/openai @langchain/core

Python

Pass base_url and api_key to ChatOpenAI.

Python
import os
from langchain_openai import ChatOpenAI

model = ChatOpenAI(
    model="qai-pro",
    base_url="https://llm.quickcasa.ai/v1",
    api_key=os.environ["QAI_API_KEY"],
)
print(model.invoke("Explain vector databases in two sentences.").content)

JavaScript

In JavaScript the base URL goes inside configuration.

JavaScript
import { ChatOpenAI } from '@langchain/openai';

const model = new ChatOpenAI({
  model: 'qai-pro',
  apiKey: process.env.QAI_API_KEY,
  configuration: { baseURL: 'https://llm.quickcasa.ai/v1' },
});

const message = await model.invoke('Explain vector databases in two sentences.');
console.log(message.content);

Tools and agents

bind_tools (Python) and bindTools (JavaScript) work as usual. Pick qai-flash or a higher tier for tool calling.

Tested against Qai on November 25, 2026 with langchain-openai 1.8.5 (Python) and @langchain/openai 1.8.5 (JavaScript): invoke, streaming and tool calling.

Limits and gotchas

  • Leave use_responses_api (Python) and useResponsesApi (JavaScript) off. Qai serves chat completions.
  • Qai model ids do not match the OpenAI names LangChain routes to the Responses API, so the defaults already send chat completions.

Questions, answered.

Which LangChain class should I use?
ChatOpenAI from langchain-openai or @langchain/openai, with the base URL set to Qai.
Does tool calling work?
Yes. Bind your tools as usual and use qai-flash or a higher tier.