Integrations / LangChain
ConnectDocumented
Run LangChain applications with Badgr
Use ChatOpenAI against Badgr for chains and agents. Keep GPU jobs as separate tools your chain calls.
The steps follow the tool's documented settings. No tested run is recorded for this page yet.
Why use Badgr for LangChain
- Badgr interface
- AI API
- Where LangChain fits
- External framework
- Why Badgr
- Model calls and compute tools
- ChatOpenAI works against Badgr with two settings changed, so chains and agents keep their code.
- Model calls stay cheap to try; heavy steps can be a separate, capped job rather than a bigger model.
- A job tool returns a receipt and output files, so an agent's GPU use is visible.
What you can do
- A retrieval chain that answers from your documents
- Structured extraction with output parsers
- An agent whose tools call out to a capped Badgr job
Quickstart: Python chain
import os
from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
llm = ChatOpenAI(
model="badgr-auto",
base_url="https://aibadgr.com/v1",
api_key=os.environ["BADGR_API_KEY"],
)
chain = ChatPromptTemplate.from_template("Summarise: {text}") | llm
print(chain.invoke({"text": "Badgr runs AI work on cloud GPUs."}).content)How it works
- 1.Your chain builds a prompt
- 2.ChatOpenAI sends it to Badgr
- 3.The reply flows on to the next step of the chain
What you get
- Chain results from Badgr models
- Optional: results from a GPU job your tool starts
Requirements
- A Badgr API key, saved as BADGR_API_KEY (get one at /get-api-key)
- Python 3.9 or newer
- Packages: langchain-openai and langchain-core
What it costs
- AI requests are billed per request at the rate listed for the model you choose (see Models). This page does not quote a fixed price.
- Your application keeps control of how many requests it sends. Use the limits in your own tool to cap usage.
- Model calls and GPU jobs are billed separately. A GPU job tool should always pass a maximum cost.
See pricing for how billing works.
Proof
No tested run is recorded for this integration yet. A receipt and example output will be added here after a real run, not before.
Troubleshooting
Calls go to the wrong host
Set base_url explicitly. An OPENAI_API_BASE environment variable can override your code.
Tool calling errors
Not every model supports tool calling. Test with a plain prompt first, then add tools.
Need a GPU, not just a model
Chat models answer prompts. For training or image work, wrap a Badgr job as a tool. See the LangGraph page for the pattern.
Developer reference
Ready to start with LangChain?
Every run or service has a spending limit you set before it starts.