Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

aimock

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

aimock

An OpenAI api simulator for developing and testing

  • 0.2.2
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

aimock

AIMock is a service built on Node.js and Express.js designed to emulate the behavior of OpenAI's APIs. It can receive API requests and return mock responses for chat completions, text generation, and image generation. This service is perfect for development and testing when actual AI-generated results are not required.

Installation

Run with npx:

npx aimock

Install in your project:

npm install aimock
# or
yarn add aimock

Install globally:

npm install -g aimock

Getting Started

You can set environment variables in a .env file to specify configurations for the service. The following environment variables are available:

  • MOCK_PORT: The port for the service, default is 5001
  • MOCK_TYPE: The type of mock responses, options are "random", "echo", or "fixed", default is "random"
  • MOCK_FILE: The path to a text file for randomly generating response content, default is "data/contents.txt"
  • MOCK_FILE_SEPARATOR: The separator for different response contents in the text file, default is the newline character ("\n")

After the service is started, you will see the following output on the console:

Server is running at http://localhost:5001

You can visit http://localhost:5001 to verify that the service is running. If the service is working correctly, you will see the greeting message: "Hello World! This is OpenAI Mock Server."

Usage

AIMock Server provides the following main routes:

  1. /v1/chat/completions - Mocks the chat model completions of OpenAI. Supports both stream and non-stream mode. Accepts POST requests.

  2. /v1/completions - Mocks the text model completions of OpenAI. Supports both stream and non-stream mode. Accepts POST requests.

  3. /v1/images/generations - Mocks the image generation of OpenAI. Accepts POST requests.

You can provide a mockType parameter in the request body to specify the type of mock response. Acceptable mockType values are "random", "echo", or "fixed". The default is "random".

For more detailed API documentation and examples, please refer to the /docs directory in the project.

Contribution

If you find any issues or have any suggestions, feel free to open an issue or submit a pull request.

Credits

This project is inspired by MockAI

License

This project is licensed under the MIT license. For more details, please refer to the LICENSE file.

Keywords

FAQs

Package last updated on 27 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc