Skip to content

polly3d/mockai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MockAI

MockAI is a mock server for OpenAI's API. It allows you to simulate API responses for development and testing purposes.

Features

  • Supports the following endpoint.

    • /v1/completions
    • /v1/chat/completions
    • /v1/images/generations
  • Allows you to specify the type of mock response: echo, random, or fixed.

  • Supports both single responses and streaming responses.

  • Reads random responses from a text file.

Getting Started

  1. Install dependencies:
npm install
  1. Set env

Open .env file and set your environment.

SERVER_PORT=5002
MOCK_TYPE=random
MOCK_FILE_PATH=data/contents.txt
MOCK_FILE_SEPERATER="@@@@"
  1. Start server:
npm start

Environment Variables

  • SERVER_PORT: The port the server listens on.
  • DEFAULT_MOCK_TYPE: The default type of mock response.
  • MOCK_FILE_PATH: The path to the text file of random responses.
  • MOCK_FILE_SEPERATER: Random contents seperater. As there may be instances of line breaks or code outputs, it is not advisable to separate with line breaks.

Contributing

Contributions are welcome! Please submit a pull request or create an issue to get started.

About

MockAI is a mock server for OpenAI's API. It allows you to simulate Chat Completions API responses for development and testing purposes.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published