Skip to content

Conversation

faisalrazap
Copy link

The previous configuration was assigning the wrong @access_token when initializing a client

This PR fixes a small syntax issue in the initializer example for Anthropic.configure.
Currently, the example in the README shows:

config.access_token = ENV.fetch("ANTHROPIC_API_KEY"),
The trailing comma causes Ruby to interpret the value as a single-element array instead of a string:

Current behavior

ENV.fetch("ANTHROPIC_API_KEY"), # => ["sk-ant-api..."]
This results in @access_token being set to an array (with nil and true as seen in debug output), which leads to an invalid x-api-key authentication error when calling the API.

Fix:

Removed the trailing comma so the value is correctly assigned as a string:

config.access_token = ENV.fetch("ANTHROPIC_API_KEY")
This change ensures the access_token is passed correctly to the client and avoids 401 authentication errors.

Why it matters:

The current example can cause confusion for new users and lead to avoidable API authentication failures. This small fix improves developer onboarding and prevents subtle bugs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant