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

aizon

v1.0.0

Published

Get structured, validated JSON output from any LLM without complex prompt engineering.

Readme

Aizon: Intelligent Structured Data Extraction from LLMs

NPM Version License: MIT TypeScript Minified Size NPM Downloads

Aizon is a powerful and reliable library designed to simplify the process of extracting valid, schema-compliant JSON from Large Language Models (LLMs). It handles the complex prompt engineering, token optimization (TOON), and self-healing retry logic automatically, ensuring you get the structured data you need with minimal effort.

✨ Features

  • Schema Enforcement Guaranteed output that strictly adheres to your provided JSON schema.

  • TOON Optimization: Token Optimization on-the-fly to reduce prompt size, leading to lower API costs and faster responses.

  • Self-Healing: Automatic retry logic to correct common LLM formatting errors (e.g., forgetting to wrap JSON in markdown blocks).

  • Granular Control (aiConfig): Fine-tune underlying model parameters like temperature, topP, and maxTokens using the new aiConfig object.

📦 Installation

Installing Aizon is straightforward. Run the following command in your project directory:

npm install aizon
# Or
yarn add aizon  

🚀 Usage Guide

To use Aizon, you must provide your JSON Schema and the textual prompt (message) from which you want to extract data.

1. Basic Extraction

This example demonstrates how to extract a simple user object:

TypeScript

// Step 1: Imports
import { Aizon } from 'aizon';

// Step 2: Define your JSON Schema
const PRODUCT_SCHEMA = {
  type: "object",
  properties: {
    productName: { type: "string", description: "The official name of the product." },
    priceUSD: { type: "number", description: "The price in US Dollars." },
    tags: { 
      type: "array", 
      items: { type: "string" },
      description: "A list of relevant product categories or tags."
    }
  },
  required: ["productName", "priceUSD"],
};

// Step 3: Run Aizon with enhanced parameters
async function runExtraction() {
  const message = "The new 'Giga-Widget' is available for $120. It's a key component for automation and software development.";
    //Define the model's persona/role
  const systemInstruction = "You are a highly concise Product Data Parser. Your only job is to extract commercial data from the user's text into the requested JSON schema. Do not add any commentary or pleasantries.";
  
  try {
    const result = await Aizon.run({
      provider: 'openai', 
      model: 'gpt-4o-mini',
      apiKey: 'sk-...', 
      SCHEMA: PRODUCT_SCHEMA,
      message: message,
      systemInstruction: systemInstruction,
      maxRetries: 3 
    });

    console.log("Extracted Product Data:", result);
  } catch (error) {
    console.error("Extraction failed:", error);
  }
}

runExtraction();

2. Advanced: Configuring the LLM (aiConfig)

Aizon's new aiConfig object gives you full control over the underlying LLM generation parameters. To ensure the output is less creative and more deterministic (ideal for accurate JSON extraction), set a low temperature.

import { Aizon } from 'aizon';

// ... (Define your SCHEMA and message)

async function runControlledExtraction() {
  const result = await Aizon.run({
    provider: 'anthropic',
    model: 'claude-3-haiku-20240307',
    apiKey: 'sk-ant...',
    SCHEMA: YOUR_SCHEMA,
    message: "Describe the key benefits of Aizon in detail.",
    systemInstruction: systemInstruction,
    maxRetries: 3
    
    aiConfig: {
      temperature: 0.1,    // Low temp for high determinism/accuracy
      maxTokens: 1024,     // Limit size
      presencePenalty: 0.5,    // Discourage introduction of new topics
      frequencyPenalty: 0.1,   // Mildly discourage repeating words/phrases
      seed: 42,  // Ensure reproducibility
    },
  });

  console.log("Controlled and Reproducible Result:", result);
}

⚙️ Configuration Parameters

The Aizon.run() function accepts a single configuration object with the following properties:

1. Score & Weight Configuration

| Parameter | Type | Required | Description | | :--- | :--- | :--- | :--- | | provider | string | Yes | The name of the LLM provider. Supported values: 'openai' | | model | string | Yes | The specific model to use (e.g., 'gpt-4o-mini', 'gemini-2.5-flash') | | apiKey | string | Yes | Your provider's API key. | | SCHEMA | object | Yes | Your complete JSON Schema object. | | message | string | Yes | The input text (prompt) from which data should be extracted. | | aiConfig | AIConfig | No | Advanced LLM generation settings. See table below. | | systemInstruction | string | No | Instructions to define the LLM's role, rules, and style. Highly recommended for accuracy. | | maxRetries | number | No | Maximum number of attempts Aizon will make to self-heal and extract valid JSON (Default: 2). | | returnPromptOnly | boolean | No | If true, Aizon returns the final generated prompt string instead of making the API call. Useful for debugging (Default: false). |

AIConfig Properties (Advanced LLM Tuning)

| Property | Type | Range | Description | | :--- | :--- | :--- | :--- | | temperature | number | 0.0 - 1.0 | Controls randomness. Lower values favor deterministic outputs. | | maxTokens | number | Integer | The maximum number of tokens the model should generate. | | topP | number | 0.0 - 1.0 | Top P sampling (nucleus sampling). | | stopSequences | string[] | Max 4 | Sequences where the model will immediately stop generating tokens. | | presencePenalty | number | Provider dependent | Penalty applied to tokens based on whether they appear in the text so far. Higher values encourage discussing new topics. | | frequencyPenalty | number | Provider dependent | Penalty applied to tokens based on how frequently they have appeared in the text so far. Higher values discourage repetition of words/phrases. | | seed | number | Integer | A seed value to make the model's output reproducible for debugging and testing. |

🛠️ Error Handling

Always wrap your Aizon.run() call in a try...catch block. If extraction fails after all self-healing attempts (maxRetries), a detailed error will be thrown.

try {
  const data = await Aizon.run({ /* ... */ });
} catch (error) {
  console.error("Critical data extraction failure. The LLM could not produce valid JSON after all retries.", error.message);
  // Implement fallback logic here
}

👤 Author & Contributor

This package is maintained and developed by Hamza Tayyab. I am passionate about creating clean, efficient, and secure frontend tools. Feel free to connect or check out my other projects!

| Platform | Link | | :--- | :--- | | 🌐 Portfolio | https://linktr.ee/hm.za | | 📧 Email | [email protected] | | 💻 GitHub | Follow me on GitHub https://github.com/hmzatayab | | 🎁 Other Packages | Check out my other open-source projects https://www.npmjs.com/~hamzatayab |

📄 License

MIT License

Copyright (c) [2025] [Hamza Tayyab]

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.