Skip to main content
Use a normal HTTP function as the boundary between your agent and LangSearch. This example uses LangChain’s tool decorator with the Python standard library.
Bind the tool using the tool-calling API of your chosen model or agent. The tool returns source links, context, and usage.input_tokens / usage.output_tokens; ask your agent to retain those links when it answers.
Network and HTTP errors should be handled by your agent’s tool-error policy. Do not convert failures into an empty search result.