> ## Documentation Index
> Fetch the complete documentation index at: https://docs.groundforge.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect a LangChain Agent

> Initialize GroundForge around a LangChain or LangGraph Agent.

Create the Agent normally, then initialize GroundForge once after the Agent is constructed.

```python theme={null}
import os
from groundforge_langchain import init as init_groundforge

runtime = init_groundforge(
    agent=agent,
    endpoint="https://platform.groundforge.ai",
    api_key=os.environ["GROUNDFORGE_API_KEY"],
    agent_id=os.environ["GROUNDFORGE_AGENT_ID"],
    tenant_id=os.environ["GROUNDFORGE_TENANT_ID"],
    workspace_id=os.environ["GROUNDFORGE_WORKSPACE_ID"],
    name="Weather Agent",
    execution_mode="managed_intake",
    serve=False,
)
```

Continue using the Agent as before:

```python theme={null}
result = agent.invoke(
    {"messages": [{"role": "user", "content": "What is the weather in Ottawa?"}]}
)
```

No custom caller metadata is required. GroundForge creates one Trace for the invocation and instruments supported model and tool activity.

Use [Service Mode](/sdk/service-mode) when Channels should dispatch requests to the running process.

## Example

<Card title="groundforgeai/demo" icon="github" iconType="brands" href="https://github.com/groundforgeai/demo" horizontal cta="Open repository">
  Follow the full setup in [LangChain Agent Example](/examples/langchain-agent).
</Card>


## Related topics

- [Python SDK](/sdk/overview.md)
- [LangChain Agent Example](/examples/langchain-agent.md)
- [LangChain Agent with Adapters](/examples/langchain-adapter.md)
- [Examples](/examples/index.md)
