desktop computer, programmer
# P4U AI Client Node API Library [Task Automation System Homepage](https://app.apihub4ai.com) [Documentation: API](https://app.apihub4ai.com/doc) A client tool for communication with the AI model hub. Thanks to the tasks you define in the admin panel, you can write your own backend for any application without knowing how to program. You can access many AI models from various providers in one API. The tool allows for easy and quick implementation of functions managed by artificial intelligence models, which we program by describing the task to be performed. The API allows for automation and task chaining. With this tool, you can easily create an AI agent that will answer phone calls, respond to emails, chat, write articles, or social media posts. This library provides convenient access to the REST API with TypeScript or JavaScript. ## Installation ### Npm [AH4AI Npm package](https://www.npmjs.com/package/p4u-client-ai) ```sh npm install --save p4u-client-ai # or yarn add p4u-client-ai ``` # AIClient Documentation The AIClient class is designed to interact with the API in the [task automation system](https://app.apihub4ai.com/doc). It manages user authentication and task operations. # AIClient User Documentation ## Overview The `AIClient` class provides an interface for interacting with the API at `https://api.programmers4u.com`. This client supports user authentication, task operations such as creating, viewing, running, and deleting tasks. It also provides several helper methods for basic interactions with the API. ## Enums ### `AudioModelsEnum` - **OAIWHISPER1**: `whisper-1` - **OAITTS1**: `tts-1` - **OAITTS1HD**: `tts-1-hd` ### `GPTModelsEnum` - **OAIGPT35Turbo**: `gpt-3.5-turbo` - **OAIGPT35Turbo1106**: `gpt-3.5-turbo-1106` - **OAIGPT35Turbo16k**: `gpt-3.5-turbo-16k` - **OAIGPT35TurboInstruct**: `gpt-3.5-turbo-instruct` - **OAIGPT4**: `gpt-4` - **OAIGPT4o**: `gpt-4o` - **OAIGPT432k**: `gpt-4-32k` - **OAIGPT4VisionPreview**: `gpt-4-vision-preview` - **OAIGPT41106Preview**: `gpt-4-1106-preview` - **Claude3Opus**: `claude-3-opus-20240229` - **Claude3Sonet**: `claude-3-sonnet-20240229` - **Claude3Haiku**: `claude-3-haiku-20240307` ## Interfaces ### `IDelete` ```typescript interface IDelete { idTask: string; } ``` ### `IInsert` ```typescript interface IInsert { name: string; context: string; model: string; instruction: string; } ``` ### `IRequest` ```typescript interface IRequest { ask: string; context: string; idTask: string; } ``` ## Methods ### `login(userName: string, password: string): Promise` Logs in a user using the provided `username` and `password`. ### `makeRequest(method: string, endpoint: string, data?: any): Promise>` Makes an HTTP request to the specified `endpoint` using the provided HTTP method `method` and optional data `data`. ### `pingPong(): Promise>` Checks if the connection to the API is active. ### `listTasks(): Promise>` Lists all tasks available to the user. ### `runTask(request: IRequest): Promise>` Runs a specified task based on the provided `request`. ### `deleteTask(request: IDelete): Promise>` Deletes a task specified by `request`. ### `createTask(request: IInsert): Promise>` Creates a new task using the provided `request`. ## Usage Example Start the test ```sh npm run test or yarn test ``` ```typescript import { IRequest } from "../interfaces/request.interface"; import AIClient from "../index"; const userName = "XXX@XXX"; const password = "XXXXXXX"; const startTest = async () => { const client = new AIClient(); await client.login(userName, password); const listOfTasks = await client.listTasks(); console.log(listOfTasks); const testText = "Description of your task here."; const taskRequest: IRequest = { idTask: "52468971-a06e-413d-9b3a-212b53aad693", ask: testText, context: " ", }; const taskRun = await client.runTask(taskRequest); console.log(taskRun); }; startTest(); ``` [#automation](https://app.apihub4ai.com/) [#artificialintelligence](https://app.apihub4ai.com/) [#API](https://app.apihub4ai.com/) [#tasks](https://app.apihub4ai.com/) [#library](https://app.apihub4ai.com/)

share:

FAQ

AIClient is a class designed to interact with the API in the task automation system. It manages user authentication and task operations such as creating, displaying, running, and deleting tasks.
AIClient supports various AI models, including audio models (e.g., whisper-1, tts-1) and GPT models (e.g., gpt-3.5-turbo, gpt-4) from Anthropic (Claude), and Stable Diffusion.
To install the p4u-client-ai library, use the command npm install --save p4u-client-ai or yarn add p4u-client-ai.
To log in to AIClient, use the login method, providing the username and password. Example: await client.login(userName, password);
Using AIClient, you can perform operations such as creating tasks, displaying the list of tasks, running tasks, and deleting tasks.
To create a new task using AIClient, use the createTask method, providing the appropriate data in the IInsert format. Example: const request: IInsert = { name: 'Task Name', context: 'Context', model: 'AI Model', instruction: 'Instruction' }; await client.createTask(request);
To run a task using AIClient, use the runTask method, providing the appropriate data in the IRequest format. Example: const request: IRequest = { idTask: 'Task ID', ask: 'Question', context: 'Context' }; await client.runTask(request);
To delete a task using AIClient, use the deleteTask method, providing the appropriate data in the IDelete format. Example: const request: IDelete = { idTask: 'Task ID' }; await client.deleteTask(request);
To check if the API connection is active, use the pingPong method. Example: await client.pingPong();
To display the list of tasks available to the user, use the listTasks method. Example: const listOfTasks = await client.listTasks();

Cookie Settings

We use cookies to manage the Services and to collect information about you and your use of the Services. Cookies help us to recognize you, customize or personalize your experience, market additional products or services to you, and analyze the use of our Services to make it more useful to you. Cookies may also allow us to collect demographic and statistical data and provide this information to our service providers to help deliver their services.

more
APIHUB4AI
2024 Programmers4u ©️ All rights reserved
Let's talk on Discord
discord icon