You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When the API token has issues, the gem raises a Faraday error. This can happen for several reasons, such as an invalid API token or low credit, etc.
To Reproduce
require'bundler/inline'gemfile(true)dosource'https://rubygems.org'git_source(:github){ |repo| "https://github.com/#{repo}.git"}gem"anthropic",path: "../"endrequire'anthropic'# secret keyclient=Anthropic::Client.new(access_token: "invalid-key")binding.pryresponse=client.messages(parameters: {model: "claude-3-sonnet-20240229",system: "Respond only in Spanish.",messages: [{"role": "user","content": "Hello, Claude!"}],max_tokens: 1000})
Expected behavior
A defined error is raised.
actual behavior
Faraday raises an error:
from (pry):3:in `on_complete'
gems/faraday-2.12.0/lib/faraday/response/raise_error.rb:31:in `on_complete': the server responded with status 400 (Faraday::BadRequestError)"
I inspected the API response and got the following error:
" @status=400 @reason_phrase="Bad Request" @response_body={"type"=>"error", "error"=>{"type"=>"invalid_request_error", "message"=>"Your credit balance is too low to access the Anthropic API. Please go to Plans & Billing to upgrade or purchase credits."}}>>
If you're okay with API consumers catching the API errors (4XX), I will close this issue and update the README. Thanks!
The text was updated successfully, but these errors were encountered:
Describe the bug
When the API token has issues, the gem raises a Faraday error. This can happen for several reasons, such as an invalid API token or low credit, etc.
To Reproduce
Expected behavior
A defined error is raised.
actual behavior
Faraday raises an error:
I inspected the API response and got the following error:
If you're okay with API consumers catching the API errors (4XX), I will close this issue and update the README. Thanks!
The text was updated successfully, but these errors were encountered: