Integrations / LangGraph
Give LangGraph agents cloud GPU jobs
Add a tool to your LangGraph agent that starts a capped Badgr job and returns the result. Your graph stays where it is.
A setup guide only. Badgr has not tested this path, so expect to adjust it.
Why use Badgr for LangGraph
- Badgr interface
- Run
- Where LangGraph fits
- External orchestrator
- Why Badgr
- Submit agent compute tasks
- Give an agent a GPU without changing your graph: it calls a tool, the tool starts a job.
- Every job has a maximum cost set in your code, so the agent cannot raise its own budget.
- Jobs end and stop billing when the command exits, and each leaves a receipt.
What you can do
- An agent that fine-tunes or renders when a step needs a GPU
- A graph node that runs a test suite as a finite job
- Long jobs the agent checks on instead of waiting
Quickstart: A tool that starts a capped job
import subprocess
from langchain_core.tools import tool
@tool
def run_gpu_job(command: str) -> str:
"""Run a command as a Badgr GPU job with a $2 cap and return its output."""
done = subprocess.run(
["badgr", "run", ".", "--cmd", command, "--max-cost", "2"],
capture_output=True, text=True, timeout=3600,
)
return done.stdout[-4000:] or done.stderr[-4000:]
# Add run_gpu_job to the tools list of your agent node.How it works
- 1.The agent decides a step needs a GPU
- 2.The tool calls the Badgr CLI with a maximum cost
- 3.The job runs and stops when the command exits
- 4.The tool returns the output to the graph
What you get
- Job output text
- Artifacts you can download with badgr artifacts <id>
- A receipt for each job
Requirements
- A Badgr API key, saved as BADGR_API_KEY (get one at /get-api-key)
- The Badgr CLI installed and logged in on the machine running the graph
- A funded Badgr balance for GPU jobs
- An existing LangGraph app
What it costs
- Each job is billed for the time it runs, and stops billing when it finishes.
- The --max-cost flag bounds each job. The tool above sets it in code, so the model cannot raise it.
- Model calls from the graph are billed separately.
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
The tool hangs
Set a subprocess timeout as shown, and start long work detached, then check it later with badgr status.
Job not found or billing after a crash
Run badgr status. A timeout on your side does not always mean nothing started. Stop anything you did not mean to leave running with badgr down <id>.
Agent keeps calling the tool
Cap tool calls in your graph and keep the per-job cost small.
Developer reference
Ready to start with LangGraph?
Every run or service has a spending limit you set before it starts.