Skip to content
AGNT
Prompt library
IntegrationDeveloper

LangChain tool definition for AGNT

Define AGNT API endpoints as LangChain tools with proper schemas and error handling.

AGNT Developer Relationsclaude-opus-4, gpt-4o

LangChain's tool abstraction lets any agent framework call AGNT's API as native tools. This prompt generates properly typed LangChain StructuredTool definitions for AGNT's core endpoints: search_venues, create_booking, get_user_memory, and calorie_scan.

The generated tools include Zod schemas for input validation, proper error handling that surfaces AGNT's BackendError messages, and rate-limit awareness so the LangChain agent backs off gracefully instead of hammering the API.

The prompt

<<<
You define AGNT API endpoints as LangChain StructuredTool instances.

INPUTS:
  - AGNT API base URL (default: https://api.agntdot.com)
  - AGNT API key
  - endpoints to wrap: list from [search_venues, create_booking, get_user_memory, calorie_scan, dupe_search]

FOR EACH ENDPOINT, GENERATE:
  1. A Zod schema matching the endpoint's request body.
  2. A StructuredTool subclass with:
     - name: agnt_<endpoint_name>
     - description: tight, routing-optimized (see /prompts/tool-description-tightener)
     - schema: the Zod schema
     - _call(): fetch to the AGNT API with auth header, parse response, handle errors.
  3. Error handling:
     - 401 → "API key invalid or expired. Check AGNT_API_KEY."
     - 429 → "Rate limited. Retry after {retry-after} seconds."
     - 4xx → surface the error message from response body.
     - 5xx → "AGNT API error. Retry once, then escalate."

OUTPUT: a single TypeScript file exporting all tool instances, ready to import into a LangChain agent.
>>>

When to use

Use this when building a LangChain agent that needs to call AGNT's API. The generated tools include proper error handling that most hand-written wrappers miss.

Works with

Related guides

Share as social post

LangChain tool definition for AGNT (langchain + claude-code) — Define AGNT API endpoints as LangChain tools with proper schemas and error handling. https://agntdot.com/prompts/langchain-tool-definition

202 / 280 chars

Related prompts

Take it further.

Pair the prompt with the right tool in the stack and the right integration recipe.