Catalog npm
Back to packageRELEASE DETAILS

1.1.0

npm

2schema

enhance tooling for AI agents

agentjsonopenapischematool
Published16 Mar 2025
Direct dependencies2
Transitive dependenciesNot calculated

README

Current package documentation

2schema

Automatically generate schemas from LLM function calling.

Instead of writing schemas by hand 🥱

import { OpenAI } from "openai";

const openai = new OpenAI();

const tools = [{
    "type": "function",
    "function": {
        "name": "getWeather",
        "description": "Get current temperature for a given location.",
        "parameters": {
            "type": "object",
            "properties": {
                // life is too short for schema
            },
        },
    }
}];

function getWeather(args: { location: string }) {
    return //...
}

const completion = await openai.chat.completions.create({
    model: "gpt-5",
    messages: [{ role: "user", content: "What is the weather like in Paris today?" }],
    tools,
});

Let the compiler works for you

import { fn } from "2schema";

const openai = new OpenAI();

class Tools {
  @fn
  static async getWeather(args: { location: string }) {
    return; // ...
  }
}

// will generate the schema for you
const tools = [Tools.getWeather.toJSONSchema()];

const completion = await openai.chat.completions.create({
  model: "gpt-5",
  messages: [
    { role: "user", content: "What is the weather like in Paris today?" },
  ],
  tools,
});

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 2

Native requirements
2 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
^5.8.2runtime
vitest
Environment
{
  "local_name": "vitest",
  "alias": false,
  "peer_metadata": null
}
^3.0.8development

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "461f9b76bb4599fbbccd3a8945579a108d5b2c04",
  "tarball": "https://registry.npmjs.org/2schema/-/2schema-1.1.0.tgz",
  "fileCount": 28,
  "integrity": "sha512-43WBQ4il67RAvbyYtNJ437A31/eGb0eSaLbHJ3uSvIMmf+Va/JiVU+pDS7l4z3M4EW9pOCPknJgxRLuBlvOHog==",
  "signatures": [
    {
      "sig": "MEYCIQD0ngjiptkcUz/QIG1nX0a693ju5oY+gYP3hN45knQHIQIhAO2GlbIj1VFEohH7G202mNJMc7Bw2M20zjkf1CpnRucN",
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
    }
  ],
  "unpackedSize": 52681
}

Repository

PENDING
chenhunghan/2schema

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 20 Oct, 19:18 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:9ea25c5fffb26a4bd8b1cf5ed33d7d2636bbe0a1063ecf122bed1b90a97ccc7a

Other collected versions

1.1.316 Mar1.1.216 Mar1.0.316 Mar1.0.216 MarView all collected versions →