{
  "schema_version": 2,
  "id": "operate/iris/lens/create-lens",
  "title": "Create Lens",
  "url": "https://redis.io/docs/latest/operate/iris/lens/create-lens/",
  "summary": "Create Lens in Redis Cloud, create the keys your agents and readers use, open Lens in the console, and delete it.",
  "tags": [
    "docs",
    "operate",
    "iris"
  ],
  "last_updated": "2026-11-03T15:22:41-08:00",
  "page_type": "content",
  "content_hash": "b09da4071116bd2c0c71077b5c02f27c9c4c92106c753bdb3180912383b9a644",
  "sections": [
    {
      "id": "overview",
      "title": "Overview",
      "role": "overview",
      "text": "Lens records each turn your agent handles, so you can open it later and see what the agent recalled, what it sent to the model, and what came back. This guide walks you through creating Lens in the Redis Cloud console, connecting an agent, and opening its sessions."
    },
    {
      "id": "before-you-begin",
      "title": "Before you begin",
      "role": "content",
      "text": "Each Redis Cloud account has one Lens instance, which stores its data in two databases you choose:\n\n| Database | Holds | Requirements |\n|:---------|:------|:-------------|\n| **Records database** | Turns, sessions, and their search indexes. | A Redis Cloud Essentials or Pro database. |\n| **Content database** | Captured prompts, responses, and tool payloads. | Any Redis Cloud database, including Redis Flex. |\n\nIf you don't have a database, see [Create a database](https://redis.io/docs/latest/operate/rc/databases/create-database).\n\nIf a database's Classless Inter-Domain Routing (CIDR) allow list blocks Lens, the **Create Lens** dialog lists the Internet Protocol (IP) addresses to add, and you can't create Lens until you add them. Add them under **Security** in the database's settings."
    },
    {
      "id": "create-lens",
      "title": "Create Lens",
      "role": "content",
      "text": "1. From the [Redis Cloud console](https://cloud.redis.io/), select **Lens** under **Iris** in the menu.\n\n    If you haven't created Lens yet, you see an introduction to Lens.\n\n    <!-- TODO: screenshot of the Lens introduction page. -->\n\n1. Select **New lens**.\n\n    **New lens** is unavailable until your account has a database for each role in [Before you begin](https://redis.io/docs/latest/operate/iris/lens/create-lens#before-you-begin). If you don't see it, you don't have permission to create Lens.\n\n1. In the **Create Lens** dialog, choose a **Records database** and a **Content database**. You can't change them after you create Lens.\n\n1. Select **Create**.\n\nWhen Lens is ready, the **Lens is ready** dialog shows the **Instance ID** and the **Endpoint**, with the steps to connect your agent:\n\n1. Install the Redis Iris software development kit (SDK).\n1. Set `IRIS_LENS_ENDPOINT` to the endpoint, and `IRIS_LENS_API_KEY` to an agent's API key.\n1. Add Lens to your agent: call `lens.init` once, and wrap each turn in `lens.turn`.\n\nCopy each step's code with **Copy code**. See [Instrument an agent](https://redis.io/docs/latest/develop/ai/context-engine/lens/instrument) for what to record in a turn.\n\nIf one of the databases is unavailable, the dialog shows a warning in place of the endpoint and the connection steps.\n\nSelect **Open Lens** to go to Lens, or **I'll do this later** to close the dialog."
    },
    {
      "id": "create-api-keys",
      "title": "Create API keys",
      "role": "content",
      "text": "Agents send turns to Lens with an API key that has the `ingest` scope. Readers, such as the [read application programming interface (API)](https://redis.io/docs/latest/develop/ai/context-engine/lens/read-api) client, need a key with the `read` scope. An agent that also reads turns needs a key with both, the `full` scope. Give each agent its own key. If one agent's key leaks, you can revoke or rotate that key without interrupting your other agents.\n\nTo create an agent's key:\n\n1. In the **Lens is ready** dialog, select **Create API key**. The console opens **Create API key** with **ingest** already selected for your Lens instance.\n1. Enter a **Key name**. Use letters, numbers, periods, underscores, or hyphens.\n1. Choose an **Expiration**. The default is 90 days.\n1. Select **Create key**.\n1. Copy the key from the **API Key Generated** dialog, and then select **Close**.\n\nTo create a read key:\n\n1. Select **Access & Identity** under **Iris** in the console menu.\n1. Select **New API key**.\n1. Enter a **Key name** and choose an **Expiration**.\n1. Under **Access**, expand **Lens** and select **Lens instance**. **ingest** is selected by default.\n1. Select **read**, and then clear **ingest**.\n1. Select **Create key**, and copy the key from the **API Key Generated** dialog.\n\n> [!WARNING]\n> The console shows a key only once, in the **API Key Generated** dialog. Save it to a secure location before you select **Close**.\n\nSee [Configure Lens](https://redis.io/docs/latest/develop/ai/context-engine/lens/configure) for the environment variables each key goes in."
    },
    {
      "id": "open-lens",
      "title": "Open Lens",
      "role": "content",
      "text": "Select **Lens** under **Iris** in the Redis Cloud console menu. Then select an agent to see its sessions. Sessions appear as soon as the agent handles a turn.\n\nSee [Inspect sessions](https://redis.io/docs/latest/develop/ai/context-engine/lens/inspect-sessions) to find a session and read each turn's steps."
    },
    {
      "id": "delete-lens",
      "title": "Delete Lens",
      "role": "content",
      "text": "Deleting Lens removes the Lens instance and its Lens data from both databases. You can't undo it. Because you can't change the databases of an existing Lens, delete Lens and create it again to use different databases.\n\n1. In Lens, select ![Lens actions](https://redis.io/docs/latest/images/rc/tags-icon-more-actions.png#no-click), and then select **Delete lens instance**.\n1. Select **Yes, I want to delete this resource**.\n1. Select **Delete lens instance**.\n\nThe console returns to the Lens introduction."
    },
    {
      "id": "next-steps",
      "title": "Next steps",
      "role": "content",
      "text": "- [Trace your first turn](https://redis.io/docs/latest/develop/ai/context-engine/lens/quickstart).\n- [Integrate with an agent framework](https://redis.io/docs/latest/develop/ai/context-engine/lens/agent-integration), such as LangGraph or the OpenAI Agents SDK."
    }
  ],
  "examples": []
}
