🦜
LangChain
FrameworkLangChain is the most popular framework for building LLM-powered applications. Because Qubax is OpenAI-compatible, you can use ChatOpenAI with a custom base_url and route your entire chain through Qubax.
Official docsInstall
Shell
pip install langchain-openaiQuickstart
Python
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="gpt-5",
base_url="https://api.qubax.ai/v1",
api_key="YOUR_API_KEY",
temperature=0.7,
)
response = llm.invoke("Explain quantum entanglement in one sentence.")
print(response.content)With a chain
Python
from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="gpt-5",
base_url="https://api.qubax.ai/v1",
api_key="YOUR_API_KEY",
)
prompt = ChatPromptTemplate.from_messages([
("system", "You are a helpful assistant that answers concisely."),
("human", "{question}"),
])
chain = prompt | llm
response = chain.invoke({"question": "What is the speed of light?"})
print(response.content)Setup steps
- 1
Install the integration
Run pip install langchain-openai. This pulls in langchain-core and the openai SDK as dependencies.
- 2
Configure ChatOpenAI
Instantiate ChatOpenAI with model="gpt-5", base_url="https://api.qubax.ai/v1", and api_key set to your Qubax key.
- 3
Use it in a chain
Pass the LLM to any LangChain chain, agent, or LCEL pipeline. Streaming, tool calling, and structured output all work.
💡
Set OPENAI_API_KEY and OPENAI_BASE_URL environment variables to avoid repeating config across LLM instances.
Test your connection
Paste your Qubax API key and send a live request to verify everything is wired up. Don't have a key yet?
Create one in the dashboard