LangChain ChatOpenAI with a custom base_url: use Heabsy models
LangChain reaches Heabsy through ChatOpenAI from langchain-openai: set base_url="https://api.heabsy.com/v1", pass your key and a model ID such as qwen38. With a custom base URL LangChain turns streaming token usage off by default — set stream_usage=True, because Heabsy does send usage in the stream.
# pip install langchain-openai
import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="qwen38",
base_url="https://api.heabsy.com/v1",
api_key=os.environ["HEABSY_API_KEY"],
stream_usage=True,
)
reply = llm.invoke("Say hello from Heabsy in five words.")
print(reply.content, reply.usage_metadata)https://api.heabsy.com/v1 · Anthropic base URL https://api.heabsy.comConfiguration through the environment
Without an explicit base_url, LangChain reads OPENAI_API_BASE and then OPENAI_BASE_URL. Setting OPENAI_BASE_URL=https://api.heabsy.com/v1 and OPENAI_API_KEY to your Heabsy key moves existing code over without edits — but also every other OpenAI client in that process.
Tools, agents and LangGraph
llm.bind_tools([...]) and agents built on ChatOpenAI work with models that support tool calling — every model in the table does. LangGraph uses the same chat model object, so the same settings apply.
Reasoning output
ChatOpenAI follows the official OpenAI specification only: reasoning fields that third-party providers add to responses are not extracted. The final answer is complete; the reasoning trace is dropped. If you need it, call the API with the openai SDK directly.
Which model should I pick?
Our own models run in the EEA and store no prompts, which matters when a chain feeds customer documents to the model. For extraction and classification steps the cheapest model in the table is often enough; for agents, pick qwen38 or glm53.
| Model | ID | Context | Max output | Input / 1M | Output / 1M |
|---|---|---|---|---|---|
| Qwen3.8 27B Fable | qwen38-fable | 512K | 32K | $0.095 | $0.58 |
| Qwen3.8 27B Queen | qwen38-queen | 512K | 32K | $0.095 | $0.58 |
| GLM 5.3 Flash Uncensored | glm53-flash-unc | 1M | 128K | $0.1739 | $0.6957 |
| MiMo V2.6 Flash Uncensored | mimo-v26-flash-unc | 1M | 64K | $0.4404 | $1.4285 |
| MiMo V2.6 Flash | mimo-v26-flash | 1M | 64K | $0.4762 | $1.4286 |
| MiMo V2.6 Flash Abliterated | mimo-v26-flash-abl | 1M | 64K | $0.4762 | $1.4286 |
| GLM 5.3 | glm53 | 1M | 128K | $0.5217 | $0.9565 |
| Qwen3.8 27B Uncensored Fast by Heabsy | qwen38-unc-fast | 512K | 230K | $0.7904 | $2.4952 |
| Qwen3.8 27B Uncensored | qwen38-unc | 1M | 230K | $0.8095 | $2.5238 |
| Qwen3.8 27B | qwen38 | 256K | 32K | $1.00 | $3.00 |
| GLM 5.3 Uncensored | glm-5.3-uncensored | 1M | 128K | $1.1905 | $2.1429 |
| CyberHeabsy | cyberheabsy | 1M | 64K | $1.4286 | $4.2857 |
All models above run on Heabsy hardware in the EEA; prompts and completions are not stored. Thecatalog also lists 23 partner-hosted models — Claude, GPT-6, Kimi K3, DeepSeek V4 and others — with the same key and invoice, but without zero data retention and without an EEA guarantee.
Verify it works
Run the snippet: it prints the reply and usage_metadata with input and output token counts. Empty usage while streaming means stream_usage is still off.
If the tool shows an error you cannot read, test the key on its own first — one short request outside the tool:
curl https://api.heabsy.com/v1/chat/completions \
-H "Authorization: Bearer $HEABSY_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"qwen38","max_tokens":16,"messages":[{"role":"user","content":"Say hi"}]}'Troubleshooting
| What you see | What to change |
|---|---|
usage_metadata is empty when streaming | Set stream_usage=True; LangChain leaves it off for custom base URLs. |
| 404 on every call | base_url must be https://api.heabsy.com/v1. Do not turn on use_responses_api — Heabsy serves Chat Completions, not the Responses API. |
| Model not found | Use the exact catalog ID; GET /v1/models lists the IDs your key may call. |
| 403 with an HTML page ("Sorry, you have been blocked") | No key was sent at all: the key variable is empty or not set where the tool runs. Requests without a key are stopped before they reach the API; a wrong key gets a JSON 401 instead. |
Where do my prompts go?
From LangChain straight to api.heabsy.com. On our own models the request is processed in the European Economic Area and the text is not stored — we keep what billing needs: the model, the token counts and the time. Partner-hosted models are processed by third-party inference providers; each is marked in the catalog, and none of them carries the no-retention promise. The terms are in the data processing agreement, the invoice comes from an EU company.
FAQ
Does LangGraph work with Heabsy?+
Yes. LangGraph nodes call the same ChatOpenAI object; configure it once as above.
Can I use embeddings from Heabsy?+
No. Heabsy serves chat and reasoning models; keep your current embedding model for retrieval and use Heabsy for generation.
Is customer data processed in the EU?+
With our own models, yes: processing in the EEA, no stored prompts, invoice from an EU company. Partner-hosted models are marked in the catalog and carry no such promise.
Also set up:Vercel AI SDK · n8n · Open WebUI
LangChain is a trademark of LangChain, Inc.; Heabsy is not affiliated with it.