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

# Manage API Keys

> Learn how to manage API keys in Vijil

To query a model for responses, you need to have one or more model hub API keys stored in Vijil. Currently, Vijil supports OpenAI and Together as model hubs. You can also add [custom hubs](/manage-agents/integrations/custom), including [Google Vertex AI](/manage-agents/integrations/vertex) and [DigitalOcean](/manage-agents/integrations/digitalocean). You can create an API key while adding an agent, or create it separately.

## Create, Delete, or Update API Keys in Vijil Web Interface

In the left sidebar, click on **Keys**. You will see a list of all the model hub API keys you have added to Vijil, along with their metadata like rate limits. Click **Add new key** to create a new API key.

## Create, Delete, or Update API Keys in the Python Client

Before doing any of this, you will need to instantiate your Vijil client. In this topic we will assume you have instantiated a Vijil client called `client`.

### List Available API keys

This lists all the model hub API keys you have added to Vijil, along with their metadata like rate limits:

<CodeGroup>
  ```python title="Python" icon="python" theme={null}
  client.api_keys.list()
  ```
</CodeGroup>

### Add an API Key

When adding an API key, you must specify the model hub it is for, the name you want to give it, and the API key value.

You can also specify a rate limit for the API key, which defines the maximum number of requests to send to model endpoint per unit of time. The `rate_limit_interval` is the number of seconds in the interval, and `rate_limit_per_interval` is the number of requests you can make in that interval. In the example below, we are specifying a limit of 600 requests per 60 seconds, i.e. 600 requests per minute.

<CodeGroup>
  ```python title="Python" icon="python" theme={null}
  client.api_keys.create(
      name="openAI20240630-2",
      model_hub="openai",
      api_key="sk+++",
      rate_limit_per_interval=600, # optional, defaults to lowest requests-per-minute
      rate_limit_interval=60, # optional, defaults to 60 seconds
  )
  ```
</CodeGroup>

If you do not define a rate limit, Vijil defaults to the lowest tier rate limit offered by the model provider.

### Delete an API Key

<CodeGroup>
  ```python title="Python" icon="python" theme={null}
  client.api_keys.delete(name="openAI20240630-2")
  ```
</CodeGroup>

### Modify an API Key

You can use this to update any property of an API key except for its name. To update its name, use the `rename` function instead.

The following example updates the API key value and rate limit properties for the key with name `openAI20240630-2`:

<CodeGroup>
  ```python title="Python" icon="python" theme={null}
  client.api_keys.modify(name="openAI20240630-2", api_key="sk---", rate_limit_interval=1, rate_limit_per_interval=5)
  ```
</CodeGroup>

### Rename an API Key

Use this to update the name of an API key.

<CodeGroup>
  ```python title="Python" icon="python" theme={null}
  client.api_keys.rename(name="openAI20240630-2", new_name="openAI20240630-3")
  ```
</CodeGroup>
