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 theapi_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 theagent_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
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â.