Node.js SDK
Introduction
The Node.js SDK is available here.
Install
The SDK can be installed using npm:
npm i @hasura/promptql
Connect
You'll connect to an instnace by creating a client:
import { createPromptQLClient } from "@hasura/promptql";
const client = createPromptQLClient({
apiKey: "<your-promptql-api-key>",
ddn: {
url: "<your-project-endpoint>",
headers: {
Authorization: "<credential>",
},
},
});
Query the Natural Language API
Then, use your client to query the Natural Language API:
client
.queryStream({
artifacts: [],
interactions: [
user_message: {
text: 'what can you do?',
}
],
},
async (chunk) => {
console.log(chunk);
},
);
Query the Execute Program API
Or, the Exceute Program API:
function executeProgram(body: PromptQLExecuteRequest, executeOptions?: FetchOptions) Promise<PromptQlExecutionResult>;