# 🧪🤖 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 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](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.
Raw data
{
"_id": null,
"home_page": "https://mharrisb1.github.io/openai-responses-python/",
"name": "openai-responses",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.9",
"maintainer_email": null,
"keywords": "openai, pytest, testing",
"author": "Michael Harris",
"author_email": "mharris@definite.app",
"download_url": "https://files.pythonhosted.org/packages/3a/26/516b287fdc616be6ca34b3901ea6acca1dd0a8ddbc28a61b2747611a68db/openai_responses-0.11.6.tar.gz",
"platform": null,
"description": "# \ud83e\uddea\ud83e\udd16 openai-responses\n\nPytest plugin for automatically mocking OpenAI requests. Powered by [RESPX](https://github.com/lundberg/respx).\n\n[](https://github.com/openai/openai-python)\n\n## Supported Endpoints\n\n- [Chat](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_chat_completion.py)\n- [Embeddings](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_embeddings.py)\n- [Files](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_files.py)\n- [Models](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_models.py)\n- [Moderations](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_moderations.py)\n- [Assistants](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_assistants.py)\n- [Threads](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_threads.py)\n- [Messages](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_messages.py)\n- [Runs](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_runs.py)\n- [Run Steps](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_run_steps.py)\n- [Vector Stores](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_vector_stores.py)\n- [Vector Store Files](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_vector_store_files.py)\n- [Vector Store File Batches](https://github.com/mharrisb1/openai-responses-python/blob/main/examples/test_vector_store_file_batches.py)\n\nView full support coverage [here](https://mharrisb1.github.io/openai-responses-python/coverage).\n\n> [!TIP]\n> \u2728 Support for creating [streaming responses](https://mharrisb1.github.io/openai-responses-python/user_guide/streaming/) added in v0.4\n\n## Usage\n\nJust 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/)).\n\n```python\nimport openai\n\nimport openai_responses\n\n\n@openai_responses.mock()\ndef test_create_assistant():\n client = openai.Client(api_key=\"sk-fake123\")\n\n assistant = client.beta.assistants.create(\n instructions=\"You are a personal math tutor.\",\n name=\"Math Tutor\",\n tools=[{\"type\": \"code_interpreter\"}],\n model=\"gpt-4-turbo\",\n )\n\n assert assistant.name == \"Math Tutor\"\n```\n\nSee [examples](https://github.com/mharrisb1/openai-responses-python/tree/main/examples) or [docs](https://mharrisb1.github.io/openai-responses-python) for more.\n\n## Installation\n\n[](https://badge.fury.io/py/openai-responses)\n[](https://pypi.org/project/openai-responses/)\n[](https://pypi.org/project/openai-responses/)\n\nAvailable on [PyPI](https://pypi.org/project/openai-responses/)\n\n```bash\npip install openai-responses\n```\n\n## Documentation\n\n[](https://mharrisb1.github.io/openai-responses-python)\n\nSee the [documentation site](https://mharrisb1.github.io/openai-responses-python) for more info.\n\n## License\n\n[](https://opensource.org/blog/license/mit)\n\nSee [LICENSE](https://github.com/mharrisb1/openai-responses-python/blob/main/LICENSE) for more info.\n\n## Contributing\n\n[](https://github.com/mharrisb1/openai-responses-python/issues)\n[](https://pypistats.org/packages/openai-responses)\n\nSee [CONTRIBUTING.md](https://github.com/mharrisb1/openai-responses-python/blob/main/CONTRIBUTING.md) for info on PRs, issues, and feature requests.\n\n## Changelog\n\nSee [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.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "\ud83e\uddea\ud83e\udd16 Pytest plugin for automatically mocking OpenAI requests",
"version": "0.11.6",
"project_urls": {
"Documentation": "https://mharrisb1.github.io/openai-responses-python/",
"Homepage": "https://mharrisb1.github.io/openai-responses-python/",
"Repository": "https://github.com/mharrisb1/openai-responses-python"
},
"split_keywords": [
"openai",
" pytest",
" testing"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "c177a9f28071ffa6ca5c85f30e2142e9b839d0ef5c8ec03cd5ea9d208a1f441d",
"md5": "7c6c12d9e2838b7df11c5e2b0b785967",
"sha256": "b47f738ffee1a2c50991a85e1c413de22eba7b9813136f77b959cde0a15028bf"
},
"downloads": -1,
"filename": "openai_responses-0.11.6-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7c6c12d9e2838b7df11c5e2b0b785967",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 51668,
"upload_time": "2025-01-24T15:42:05",
"upload_time_iso_8601": "2025-01-24T15:42:05.718548Z",
"url": "https://files.pythonhosted.org/packages/c1/77/a9f28071ffa6ca5c85f30e2142e9b839d0ef5c8ec03cd5ea9d208a1f441d/openai_responses-0.11.6-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3a26516b287fdc616be6ca34b3901ea6acca1dd0a8ddbc28a61b2747611a68db",
"md5": "14722eb7107c7289d006721069acf33a",
"sha256": "8beaa3e341ae6918a6db53c1797f79ca5061eb804803a067a689ac97f4fbd006"
},
"downloads": -1,
"filename": "openai_responses-0.11.6.tar.gz",
"has_sig": false,
"md5_digest": "14722eb7107c7289d006721069acf33a",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 26584,
"upload_time": "2025-01-24T15:42:07",
"upload_time_iso_8601": "2025-01-24T15:42:07.542686Z",
"url": "https://files.pythonhosted.org/packages/3a/26/516b287fdc616be6ca34b3901ea6acca1dd0a8ddbc28a61b2747611a68db/openai_responses-0.11.6.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-24 15:42:07",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mharrisb1",
"github_project": "openai-responses-python",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"tox": true,
"lcname": "openai-responses"
}