https://github.com/mharrisb1/openai-responses-python
🧪🤖 Pytest plugin for OpenAI requests
https://github.com/mharrisb1/openai-responses-python
mock openai pytest-plugin python respx testing
Last synced: 19 days ago
JSON representation
🧪🤖 Pytest plugin for OpenAI requests
- Host: GitHub
- URL: https://github.com/mharrisb1/openai-responses-python
- Owner: mharrisb1
- License: mit
- Created: 2024-03-21T00:01:03.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-17T17:19:20.000Z (2 months ago)
- Last Synced: 2025-04-20T09:44:36.656Z (about 1 month ago)
- Topics: mock, openai, pytest-plugin, python, respx, testing
- Language: Python
- Homepage: https://mharrisb1.github.io/openai-responses-python/
- Size: 278 KB
- Stars: 42
- Watchers: 1
- Forks: 4
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# 🧪🤖 openai-responses
Pytest plugin for automatically mocking OpenAI requests. Powered by [RESPX](https://github.com/lundberg/respx).
[](https://github.com/openai/openai-python)
## Supported Endpoints
- [Chat](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_chat_completion.py)
- [Embeddings](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_embeddings.py)
- [Files](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_files.py)
- [Models](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_models.py)
- [Moderations](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_moderations.py)
- [Assistants](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_assistants.py)
- [Threads](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_threads.py)
- [Messages](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_messages.py)
- [Runs](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_runs.py)
- [Run Steps](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_run_steps.py)
- [Vector Stores](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_vector_stores.py)
- [Vector Store Files](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_vector_store_files.py)
- [Vector Store File Batches](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_vector_store_file_batches.py)View full support coverage [here](https://mharrisb1.github.io/openai-responses-python/coverage).
> [!TIP]
> ✨ Support for creating [streaming responses](https://mharrisb1.github.io/openai-responses-python/user_guide/streaming/) added in v0.4## Usage
Just decorate any test function that makes a call to the OpenAI API (either using [openai-python](https://github.com/openai/openai-python) or with [HTTPX](https://www.python-httpx.org/)).
```python
import openaiimport 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](https://github.com/mharrisb1/openai-responses-python/tree/main/examples) or [docs](https://mharrisb1.github.io/openai-responses-python) for more.
## Installation
[](https://badge.fury.io/py/openai-responses)
[](https://pypi.org/project/openai-responses/)
[](https://pypi.org/project/openai-responses/)Available on [PyPI](https://pypi.org/project/openai-responses/)
```bash
pip install openai-responses
```## Documentation
[](https://mharrisb1.github.io/openai-responses-python)
See the [documentation site](https://mharrisb1.github.io/openai-responses-python) for more info.
## License
[](https://opensource.org/blog/license/mit)
See [LICENSE](https://github.com/mharrisb1/openai-responses-python/blob/main/LICENSE) for more info.
## Contributing
[](https://github.com/mharrisb1/openai-responses-python/issues)
[](https://pypistats.org/packages/openai-responses)See [CONTRIBUTING.md](https://github.com/mharrisb1/openai-responses-python/blob/main/CONTRIBUTING.md) for info on PRs, issues, and feature requests.
## Changelog
See [CHANGELOG.md](https://github.com/mharrisb1/openai-responses-python/blob/main/CHANGELOG.md) for summarized notes on changes or view [releases](https://github.com/mharrisb1/openai-responses-python/releases) for more details information on changes.