Skip to content

AttributeError: 'function' object has no attribute 'completion' #1142

@abhiram1809

Description

@abhiram1809

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


client = OpenAI(api_key = "API-KEY")
chat_completion = client.chat.completions.create(
    messages=[
        {
            "role": "user",
            "content": "Say this is a test",
        }
    ],
    model="gpt-3.5-turbo",
)

Gives an Error on Colab
`---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
in <cell line: 1>()
----> 1 chat_completion = client.chat.completions.create(
2 messages=[
3 {
4 "role": "user",
5 "content": "Say this is a test",

AttributeError: 'function' object has no attribute 'completions'
`
Version: openai 1.12.0

To Reproduce

client = OpenAI(api_key = "API-KEY")
chat_completion = client.chat.completions.create(
    messages=[
        {
            "role": "user",
            "content": "Say this is a test",
        }
    ],
    model="gpt-3.5-turbo",
)

Code snippets

Already Attached

OS

linux

Python version

Python 3.11

Library version

openai v1.12.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions