The default Agent Mode in Android Studio has a no-cost daily quota with a limited context window. To expand the context window, you can add your own Gemini API key to take advantage of more tokens with an upgraded Gemini model version. To learn how to add an API key when using third-party models, see Use a remote model.
A larger context window lets you send more instructions, code, and attachments to Gemini, leading to even higher quality responses. This is especially useful when working with agents because the larger context provides Gemini with the ability to reason about complex or long-running tasks.
To get a Gemini API key:
- In Android Studio, go to File (Android Studio on macOS) > Settings > Tools > Gemini > Model Providers and click Gemini.
- Click Get a Gemini API key to open Google AI Studio and retrieve or create your API key.
- Enter your Gemini API key in the API key field. A list of models appears in Available models.
- Select the models you want to enable. You can choose from the enabled models when you send a prompt.
- Select Apply to apply the updates (click OK to apply the updates and immediately exit the settings).
Be sure to safeguard your Gemini API key because additional charges apply for Gemini API usage associated with a personal API key. You can monitor your Gemini API key usage in AI Studio through Usage and Limits.