Deep Agents Integration with The Grid | LangChain Setup
Use Deep Agents with The Grid through ChatOpenAI. Point to the OpenAI-compatible endpoint and set use_responses_api=False.
Deep Agents is LangChain's batteries-included agent harness. create_deep_agent() ships with planning, a filesystem, shell access, sub-agents, and context summarization on top of LangGraph. The Grid plugs in as a standard OpenAI-compatible model, but one setting matters more than anything else: you must force Chat Completions over the Responses API, or every request returns 404.
Prerequisites
Python 3.10+ with
deepagentsinstalled:uv add deepagents langchain-openai.A Grid account at app.thegrid.ai.
Credits in your account. The Grid is prepaid.
A Grid consumption API key from Settings → API Keys → Create Consumption Key.
Setup
1. Set the key as an environment variable
export GRID_API_KEY="your-consumption-api-key-here"Or add it to .env and load via python-dotenv.
2. Build a ChatOpenAI instance pointed at The Grid
This is the step that matters. Construct the model explicitly and pass the instance to create_deep_agent. Use an instrument from the current instruments list:
import os
from langchain_openai import ChatOpenAI
from deepagents import create_deep_agent
model = ChatOpenAI(
model="agent-prime",
api_key=os.environ["GRID_API_KEY"],
base_url="https://api.thegrid.ai/v1",
use_responses_api=False,
)
agent = create_deep_agent(model=model)3. (Optional) Tier sub-agents by task type
Each sub-agent's model field accepts a BaseChatModel instance. Use this to put the main loop on Agent Prime and delegate cheap classification work to Text Standard:
Sub-agents that omit model inherit the main agent's model. Always pass ChatOpenAI instances for sub-agents too, so use_responses_api=False stays explicit.
4. Invoke the agent
Verification
A realistic shakeout that exercises planning, filesystem, and a sub-agent:
If all four steps complete without 404s, your setup works end to end.
Troubleshooting
Last updated
Was this helpful?