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

@hasura/promptql

v0.4.0

Published

A Node.js SDK allows you to interact with PromptQL API

Readme

PromptQL NodeJS SDK

A Node.js SDK for PromptQL API.

Install

Run the following command:

npm install @hasura/promptql

Get started

Prerequisite

Use PromptQL SDK

Create client

Create the PromptQL client with required configurations:

import { createPromptQLClientV2 } from '@hasura/promptql';

const client = createPromptQLClientV2({
    apiKey: '<your-promptql-api-key>',
    ddn: {
        headers: {
            'Authorization': '<credential>'
        }
    },
    // You can define a lazy function for the ddn options.
    //
    // ddn: () => {{ 
    //     headers: {
    //         'Authorization': '<credential>'
    //     }
    // }}  
});

Run a Query

const runQuery = (text: string) => {
    return client.query({
        artifacts: [],
        interactions: [
            {
                user_message: {
                    text,
                }
            }
        ],
        ddn: {
            // you can override the default ddn config, 
            // for example, dynamic auth credentials
            headers: {}
        }
    });

    return response.
}

runQuery('what can you do?').then((response) => {
    console.log(response)
});

Reference

Version 2

Natural Language

The API version 2 simplifies request parameters:

  • The DDN URL is replaced by build_version.
  • llm, ai_primitives_llm, and system_instructions are removed.

To use the API v2, you need to create a PromptQL Client v2:

import { createPromptQLClientV2 } from '@hasura/promptql';

const client = createPromptQLClientV2({
    apiKey: '<your-promptql-api-key>',
    ddn: {
        // build_version: '<your-build-version>',
        headers: {
            'Authorization': '<credential>'
        }
    },
});
Non-Streaming
function query(
    body: PromptQLQueryRequestV2,
    queryOptions?: FetchOptions
) => Promise<QueryResponse>
Streaming
function queryStream(
    body: PromptQLQueryRequestV2, 
    callback?: (data: QueryResponseChunk) => void | Promise<void>, 
    queryOptions?: FetchOptions
) Promise<Response>;

Execute Program

Execute a PromptQL program with your data.

function executeProgram: (
    body: PromptQLExecuteRequestV2,
    executeOptions?: FetchOptions,
) => Promise<PromptQlExecutionResult>

Version 1

Natural Language

The Natural Language Query API allows you to interact with PromptQL directly, sending messages and receiving responses.

Non-Streaming
function query(
    body: PromptQLQueryRequestV1,
    queryOptions?: FetchOptions
) => Promise<QueryResponse>
Streaming

The streaming response sends chunks of data in Server-Sent Events (SSE) format. If the callback isn't set the client returns the raw response and you need to handle the response manually.

function queryStream(
    body: PromptQLQueryRequestV1, 
    callback?: (data: QueryResponseChunk) => void | Promise<void>, 
    queryOptions?: FetchOptions
) Promise<Response>;

Example:

client
    .queryStream({
        artifacts: [],
        interactions: [
            user_message: {
                text: 'what can you do?',
            }
        ],
    },
    async (chunk) => {
        console.log(chunk);
    },
);

Execute Program

Execute a PromptQL program with your data.

function executeProgram: (
    body: PromptQLExecuteRequestV1,
    executeOptions?: FetchOptions,
) => Promise<PromptQlExecutionResult>

Development

Generate types

Use the following command to update TypeScript types of PromptQL APIs from OpenAPI document.

npm run openapi:ts