Prerequisites
- A LangSmith account with an Agent Builder agent
- A Personal Access Token (PAT) for authentication
- The LangGraph SDK installed:
Authentication
To authenticate with your agent’s Agent Builder deployment, provide a LangSmith Personal Access Token (PAT) to theapi_key argument when instantiating the LangGraph SDK client, or via the X-API-Key header. If using X-API-Key, you must also 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 and you’re not the owner, you can perform all the same operations as you would in the UI (read-only).
Example
To get your agent’sagent_id and api_url:
- Navigate to the agent in Agent Builder.
- Click the settings icon in the top right corner.
- Click View code snippets to see pre-populated values for your agent.
agent_id and api_url with the values from your agent’s code snippets.
Create a .env file in your project root with your Personal Access Token:
.env
- Python
- TypeScript
Use a Personal Access Token (PAT) tied to your LangSmith account. Set the
X-Auth-Scheme header to langsmith-api-key for authentication. If you implemented custom authentication, pass the user’s token in headers so the agent can use user-scoped tools. See Add custom authentication.