How can I see the requests and responses from LangChain and LangGraph?
17:50 11 Apr 2025

I'm looking for an easy way to see the communication between LangChain/LangGraph and the server, that is I want to see what requests are made and what responses the server gives. I want to be able to understand the whole information flow to have a better grasp of what the LLMs are doing.

I know about a couple of options so far:

  • mitmproxy (a proxy to catch communication) I don't love this method as it's a little bit hacky and you need to create a certificate if you use https.
  • Wireshark, I've been using it with Ollama locally and it works. However it involves too many steps.

I would like to have some kind of log with all the requests done from my code and all the responses from the server. I would like for this to be automatically generated so I would only need to access it somehow, a file maybe. Also I would like this to work not only on Ollama locally without https but even if using an external API like the one from OpenAI or others.

I'm using macOS, but it would be great if the answer works on any OS. Also, I am using Jupyter so it would be nice if it worked there, not a deal breaker if it doesn't though.

This is what I am able to see in Wireshark, which is exactly what I would like to see (minus the http headers). Wireshark request/response from Ollama

logging request response langchain langgraph