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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@gram-ai/sdk

v0.2.3

Published

Developer-friendly Typescript SDK to interact with Gram toolsets. Gram allows you to use your agentic tools in a variety of different frameworks and protocols. Gram tools can be used with pretty much any model that supports function calling via a chat c

Downloads

92

Readme

@gram-ai/sdk

Developer-friendly Typescript SDK to interact with Gram toolsets. Gram allows you to use your agentic tools in a variety of different frameworks and protocols. Gram tools can be used with pretty much any model that supports function calling via a chat completions or responses style API.

SDK Installation

The SDK can be installed with either npm, pnpm, bun or yarn package managers.

NPM

npm add @gram-ai/sdk

PNPM

pnpm add @gram-ai/sdk

Bun

bun add @gram-ai/sdk

Yarn

yarn add @gram-ai/sdk zod

# Note that Yarn does not install peer dependencies automatically. You will need
# to install zod as shown above.

[!NOTE] This package is published as an ES Module (ESM) only. For applications using CommonJS, use await import("@gram-ai/sdk") to import and use this package.

AI SDK by Vercel

import { generateText } from 'ai';
import { VercelAdapter } from "@gram-ai/sdk/vercel";
import { createOpenAI } from "@ai-sdk/openai";

const key = process.env.GRAM_API_KEY
const vercelAdapter = new VercelAdapter({apiKey: key});

const openai = createOpenAI({
    apiKey: process.env.OPENAI_API_KEY
});

const tools = await vercelAdapter.tools({
    project: "default",
    toolset: "default",
    environment: "default"
});

const result = await generateText({
    model: openai("gpt-4"),
    tools,
    maxSteps: 5,
    prompt: "Can you tell me what tools you have available?"
});

console.log(result.text);

LangChain

import { LangchainAdapter } from "@gram-ai/sdk/langchain";
import { ChatOpenAI } from "@langchain/openai";
import { createOpenAIFunctionsAgent, AgentExecutor } from "langchain/agents";
import { pull } from "langchain/hub";
import { ChatPromptTemplate } from "@langchain/core/prompts";

const key = process.env.GRAM_API_KEY
const langchainAdapter = new LangchainAdapter({apiKey: key});

const llm = new ChatOpenAI({
  modelName: "gpt-4",
  temperature: 0,
  openAIApiKey: process.env.OPENAI_API_KEY,
});

const tools = await langchainAdapter.tools({
  project: "default",
  toolset: "default",
  environment: "default",
});

const prompt = await pull<ChatPromptTemplate>(
  "hwchase17/openai-functions-agent"
);

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

const executor = new AgentExecutor({
  agent,
  tools,
  verbose: false,
});

const result = await executor.invoke({
  input: "Can you tell me what tools you have available?"
});

console.log(result.output);

OpenAI Function Calling

import { OpenAI } from 'openai';
import { OpenAIAdapter } from "@gram-ai/sdk/openai";

const key = process.env.GRAM_API_KEY
const openaiAdapter = new OpenAIAdapter({apiKey: key});

const openai = new OpenAI({
    apiKey: process.env.OPENAI_API_KEY
});

const tools = await openaiAdapter.tools({
    project: "default",
    toolset: "default",
    environment: "default"
});

const result = await openai.chat.completions.create({
    model: openai("gpt-4"),
    tools,
    maxSteps: 5,
    prompt: "Can you tell me what tools you have available?"
});

console.log(result.text);

Vanilla Function Calling

import { FunctionCallingAdapter } from "@gram-ai/sdk/functioncalling";

const key = process.env.GRAM_API_KEY ?? "";

// vanilla client that matches the function calling interface for direct use with model provider APIs
const functionCallingAdapter = new FunctionCallingAdapter({apiKey: key});

const tools = await functionCallingAdapter.tools({
  project: "default",
  toolset: "default",
  environment: "default",
});

// exposes name, description, parameters, and an execute and aexcute (async) function
console.log(tools[0].name)
console.log(tools[0].description)
console.log(tools[0].parameters)
console.log(tools[0].execute)

Passing in User Defined Environment Variables

If preferred, it's possible to pass in user defined environment variables into tools calls rather than using hosted gram environments.

import { generateText } from 'ai';
import { VercelAdapter } from "@gram-ai/sdk/vercel";
import { createOpenAI } from "@ai-sdk/openai";

const key = process.env.GRAM_API_KEY
const vercelAdapter = new VercelAdapter({apiKey: key, environmentVariables: {
    "MY_TOOL_TOKEN": "VALUE"
}});

const openai = createOpenAI({
    apiKey: process.env.OPENAI_API_KEY
});

const tools = await vercelAdapter.tools({
    project: "default",
    toolset: "default",
    environment: "default"
});

const result = await generateText({
    model: openai("gpt-4"),
    tools,
    maxSteps: 5,
    prompt: "Can you tell me what tools you have available?"
});

console.log(result.text);

MCP

Gram also instantly allows you to expose and use any toolset as a hosted MCP server.

{
    "mcpServers": {
      "GramTest": {
        "command": "npx",
        "args": [
          "mcp-remote",
          "https://app.getgram.ai/mcp/default/default/default",
          "--allow-http",
          "--header",
          "Authorization:${GRAM_KEY}"
        ],
        "env": {
          "GRAM_KEY": "Bearer <your-key-here>"
        }
      }
    }
  }

You also have the option to add a unique slug to these servers and make them publicly available to pass your own credentials.

{
    "mcpServers": {
      "GramSlack": {
        "command": "npx",
        "args": [
          "mcp-remote",
          "https://app.getgram.ai/mcp/speakeasy-team-default",
          "--allow-http",
          "--header",
          "MCP-SPEAKEASY_YOUR_TOOLSET_CRED:${VALUE}"
        ]
      }
    }
  }