Accessing Messages from custom route in Langgraph Platform instance

Hello folks!

I’m having trouble accessing messages based on a thread_id in a custom route attached to the Langgraph Platform deployment.

What is the best approach to doing this?
I’ve tried importing and compiling the graph with the thread_id, but I get no messages in a thread I’m confident messages exist. The documentation says that accessing the internal postgres DB is not recommended/allowed. Can someone point me in the right direction? Thanks!

I’d recommend using the API/SDK.

from langgraph_sdk import get_client

sdk = get_client() # url can be None to connect to the loopback transport (current deployment)

async def my_route(...):
    await sdk.threads. get_state(thread_id)
    ...