Skip to content

openshieldai/mockai

Repository files navigation

MockAI service

This is a mock service for multiple AI services.

Documentation

Documentation

OpenAI API

Supported endpoints:

  • /openai/v1/chat/completions (streaming supported)
  • /openai/v1/images/generations
  • /openai/v1/models
  • /openai/v1/models/:id
  • /anthropic/v1/messages (streaming supported)

Echo mode

If you set answer in the request body, the service will echo the answer back.

Extra parameters

  • request_delay: Delay the response time.
  • answer: Echo the answer back.

Example code

OpenAI

cd examples/openai
pnpm install
pnpm run build
pnpm run start

Anthropic

cd examples/anthropic
pnpm install
pnpm run build
pnpm run start

Deploy

Environment variables

  • MAX_COMPLETION_TOKENS: The maximum number of tokens in the response.
  • MAXIMUM_REQUEST_DELAY: The maximum request delay.
  • RATELIMITING_ENABLED: Whether to enable rate limiting.
  • ENV: The environment name.
  • DOC_URL: The documentation URL.
npm install -g pnpm
cp wrangler_example.toml wrangler.toml

Customize the wrangler.toml file with your own values.

pnpm install
wrangler login
wrangler deploy -e production