npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

toolsyai-client-sdk

v0.1.0

Published

AI Tools Marketplace Client SDK

Readme

AI Tools Marketplace Client SDK

A TypeScript SDK for easily consuming AI tools from the AI Tools Marketplace platform.

Installation

npm install aiapi-client-sdk

Quick Start

import { initialize } from "aiapi-client-sdk";

// Initialize with your API key
const client = initialize("your-api-key");

// Call a tool
async function translateText() {
  const result = await client.callTool("translateText", {
    text: "Hello, world!",
    targetLanguage: "fr",
  });

  console.log(result.translatedText); // [fr] Hello, world!
}

translateText();

Integrations

LangChain Integration

The SDK can be used with LangChain to create agents that use marketplace tools:

import { ChatOpenAI } from "@langchain/openai";
import { initialize, convertToLangChainTools } from "aiapi-client-sdk";
import { AgentExecutor, createOpenAIFunctionsAgent } from "langchain/agents";
import { ChatPromptTemplate } from "@langchain/core/prompts";

async function main() {
  // Initialize the client
  const client = initialize("your-api-key");

  // Convert tools to LangChain format
  const tools = await convertToLangChainTools(client);

  // Create an agent with the tools
  const model = new ChatOpenAI({ modelName: "gpt-4" });
  const prompt = ChatPromptTemplate.fromMessages([
    [
      "system",
      "You are a helpful assistant. Use the available tools when appropriate.",
    ],
    ["user", "{input}"],
  ]);

  const agent = await createOpenAIFunctionsAgent({
    llm: model,
    tools,
    prompt,
  });

  const agentExecutor = new AgentExecutor({
    agent,
    tools,
    maxIterations: 5,
  });

  // Run the agent
  const result = await agentExecutor.invoke({
    input: "What's the weather like in New York?",
  });

  console.log(result.output);
}

OpenAI Native Integration

The SDK can be used directly with the OpenAI SDK:

import { OpenAI } from "openai";
import { initialize, convertToOpenAIFunctions } from "aiapi-client-sdk";

async function main() {
  // Initialize the client
  const client = initialize("your-api-key");

  // Get tools as OpenAI functions
  const functions = await convertToOpenAIFunctions(client);

  // Use with OpenAI
  const openai = new OpenAI({ apiKey: "your-openai-key" });

  const response = await openai.chat.completions.create({
    model: "gpt-4-turbo",
    messages: [{ role: "user", content: "What's the weather in New York?" }],
    tools: functions,
    tool_choice: "auto",
  });

  const message = response.choices[0].message;

  // Handle tool calls
  if (message.tool_calls && message.tool_calls.length > 0) {
    const toolResults = await Promise.all(
      message.tool_calls.map(async (toolCall) => {
        const toolName = toolCall.function.name;
        const toolArgs = JSON.parse(toolCall.function.arguments);

        // Call the tool via the marketplace client
        const result = await client.callTool(toolName, toolArgs);

        return {
          tool_call_id: toolCall.id,
          role: "tool",
          name: toolName,
          content: JSON.stringify(result),
        };
      })
    );

    // Get final response with tool results
    const finalResponse = await openai.chat.completions.create({
      model: "gpt-4-turbo",
      messages: [
        { role: "user", content: "What's the weather in New York?" },
        message,
        ...toolResults,
      ],
    });

    console.log(finalResponse.choices[0].message.content);
  }
}

Google Gemini Integration

The SDK can be used with Google's Gemini API:

import { GoogleGenerativeAI } from "@google/generative-ai";
import { initialize, convertToGeminiFunctions } from "aiapi-client-sdk";

async function main() {
  // Initialize the client
  const client = initialize("your-api-key");

  // Get tools as Gemini functions
  const functionDeclarations = await convertToGeminiFunctions(client);

  // Initialize Gemini client
  const genAI = new GoogleGenerativeAI("your-gemini-api-key");

  // Create a model with the tools
  const model = genAI.getGenerativeModel({
    model: "gemini-1.5-pro",
    tools: { functionDeclarations },
  });

  // Start a chat session
  const chat = model.startChat();

  // Send a message that might trigger tool use
  const result = await chat.sendMessage("What's the weather in New York?");

  // Handle tool calls if any
  if (
    result.response.functionCalls &&
    result.response.functionCalls.length > 0
  ) {
    for (const functionCall of result.response.functionCalls) {
      const { name, args } = functionCall;

      // Call the tool via the marketplace client
      const toolResult = await client.callTool(name, args);

      // Send the result back to Gemini
      const followupResult = await chat.sendMessage({
        functionResponse: {
          name: name,
          response: { result: toolResult },
        },
      });

      console.log(followupResult.response.text());
    }
  }
}

Anthropic Claude Integration

The SDK can be used with Anthropic's Claude AI:

import Anthropic from "@anthropic-ai/sdk";
import { initialize, convertToAnthropicTools } from "aiapi-client-sdk";

