> ## Documentation Index
> Fetch the complete documentation index at: https://docs.banya.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Connect an AI model

> How to select an AI model and register an API key in CodePilot.

CodePilot needs an **AI model** connected before it can generate responses.

In most cases, you just **select a model and register a personal API key** in Settings. Google is included by default, so you can start right away. This guide uses **Google Gemini** as the example.

<Info>
  When an administrator (super) enables the providers and models the organization will use, members simply pick from that list. Registering a model that isn't on the list — via [Custom Models](#4-register-a-custom-model-standalone-only) — is **only for standalone setups used without signing in**.
</Info>

***

## 1. Get a Gemini API key

You can get an API key from Google for free.

<Steps>
  <Step title="Go to Google AI Studio">
    In your browser, go to [aistudio.google.com/apikey](https://aistudio.google.com/apikey) and sign in with your Google account.
  </Step>

  <Step title="Create an API key">
    Click the **Create API key** button. If it asks you to choose a project, pick any project or create a new one.
  </Step>

  <Step title="Copy the key">
    A string starting with `AIza` is generated. Click the **Copy** button and keep it somewhere safe.
  </Step>
</Steps>

<Warning>
  An API key is like a password. Don't paste it into source code or team chat. If it leaks, delete it immediately in Google AI Studio and issue a new one.
</Warning>

<Info>
  Gemini includes a free usage tier. You may be charged if you exceed it, so check your billing settings and limits in Google AI Studio.

  **Coding work sends a large amount of context per turn.** On the free or a low tier, you may frequently hit per-minute request/token rate limits, causing responses to stall or slow down. For real development work, **a paid tier is recommended.**
</Info>

***

## 2. Select a model and register an API key

Register the key you obtained in Settings.

<Steps>
  <Step title="Open AI model settings">
    Click the **gear (⚙) icon** at the top right of the chat panel, then select **AI Models** from the left menu.

    <img src="https://mintcdn.com/banyaai/eM-Nuqr2SnMxEdsc/images/en/IDE_AI_MODEL.png?fit=max&auto=format&n=eM-Nuqr2SnMxEdsc&q=85&s=1b3c94259e1fbb766da734f6d72807ce" alt="AI Models settings" width="1030" height="685" data-path="images/en/IDE_AI_MODEL.png" />
  </Step>

  <Step title="Select an AI model">
    In the **Select AI Model** dropdown, choose the provider you want to use. **Google** is included by default, so you can leave it as-is.
  </Step>

  <Step title="Choose a model">
    In the **model settings** area below (Configure the API settings for the selected model), open the **Model** dropdown and choose the model to use. (e.g., `Gemini 3.0 Flash`)
  </Step>

  <Step title="Register a personal API key">
    Set the **API Key** item to **Personal API Key**, then paste the key you copied in step 1 into the **Personal API Key** field and click **Save**.
  </Step>
</Steps>

Now type any question in the chat to confirm the connection.

```
Hi there! Just checking that everything's connected properly.
```

<Tip>
  Use the **Streaming · Native tool calls · Thinking · Multimodal** toggles to adjust how responses are generated. See the [Settings](/en/ide/settings) guide for details.
</Tip>

***

## 3. Switching to the admin key

If your administrator has registered an API key for the organization, a dropdown to choose between the admin key and a personal key appears under the **API Key** item. Switching to the admin key lets you start using it right away without your own key.

<img src="https://mintcdn.com/banyaai/eM-Nuqr2SnMxEdsc/images/en/IDE_MODEL_KEY_SOURCE.png?fit=max&auto=format&n=eM-Nuqr2SnMxEdsc&q=85&s=7d378a0d5f9ad746f38116a1cc20033c" alt="Choosing the API key source" width="767" height="246" data-path="images/en/IDE_MODEL_KEY_SOURCE.png" />

| Option               | Meaning                                                                       |
| -------------------- | ----------------------------------------------------------------------------- |
| **Admin API Key**    | Uses the key registered by the organization. The organization covers the cost |
| **Personal API Key** | Uses a key you issued yourself. You cover the cost                            |

<Info>
  When both an admin key and a personal key exist, **Admin API Key** is selected by default. If no keys are registered at all, it shows **No keys registered** — in that case, ask your administrator or register a personal key.
</Info>

***

## 4. Register a custom model (standalone only)

<Info>
  This method is **only for standalone (BYOK) setups used without signing in**. Use it to register a model that isn't in the provider list above, specifying its endpoint directly. The **Custom Models** section does not appear when you're signed in to an organization.
</Info>

<Steps>
  <Step title="Add a model">
    Under **Custom Models** in Settings → **AI Models**, click **+ Add Model**.

    <img src="https://mintcdn.com/banyaai/eM-Nuqr2SnMxEdsc/images/en/IDE_MODEL_ADD.png?fit=max&auto=format&n=eM-Nuqr2SnMxEdsc&q=85&s=9a1a67fe882401eacc4cea86a057c55d" alt="Adding a custom model" width="1050" height="734" data-path="images/en/IDE_MODEL_ADD.png" />
  </Step>

  <Step title="Select a provider">
    In the **Provider** dropdown, choose **Google Gemini**. Once you select it, the **API Endpoint** is filled in automatically. Leave this value as-is.

    <img src="https://mintcdn.com/banyaai/eM-Nuqr2SnMxEdsc/images/en/IDE_MODEL_FORM_GEMINI.png?fit=max&auto=format&n=eM-Nuqr2SnMxEdsc&q=85&s=f2fb4dac144408cce73ed2a4540254bf" alt="Gemini model form" width="755" height="956" data-path="images/en/IDE_MODEL_FORM_GEMINI.png" />
  </Step>

  <Step title="Enter the model details">
    Type the two values below yourself.

    | Field          | Value to enter                                                                       |
    | -------------- | ------------------------------------------------------------------------------------ |
    | **Model Name** | `Gemini 3.1 Pro` — this is just the name shown in the list, so use whatever you like |
    | **Model ID**   | `gemini-3.1-pro-preview` — must be the exact value defined by Google                 |

    <Warning>
      The faint example text in the field (`gemini-2.5-pro`) refers to an older model. Don't leave it as-is — type the value above instead.
    </Warning>
  </Step>

  <Step title="Paste the API key and save">
    Paste the key you copied in step 1 into the **API Key** field. Leave everything else (auth method, context window, temperature, extra headers, etc.) at its default and click **Save**.
  </Step>

  <Step title="Test, then select">
    Click **Test** next to the saved model to confirm **Connection OK**, then click **Select** to put it in the **✓ Active** state.

    <img src="https://mintcdn.com/banyaai/eM-Nuqr2SnMxEdsc/images/en/IDE_MODEL_TEST.png?fit=max&auto=format&n=eM-Nuqr2SnMxEdsc&q=85&s=905c499b952f570b1b4d482950fa78cc" alt="Testing and selecting the model" width="748" height="275" data-path="images/en/IDE_MODEL_TEST.png" />

    <Warning>
      If you only save and don't click **Select**, the model is merely registered and won't be used. Be sure to select it too.
    </Warning>
  </Step>
</Steps>

***

## Using a different provider

Choose a different provider in the Provider dropdown. The steps are the same as for Gemini — only **where you get the API key** differs.

| Provider         | Example model ID         |
| ---------------- | ------------------------ |
| OpenAI           | `gpt-4o`                 |
| Anthropic Claude | `claude-opus-4-6`        |
| Google Gemini    | `gemini-3.1-pro-preview` |
| DeepSeek         | `deepseek-chat`          |

<Info>
  Model IDs change whenever a provider releases a new model. If the value above doesn't work, check the provider's official documentation for the current model ID.
</Info>

You can also register cloud providers (Vertex AI · Azure OpenAI · AWS Bedrock) and self-hosted servers (OpenAI-compatible endpoints).

<Tip>
  To use it without an internet connection, you can run a **local model** that needs no API key. Connect a local model server under Settings → AI Models.
</Tip>

***

## Troubleshooting

<AccordionGroup>
  <Accordion title="No response in chat">
    The **API Key** item may be set to **Personal API Key** without a saved key, or there may be no admin key available. Check that you entered your personal key and clicked **Save**.
  </Accordion>

  <Accordion title="It shows &#x22;No keys registered&#x22;">
    Neither an admin key nor a personal key is registered. Issue and register a personal key, or ask your administrator to register an organization key.
  </Accordion>

  <Accordion title="The model I want isn't in the list">
    Your administrator (super) may not have enabled that provider. Ask your administrator. In a standalone setup used without signing in, you can register it yourself via [Custom Models](#4-register-a-custom-model-standalone-only).
  </Accordion>

  <Accordion title="A custom-model test shows &#x22;Connection failed&#x22;">
    Check the following, in order.

    1. **API key** — make sure no leading/trailing whitespace got copied in, and paste it again.
    2. **Model ID** — it must be the exact value defined by Google, like `gemini-3.1-pro-preview`. Don't confuse it with the model name (`Gemini 3.1 Pro`).
    3. **API endpoint** — reselecting the provider restores the correct value.
    4. **Network** — a corporate firewall may be blocking outbound API calls. Contact your administrator.
  </Accordion>

  <Accordion title="Quota exceeded error">
    You may have used up the Gemini free tier. Check your usage and billing settings in Google AI Studio.
  </Accordion>
</AccordionGroup>

***

## Next steps

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/en/getting-started/quickstart">
    Send your first request and approve changes right away
  </Card>

  <Card title="Connect to an organization" icon="building" href="/en/getting-started/organization">
    Using it as a team? Join an organization to apply administrator policies
  </Card>
</CardGroup>
