Skip to main content

Faux AI

False LLM endpoints for testing

Faux AI provides a local server that interops with many LLM SDKs, so you can call these APIs as normal but receive mock or pre-determined responses at no cost!

The package currently provides clients for OpenAI, MistralAI, and Cohere with full support for streaming and async, and a limited client for Anthropic (no streaming support yet). It patches these libraries directly under the hood, so it will always be up to date.

Installation

# With pip
pip install fauxai

# With poetry
poetry add fauxai

Usage

Start the Faux AI server

This is the server that the mock clients will communicate with, we'll see later how we can configure our own pre-determined responses :).

# After installing fauxai
$ fauxai

Chat Completions

To use a mock version of these providers, you only have to change a single line of code (and just barely!):

- from openai import OpenAI         # Real Client
+ from fauxai.openai import OpenAI  # Fake Client
# Rest of the code remains the exact same!
client = OpenAI()

response = client.chat.completions.create(
        model="gpt-5",  # Model can be whatever you want
        messages=[
            {
                "role": "user",
                "content": "Hi faux!"
            }
        ],
        # All other kwargs are accepted, but ignored (except for stream ;)) 
        temperate = 0.7,
        top_k = 0.95
    )

print(response.choices[0].message.content)
# >> "Hi faux!"

# By default, the response will be a copy of the
# content of the last message in the conversation

Faux AI also provides clients for Cohere, Mistral and Anthropic:

# from mistralai.client import MistralClient
from fauxai.mistralai import MistralClient

client = MistralClient()

response = client.chat(model="mistral-turbo", messages=[{"role": "user", "content": "Hi!"}])

print(response.choices[0].message.content)
# >> "Hi!"
# from cohere import Client
from fauxai.cohere import Client

client = Client()

response = client.chat(model="Command-X", message="Hello!")

print(response.text)
# >> "Hello!"
# from anthropic import Anthropic
from fauxai.anthropic import Anthropic

client = Anthropic()

response = client.messages.create(
        model="claude-3.5-opus",
        messages=[{"role": "user", "content": "What's up!"}],
        max_tokens=1024
    )

print(response.content)
# >> "What's up!"

And of course the async versions of all clients are supported:

from fauxai.openai import AsyncOpenAI
from fauxai.anthropic import AsyncAnthropic
from fauxai.mistralai import MistralAsyncClient
from fauxai.cohere import AsynClient

Streaming is supported as well for the OpenAI, MistralAI, and Cohere clients:

from fauxai.openai import OpenAI

client = OpenAI()

response = client.chat.completions.create(
        model="gpt-5",
        messages=[{"role": "user", "content": "Hi mock!"}],
        stream = True
    )

# Streaming mock responses will yield one letter per chunk
for chunk in response:
    if chunk.choices:
        if chunk.choices[0].delta.content:
            print(chunk.choices[0].delta.content)
# >> H
# >> i
# >>  
# >> m
# >> o
# >> c
# >> k
# >> !

To learn more about the usage of each client, you can look at the docs of the respective provider, the mock clients are the exact same!

Tool Calling

All mock clients also work with tool calling! By default, a function call will be triggered if the substring "func" is found in the most recent message contents.

from mockai.openai import OpenAI

client = OpenAI()

response = client.chat.completions.create(
        model="gpt-5",
        messages=[{"role": "user", "content": "Function!"}],
    )

print(response.choices[0].message.tool_calls[0].function.name)
# >> "mock"
print(response.choices[0].message.tool_calls[0].function.arguments)
# >> "{"mock_arg": "mock_val"}"

However, the default function is not useful at all, so let's see how to set up our own pre-determined responses!

Configure responses

The fauxai server takes an optional path to a JSON file were we can establish our responses for both completions and tool calls.

The structure of the json is simple. Each key should be the the content of a user message, and the value is a dict with the wanted response.

# mock_responses.json
{
  "Hello?": {
    "type": "completion",
    "content": "How are ya!"
  },
  "What's the weather in San Fran": {
    "type": "function",
    "name": "get_weather",
    "arguments": {
      "weather": "42 degrees Fahrenheit"
    }
  }
}

When creating your .json file, please follow these rules:

  1. Each response must have a type key, whose value must be either completion or function, this will determine the response object of the client.
  2. Responses of type completion must have a content key with the string response.
  3. Responses of type function must have a name key with the name of the function, and a arguments key with a dict of args and values (Example: {"weather": "42 degrees Fahrenheit"}).

Load the json file

To create a fauxai server with our json file, we just need to pass it to the fauxai cli.

$ fauxai mock_responses.json

# The full file path can also be passed
$ fauxai ~/home/foo/bar/mock_responses.json

With this, our mock clients will have access to our pre-determined responses!

from fauxai.openai import OpenAI

client = OpenAI()

response = client.chat.completions.create(
        model="gpt-5",
        messages=[{"role": "user", "content": "Hello?"}],
    )

print(response.choices[0].message.content)
# >> "How are ya!"

response = client.chat.completions.create(
        model="gpt-5",
        messages=[{"role": "user", "content": "What's the weather in San Fran"}],
    )

print(response.choices[0].message.tool_calls[0].function.name)
# >> "get_weather"

print(response.choices[0].message.tool_calls[0].function.arguments)
# >> "{'weather': '42 degrees Fahrenheit'}"

Metadata

Release files for fauxai 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fauxai 0.1.0
File Size Uploaded Provenance Actions
fauxai-0.1.0.tar.gz 8.1 kB Without provenance Details for fauxai-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fauxai 0.1.0
File Interpreter ABI Platform Actions
fauxai-0.1.0-py3-none-any.whl Python 3 none any Details for fauxai-0.1.0-py3-none-any.whl

Total release size: 17.1 kB

Release files / fauxai-0.1.0.tar.gz

Download URL fauxai-0.1.0.tar.gz
Size 8.1 kB
Tags Source
SHA-256 checksum
How to use checksums
7b34d2752035b9f0db89017e0059584fb1e90c2e22f5d6f72d35e8ab38580b6b
BLAKE2b-256 checksum
How to use checksums
d56ef67400ccefbf0fd912a26938e1c15e524cff701c4544aa0090e507b06ecc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Linux/6.9.5-arch1-1

Release files / fauxai-0.1.0-py3-none-any.whl

Download URL fauxai-0.1.0-py3-none-any.whl
Size 8.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f352a0d3c960cba8d40f7299ba59d3002d863d27e3525cd7a95098735cfdc05d
BLAKE2b-256 checksum
How to use checksums
318ebae22c6801c5c3ffe2e0ca6193f59bba2c2b3283546134ae34178aa92c18
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.3 CPython/3.12.4 Linux/6.9.5-arch1-1

Security for fauxai 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page