client.Completion issue can any one help?

this is my code :"response = client.Completion.create(
model=“gpt-3.5-turb”,
messages=[
{
“role”: “user”,
“content”: “who won the first cricket worldcup?”
}
],
max_tokens=150,
)
" this is an error :“AttributeError: ‘OpenAI’ object has no attribute ‘Completion’

As gpt-3.5-turbo is a chat completions model, you need to adjust for this. Here’s the updated code (note, I also corrected for the typo in the model name):

response = client.chat.completions.create(
    model="gpt-3.5-turbo"
    messages=[
        {"role": "user", "content": "who won the first cricket world cup?"}
    ],
    max_tokens=150
)

how can i resolv this error :“RateLimitError: Error code: 429 - {‘error’: {‘message’: ‘You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.’, ‘type’: ‘insufficient_quota’, ‘param’: None, ‘code’: ‘insufficient_quota’}}”

Have you added credits to your API account? OpenAI no longer offers the free tier/free credits, hence you need to prefund the API use.

1 Like