-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Closed as not planned
Description
Confirm this is an issue with the Python library and not an underlying OpenAI API
- This is an issue with the Python library
Describe the bug
Running in Google Colab. Updated to newest 1.66.2 library. Getting a "AttributeError: 'OpenAI' object has no attribute 'responses'" using an exact copy of the documentation example
To Reproduce
Open notebook in google colab
Install new library 1.66.2
follow documentation example from https://platform.openai.com/docs/api-reference/responses/create
Code snippets
!openai --version
openai 1.66.2
from openai import OpenAI
import os
api_key = userdata.get('OPENAI_API_KEY')
client = OpenAI(api_key=api_key)
response = client.responses.create(
model="gpt-4o-mini",
tools=[{ "type": "web_search_preview" }],
input="What was a positive news story from today?",
)
print(response)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
[<ipython-input-25-8b2de658b70d>](https://localhost:8080/#) in <cell line: 0>()
----> 1 response = client.responses.create(
2 model="gpt-4o-mini",
3 tools=[{ "type": "web_search_preview" }],
4 input="What was a positive news story from today?",
5 )
AttributeError: 'OpenAI' object has no attribute 'responses'
Check which attributes are available in the client, responses is not available.
('api_key', 'sk-p')
('audio', <openai.resources.audio.audio.Audio object at 0x79093aa4fb50>)
('auth_headers', {'Authorization': 'Bearer sk-p'})
('base_url', URL('https://api.openai.com/v1/'))
('batches', <openai.resources.batches.Batches object at 0x79093aa4fd50>)
('beta', <openai.resources.beta.beta.Beta object at 0x79093aa4fd90>)
('chat', <openai.resources.chat.chat.Chat object at 0x79097ef85fd0>)
('completions', <openai.resources.completions.Completions object at 0x79097ef85a10>)
('custom_auth', None)
('default_headers', {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'OpenAI/Python 1.61.1', 'X-Stainless-Lang': 'python', 'X-Stainless-Package-Version': '1.61.1', 'X-Stainless-OS': 'Linux', 'X-Stainless-Arch': 'x64', 'X-Stainless-Runtime': 'CPython', 'X-Stainless-Runtime-Version': '3.11.11', 'Authorization': 'Bearer sk-p', 'X-Stainless-Async': 'false', 'OpenAI-Organization': <openai.Omit object at 0x79093afbb7d0>, 'OpenAI-Project': <openai.Omit object at 0x79093a945850>})
('default_query', {})
('embeddings', <openai.resources.embeddings.Embeddings object at 0x79097ef85c90>)
('files', <openai.resources.files.Files object at 0x79097ef84290>)
('fine_tuning', <openai.resources.fine_tuning.fine_tuning.FineTuning object at 0x79093aa4f1d0>)
('images', <openai.resources.images.Images object at 0x79093aa4fc10>)
('max_retries', 2)
('models', <openai.resources.models.Models object at 0x79093aa4de10>)
('moderations', <openai.resources.moderations.Moderations object at 0x79093aa4cf90>)
('organization', None)
('project', None)
('qs', <openai._qs.Querystring object at 0x79093a9dc5d0>)
('timeout', Timeout(connect=5.0, read=600, write=600, pool=600))
('uploads', <openai.resources.uploads.uploads.Uploads object at 0x79093aa4fd10>)
('user_agent', 'OpenAI/Python 1.61.1')
('websocket_base_url', None)
('with_raw_response', <openai._client.OpenAIWithRawResponse object at 0x79093aa4fe10>)
('with_streaming_response', <openai._client.OpenAIWithStreamedResponse object at 0x79093aa4ed90>)
OS
Linux 3a991ab24ecd 6.1.85+ #1 SMP PREEMPT_DYNAMIC Thu Jun 27 21:05:47 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
Python version
3.11.11
Library version
1.66.2
Metadata
Metadata
Assignees
Labels
No labels