async function main() {
  // Initialize the client
  const client = initialize("your-api-key");

  // Get tools as Anthropic tools
  const tools = await convertToAnthropicTools(client);

  // Initialize Anthropic client
  const anthropic = new Anthropic({
    apiKey: "your-anthropic-api-key",
  });

  // Create a message with tool use
  const response = await anthropic.messages.create({
    model: "claude-3-opus-20240229",
    max_tokens: 1024,
    system: "You are a helpful assistant. Use tools when appropriate.",
    messages: [{ role: "user", content: "What's the weather in New York?" }],
    tools: tools,
  });

  // Handle tool calls if any
  const toolUses = response.content
    .filter((content) => content.type === "tool_use")
    .map((content) => (content.type === "tool_use" ? content : null))
    .filter(Boolean);

  if (toolUses.length > 0) {
    // Process each tool call
    const toolResults = await Promise.all(
      toolUses.map(async (toolUse) => {
        const { name, input } = toolUse;

        // Call the tool via the marketplace client
        const result = await client.callTool(name, input);

        return {
          role: "user",
          content: [
            {
              type: "tool_result",
              tool_use_id: toolUse.id,
              content: JSON.stringify(result),
            },
          ],
        };
      })
    );

    // Get final response with tool results
    const finalResponse = await anthropic.messages.create({
      model: "claude-3-opus-20240229",
      max_tokens: 1024,
      system: "You are a helpful assistant. Use tools when appropriate.",
      messages: [
        { role: "user", content: "What's the weather in New York?" },
        { role: "assistant", content: response.content },
        ...toolResults,
      ],
    });

    console.log(
      finalResponse.content
        .map((c) => (c.type === "text" ? c.text : "[non-text content]"))
        .join("\n")
    );
  }
}

Vercel AI SDK Integration

This SDK provides seamless integration with the Vercel AI SDK:

import { streamText } from "ai";
import { openai } from "@ai-sdk/openai";
import { initialize, convertToAISDKTools } from "aiapi-client-sdk";

async function main() {
  // Initialize the client
  const client = initialize("your-api-key");

  // Convert marketplace tools to AI SDK format
  const { tools, handleToolCall } = await convertToAISDKTools(client);

  // Use with the AI SDK
  const result = await streamText({
    model: openai("gpt-4o"),
    messages: [{ role: "user", content: 'Translate "Hello" to French' }],
    tools,
    onToolCall: async ({ name, input }) => {
      return handleToolCall(name, input);
    },
  });

  for await (const chunk of result.textStream) {
    process.stdout.write(chunk);
  }
}

API Reference

initialize(apiKey, options?)

Initialize the client with your API key.

const client = initialize("your-api-key", {
  apiUrl: "https://your-custom-api-url.com", // Optional custom API URL
  cacheSchemas: true, // Whether to cache schemas (default: true)
});

Client Methods

client.initialize()

Initializes the client by fetching available tools. Called automatically when needed.

client.callTool(name, input)

Call an AI tool by name with the given input parameters.

const result = await client.callTool("toolName", {
  param1: "value1",
  param2: "value2",
});

client.getToolNames()

Get an array of available tool names.

const toolNames = await client.getToolNames();
console.log(toolNames); // ['translateText', 'summarizeText', ...]

client.getTools()

Get detailed information about all available tools.

const tools = await client.getTools();

client.getTool(name)

Get detailed information about a specific tool.

const tool = await client.getTool("translateText");
console.log(tool.description); // "Translate text to another language"

LangChain Integration

convertToLangChainTools(client)

Convert marketplace tools to LangChain-compatible tools.

const tools = await convertToLangChainTools(client);

getLangChainTool(client, toolName)

Get a specific tool as a LangChain tool.

const tool = await getLangChainTool(client, "translateText");

OpenAI Integration

convertToOpenAIFunctions(client)

Convert marketplace tools to OpenAI function format.

const functions = await convertToOpenAIFunctions(client);

handleOpenAIFunctionCall(client, response)

Handle an OpenAI function call response.

const result = await handleOpenAIFunctionCall(client, openaiResponse);

getOpenAIFunction(client, toolName)

Get a specific tool as an OpenAI function.

const function = await getOpenAIFunction(client, "translateText");

Gemini Integration

convertToGeminiFunctions(client)

Convert marketplace tools to Gemini function format.

const functionDeclarations = await convertToGeminiFunctions(client);

handleGeminiFunctionCall(client, functionCall)

Handle a Gemini function call.

const result = await handleGeminiFunctionCall(client, geminiFunctionCall);

getGeminiFunction(client, toolName)

Get a specific tool as a Gemini function.

const function = await getGeminiFunction(client, "translateText");

Anthropic Integration

convertToAnthropicTools(client)

Convert marketplace tools to Anthropic Claude format.

const tools = await convertToAnthropicTools(client);

handleAnthropicToolCall(client, toolCall)

Handle an Anthropic tool call.

const result = await handleAnthropicToolCall(client, claudeToolCall);

getAnthropicTool(client, toolName)

Get a specific tool as an Anthropic tool.

const tool = await getAnthropicTool(client, "translateText");

AI SDK Integration

convertToAISDKTools(client)

Convert the marketplace client to AI SDK compatible tools.

const { tools, handleToolCall } = await convertToAISDKTools(client);

Examples

See the examples/ directory for complete usage examples.