You'll need the latest version (0.4.0) of ellmer:
pak::pak("ellmer")You'll also need to set up at least one chat provider. If you don't already have an API account (a paid subscription unfortunately doesn't count), we recommend either Claude, OpenAI, or Gemini. Claude and OpenAI offer very similar performance, but Claude is a little more expensive. Gemini is a little worse, but offers a very generous free tier.
- Sign up at https://console.anthropic.com.
- Load up enough credit to buy a coffee.
- Create a key at https://console.anthropic.com/settings/keys and copy it to the clipboard.
usethis::edit_r_environ().- Add a new line containing:
ANTHROPIC_API_KEY={paste}. - Restart R.
- Check that
ellmer::chat_claude()$chat("Tell me a joke")works.
- Sign up at https://platform.openai.com/login
- Go to https://platform.openai.com/settings/organization/billing/overview and load up enough credit to buy a coffee.
- Create a key at https://platform.openai.com/settings/organization/api-keys and copy it to the clipboard.
usethis::edit_r_environ().- Add a new line containing:
OPENAI_API_KEY={paste}. - Restart R.
- Check that
ellmer::chat_openai()$chat("Tell me a joke")works.
- Log in to https://aistudio.google.com with a google account
- Click create API key & copy it to the clipboard.
usethis::edit_r_environ()- Add a new line containing:
GOOGLE_API_KEY={paste} - Restart R.
- Check that
ellmer::chat_google_gemini()$chat("Tell me a joke")works.
If the other methods fail, you can try this fallback.
- Run
ellmer::chat_google_gemini()$chat("Hi"). - Log in with a google account
- On the slightly scary screen that says "Google hasn’t verified this app", click "Advanced" then "Go to ellmer (unsafe)".
- Click "Continue".