Skip to content

LangChain

Use Chronary’s calendar tools in LangChain. new ChronaryToolkit(...).getTools() returns an array of LangChain StructuredTools you can bindTools to a chat model or pass to an agent.

Terminal window
npm install @chronary/toolkit @chronary/sdk @langchain/core
# plus a model integration, e.g. @langchain/openai
npm install @langchain/openai
import { ChatOpenAI } from '@langchain/openai';
import { ChronaryToolkit } from '@chronary/toolkit/langchain';
const tools = new ChronaryToolkit({
apiKey: process.env.CHRONARY_API_KEY!,
}).getTools();
const llm = new ChatOpenAI({ model: 'gpt-4o' }).bindTools(tools);
const res = await llm.invoke('When is my next calendar event?');
console.log(res.tool_calls);

For a full agent loop, drop the same tools into createReactAgent (from @langchain/langgraph/prebuilt) or AgentExecutor so LangChain runs the tool calls and returns a final answer.

Each tool’s invoke() resolves to the result as a JSON string. A failed call (an API error, or input the tool’s rules refuse) resolves to a JSON error object such as {"error":"validation_error","message":"..."} instead of throwing, so the model can read it and correct itself. Input that does not match the tool’s advertised JSON Schema is refused by LangChain before the tool runs.