Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
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.
Run with npx:
npx aimock
Install in your project:
npm install aimock
# or
yarn add aimock
Install globally:
npm install -g aimock
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 5001MOCK_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."
AIMock Server provides the following main routes:
/v1/chat/completions
- Mocks the chat model completions of OpenAI. Supports both stream and non-stream mode.
Accepts POST requests.
/v1/completions
- Mocks the text model completions of OpenAI. Supports both stream and non-stream mode. Accepts
POST requests.
/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.
If you find any issues or have any suggestions, feel free to open an issue or submit a pull request.
This project is inspired by MockAI
This project is licensed under the MIT license. For more details, please refer to the LICENSE
file.
FAQs
An OpenAI api simulator for developing and testing
The npm package aimock receives a total of 1 weekly downloads. As such, aimock popularity was classified as not popular.
We found that aimock demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.