Automatically mock OpenAI requests
Project description
🧪🤖 openai-responses
Pytest plugin for automatically mocking OpenAI requests. Powered by RESPX.
Supported Routes
/v1/chat/completions
/v1/embeddings
/v1/files
/v1/assistants
/v1/threads
(+ messages, runs, and steps)
View full support coverage here.
Usage
Just decorate any test function that makes a call to the OpenAI API (either using openai-python or with HTTPX).
import openai
import openai_responses
@openai_responses.mock()
def test_create_assistant():
client = openai.Client(api_key="sk-fake123")
assistant = client.beta.assistants.create(
instructions="You are a personal math tutor.",
name="Math Tutor",
tools=[{"type": "code_interpreter"}],
model="gpt-4-turbo",
)
assert assistant.name == "Math Tutor"
See examples or docs for more.
Installation
Available on PyPi
pip install openai-responses
Documentation
See the documentation site for more info.
License
See LICENSE for more info.
Contributing
See CONTRIBUTING.md for info on PRs, issues, and feature requests.
Changelog
See CHANGELOG.md for summarized notes on changes or view releases for more details information on changes.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
openai_responses-0.3.3.tar.gz
(17.8 kB
view hashes)
Built Distribution
Close
Hashes for openai_responses-0.3.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2a7dd6ad9fe1f948dd49ef4fa5bc5288ae2a85ffc466fdbba9276ae7d23d405 |
|
MD5 | 47cd8511b75265cbc8c2c2f1f582b6f8 |
|
BLAKE2b-256 | ec22fa7837aa10a17e7fc3fd114cba879b598c24b01695dec0381b918cdf77f2 |