Skip to content

Setting the API key for Cohere and Anthropic per instance #15735

Answered by dosubot bot
anirbanbasu asked this question in Q&A
Discussion options

You must be logged in to vote

The inability to set the api_key attribute on a Cohere LLM object after instantiation is intended behavior, not a bug. This is because the api_key is used during the initialization of the _client and _aclient attributes, which are instances of cohere.Client and cohere.AsyncClient, respectively. These clients are created in the __init__ method and require the api_key at that time. Changing the api_key after instantiation would not update these client instances [1].

For the Anthropic class, I wasn't able to find specific information within the repository, but it is likely that it follows a similar pattern where the api_key is used during initialization and cannot be changed afterward.

If y…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@anirbanbasu
Comment options

@dosubot
Comment options

Answer selected by anirbanbasu
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants