RStudio has a built‑in AI Assistant (the Posit Assistant pane) that can chat with you, explain code, and help debug. Before you can use it you must connect it to an AI provider – the service that actually runs the language model.
You are free to choose whichever provider you like. Several options are listed below. They all work the same way once connected; they differ mainly in cost and setup effort.
| Option | Cost | Google/other account needed | Setup effort |
|---|---|---|---|
| 1. Posit AI Pass | Free trial only (small credit, then paid) | Posit account | Easiest |
| 2. Google Gemini | Free (rate‑limited) | Free Google account | Medium |
| 3. OpenRouter (free models) | Free (rate‑limited) | Free OpenRouter account | Medium |
| 4. Local model (Ollama) | Free | none | Only if you run RStudio on your own computer |
There is also a bonus option for code auto‑completion (GitHub Copilot) at the end – that is separate from the chat assistant and is free if you have a GitHub Student account.
Open the Posit Assistant pane:
In the Assistant pane, the gear / settings menu is where you add a provider and enter your key. The Chat provider dropdown (also in Tools → Global Options → Assistant) is where you pick which connected provider is active.
The exact wording of menu items varies slightly between RStudio versions, but the flow is always: add provider → paste key → select it as the chat provider.
Posit AI Pass is Posit’s own managed service. Setup is a single sign‑in – no API keys.
Limitation: the free trial is a small one‑time credit allowance (a few dollars of usage), not an unlimited 30‑day period. When the credit runs out, continued use needs a paid subscription. Fine for trying the assistant out; not a long‑term free option for the course.
Google gives out free Gemini API keys. There are rate limits (roughly 15 requests/minute on the free tier) but that is plenty for one person doing coursework.
AIza…). Treat it like a password – don’t share it or commit it
to a repository.gemini-3.6-flash or newer – the
gemini-2.5 (and older) models are no longer supported and will fail if selected.OpenRouter is a gateway to many models, including a rotating set of free ones.
sk-or-…).:free (for example a free Llama, Gemini, or DeepSeek
variant – the exact list changes over time).Notes: free models have low rate limits, can be slow at busy times, and prompts sent to them may be used by the model providers for training. Don’t paste anything private or assessable.
If you have a GitHub Student Developer Pack, you get GitHub Copilot Pro for free. In RStudio this gives you inline code suggestions as you type (grey ghost text you accept with Tab). It does not provide chat – that still needs one of the providers above.
You can run Copilot completions and a chat provider (e.g. Gemini) at the same time.