# 🧪🤖 openai-responses
Pytest plugin for automatically mocking OpenAI requests. Powered by [RESPX](https://github.com/lundberg/respx).
[![sdk support](https://img.shields.io/badge/SDK_Support-v1.50+-white?logo=openai&logoColor=black&labelColor=white)](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
[![PyPI version](https://badge.fury.io/py/openai-responses.svg)](https://badge.fury.io/py/openai-responses)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/openai-responses.svg)](https://pypi.org/project/openai-responses/)
[![PyPI - Downloads](https://img.shields.io/pypi/dm/openai-responses)](https://pypi.org/project/openai-responses/)
Available on [PyPI](https://pypi.org/project/openai-responses/)
```bash
pip install openai-responses
```
## Documentation
[![Docs](https://github.com/mharrisb1/openai-responses-python/actions/workflows/docs.yml/badge.svg)](https://mharrisb1.github.io/openai-responses-python)
See the [documentation site](https://mharrisb1.github.io/openai-responses-python) for more info.
## License
[![PyPI - License](https://img.shields.io/pypi/l/openai-responses)](https://opensource.org/blog/license/mit)
See [LICENSE](https://github.com/mharrisb1/openai-responses-python/blob/main/LICENSE) for more info.
## Contributing
[![Open Issues](https://img.shields.io/github/issues/mharrisb1/openai-responses-python)](https://github.com/mharrisb1/openai-responses-python/issues)
[![Stargazers](https://img.shields.io/github/stars/mharrisb1/openai-responses-python?style)](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/36/38/d91a4b00235dc94a313401066587488e1ede053f0f80359a6e8088cf2149/openai_responses-0.11.2.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[![sdk support](https://img.shields.io/badge/SDK_Support-v1.50+-white?logo=openai&logoColor=black&labelColor=white)](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[![PyPI version](https://badge.fury.io/py/openai-responses.svg)](https://badge.fury.io/py/openai-responses)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/openai-responses.svg)](https://pypi.org/project/openai-responses/)\n[![PyPI - Downloads](https://img.shields.io/pypi/dm/openai-responses)](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[![Docs](https://github.com/mharrisb1/openai-responses-python/actions/workflows/docs.yml/badge.svg)](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[![PyPI - License](https://img.shields.io/pypi/l/openai-responses)](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[![Open Issues](https://img.shields.io/github/issues/mharrisb1/openai-responses-python)](https://github.com/mharrisb1/openai-responses-python/issues)\n[![Stargazers](https://img.shields.io/github/stars/mharrisb1/openai-responses-python?style)](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.2",
"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": "2f44244f749b2073f893e8dec12ec62b8717f55f89690e9c10daea2dd9bcb3b8",
"md5": "da19a775110ecf5c86cba66a99497d44",
"sha256": "302993370c6c76a502bb58b1a8ee750c6b10d74f9093b995bb54801c79b06e17"
},
"downloads": -1,
"filename": "openai_responses-0.11.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "da19a775110ecf5c86cba66a99497d44",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.9",
"size": 51665,
"upload_time": "2024-11-18T16:20:33",
"upload_time_iso_8601": "2024-11-18T16:20:33.199872Z",
"url": "https://files.pythonhosted.org/packages/2f/44/244f749b2073f893e8dec12ec62b8717f55f89690e9c10daea2dd9bcb3b8/openai_responses-0.11.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3638d91a4b00235dc94a313401066587488e1ede053f0f80359a6e8088cf2149",
"md5": "c862d9c6f6a975a08e48e592c0da4d87",
"sha256": "2de311d18aa5518630802f0487abbf5c3254ac8eaa0d334c5ad9146bd7082e2f"
},
"downloads": -1,
"filename": "openai_responses-0.11.2.tar.gz",
"has_sig": false,
"md5_digest": "c862d9c6f6a975a08e48e592c0da4d87",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.9",
"size": 26577,
"upload_time": "2024-11-18T16:20:34",
"upload_time_iso_8601": "2024-11-18T16:20:34.397330Z",
"url": "https://files.pythonhosted.org/packages/36/38/d91a4b00235dc94a313401066587488e1ede053f0f80359a6e8088cf2149/openai_responses-0.11.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-18 16:20:34",
"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"
}