Skip to main content
You can invoke Agent Builder agents from your applications using the LangGraph SDK. You can use all the same API methods as you would with any other LangGraph deployment.

Authentication

To authenticate with the deployment your Agent Builder agents are running on, you must provide a personal access token (PAT) API key tied to your user to the api_key arg when instantiating the LangGraph SDK client, or via the X-API-Key header. Then, set the X-Auth-Scheme header to langsmith-api-key. If the PAT you pass is not tied to the owner of the agent, your request will be rejected with a 404 not found error. If the agent you’re trying to invoke is a workspace agent, and you’re not the owner, you’ll be able to preform all the same operations as you would in the UI (read-only).

Example

To invoke the agent, you can copy the code below, and replace the agent_id and api_url with the correct values. Alternatively, you can copy the same code shown below, but pre-populated with the proper agent ID and API URL, via the Agent Builder UI. To do this, navigate to the agent you want to invoke, visit the editor page, then click on the settings icon in the top right corner, and click View code snippets. You’ll still need to manually set your LANGGRAPH_API_KEY environment variable.
  • Python
  • TypeScript
import os
from dotenv import load_dotenv
from langgraph_sdk.client import get_client

load_dotenv()

agent_id = "your-agent-id"

# This must be a PAT API key tied to your user
api_key = os.getenv("LANGGRAPH_API_KEY")
api_url = "https://prod-agent-builder-5ccea139413e5ef289ab8e5d04688e11.us.langgraph.app"

client = get_client(
    url=api_url,
    api_key=api_key,
    headers={
        "X-Auth-Scheme": "langsmith-api-key",
    },
)

async def get_assistant(agent_id: str):
    agent = await client.assistants.get(agent_id)
    print(agent)

if __name__ == "__main__":
    import asyncio
    asyncio.run(get_assistant(agent_id))
Use a PAT (Personal Access Token) API key tied to your user account. Set the X-Auth-Scheme header to langsmith-api-key for authentication. If you implemented custom authentication, pass your user’s token in headers so the agent can use user‑scoped tools. See “Add custom authentication”.

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.