Custom Tool Integration
Use kirha.tools() to fetch available tools and register them as function calls in any LLM SDK. The model decides which tools to call, and kirha.executeTool() handles execution against real-time data providers.
Fetch and convert tools
import { Kirha } from "kirha";
const kirha = new Kirha({
apiKey: process.env.KIRHA_API_KEY,
});
const kirhaTools = await kirha.tools({ vertical: "crypto" }); OpenAI SDK
Use kirha.tools() with the OpenAI Node SDK and the Responses API:
import OpenAI from "openai";
import { Kirha } from "kirha";
const openai = new OpenAI();
const kirha = new Kirha({ apiKey: process.env.KIRHA_API_KEY });
const kirhaTools = await kirha.tools({ vertical: "crypto" });
// Convert Kirha tools to OpenAI function definitions
const tools = kirhaTools.map((t) => ({
type: "function" as const,
function: {
name: t.name,
description: t.description,
parameters: t.inputSchema,
},
}));
let contents: OpenAI.Responses.ResponseInput = [
{ role: "user", content: "What is the current price of Bitcoin?" },
];
// Agentic loop
while (true) {
const response = await openai.responses.create({
model: "gpt-5.2",
input: contents,
tools,
});
// Find function calls in the response
const functionCalls = response.output.filter(
(item) => item.type === "function_call"
);
if (functionCalls.length === 0) {
// No more tool calls, print the final text
const text = response.output
.filter((item) => item.type === "message")
.flatMap((item) => item.content)
.filter((c) => c.type === "output_text")
.map((c) => c.text)
.join("");
console.log(text);
break;
}
// Execute each tool call and feed results back
contents = [{ type: "response", response }];
for (const call of functionCalls) {
const result = await kirha.executeTool(call.name,
JSON.parse(call.arguments),
);
contents.push({
type: "function_call_output",
call_id: call.call_id,
output: JSON.stringify(result),
});
}
}Google GenAI SDK
Use kirha.tools() with the Google GenAI SDK:
import { GoogleGenAI, Type } from "@google/genai";
import { Kirha } from "kirha";
const ai = new GoogleGenAI({ apiKey: process.env.GOOGLE_API_KEY });
const kirha = new Kirha({ apiKey: process.env.KIRHA_API_KEY });
const kirhaTools = await kirha.tools({ vertical: "crypto" });
// Convert Kirha tools to Google GenAI function declarations
const tools = [{
functionDeclarations: kirhaTools.map((t) => ({
name: t.name,
description: t.description,
parameters: t.inputSchema,
})),
}];
let contents: any[] = [
{ role: "user", parts: [{ text: "What is the current price of Bitcoin?" }] },
];
// Agentic loop
while (true) {
const result = await ai.models.generateContent({
model: "gemini-3-flash-preview",
contents,
config: { tools },
});
if (result.functionCalls && result.functionCalls.length > 0) {
const { name, args } = result.functionCalls[0];
const toolResult = await kirha.executeTool(name!, args);
// Feed the result back to the model
contents.push({
role: "model",
parts: [{ functionCall: result.functionCalls[0] }],
});
contents.push({
role: "user",
parts: [{
functionResponse: {
name,
response: { result: toolResult },
},
}],
});
} else {
console.log(result.text);
break;
}
}Works with any SDK
The same pattern applies to any LLM that supports function calling. Fetch tools with kirha.tools(), convert them to the SDK's tool format, and execute them with kirha.executeTool().