Closed shmulickrot closed 5 months ago
@shmulickrot thanks for opening the issue. I believe that today we can capture a 429 status code and access the raw response.
Did you try this?
require 'gemini-ai'
begin
client.stream_generate_content({
contents: { role: 'user', parts: { text: 'hi!' } }
})
rescue Gemini::Errors::GeminiError => error
puts error.class # Gemini::Errors::RequestError
puts error.message # 'the server responded with status 429'
puts error.payload
# { contents: [{ role: 'user', parts: { text: 'hi!' } }],
# generationConfig: { candidateCount: 1 },
# ...
# }
puts error.request
# #<Faraday::ServerError response={:status=>429, :headers...
end
error.request.response
should give the raw response.
my bad after checking it also works for
Faraday::TooManyRequestsError
as it the class of the
Gemini Error
anyway thanks again
please add support rescue for response.status = 429 or give access to the raw response completely so we can handle it with our logic thanks for you work