When following the openai ruby gem docs:
response = client.chat(
parameters: {
model: "gpt-3.5-turbo", # Required.
messages: [{ role: "user", content: "Hello!"}], # Required.
temperature: 0.7,
})
puts response.dig("choices", 0, "message", "content")
# /Users/st/.rbenv/versions/3.3.0/lib/ruby/gems/3.3.0/gems/faraday-2.9.0/lib/faraday/response/raise_error.rb:34:in `on_complete': the server responded with s tatus 429 (Faraday::TooManyRequestsError)
but this is the very first request to the OpenAI API, so it’s odd that it’s ‘Too many requests’.
I had this problem and the error message seemed a bit unrelated to the underlying cause, so figured I’d share what solved (for me, anyway).
Basically I had to add credit to the OpenAI API account. See here, but basically:
- Go to OpenAI API settings:
- Click on ‘Billing’
- Click on ‘Add to credit balance’
- Wait a few minutes (it took about 3 minutes until it worked for me)
I’m not sure why it gives a 429 error code.