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

# Quickstart

## Overview

In this guide, you'll initialize a voice agent, interact with it locally, and then deploy it in production.

## Requirements

* [**Python 3.11+**](https://www.python.org/)
* [**Jay API Key**](\(https://jay.so/dashboard/agent/settings\))
* [**Ngrok**](https://www.ngrok.com/)
* [**Docker**](https://www.docker.com/)
* **AI Provider API Keys**:
  * **Speech-to-Text (STT), e.g. [Deepgram](https://deepgram.com/)**
  * **Large Language Model (LLM), e.g. [OpenAI](https://openai.com/)**
  * **Text-to-Speech (TTS), e.g. [ElevenLabs](https://elevenlabs.io/)**

## 1: Select Your Package Manager

<Tabs>
  <Tab title="Pip">
    ## 2: Select Your LLM Provider

    <Tabs>
      <Tab title="OpenAI (or OpenAI Compatible)">
        ## 3: Set up a virtual environment

        Skip this step if you already have a virtual environment.

        ```zsh theme={null}
        python -m venv .venv && source .venv/bin/activate
        ```

        ## 4: Install Jay

        ```zsh theme={null}
        pip install jay_ai
        ```

        ## 5: Install OpenAI

        Skip this step if it's already installed.

        ```zsh theme={null}
        pip install "openai>=1.0,<2.0"
        ```

        ## 6: Initialize Your Project

        ```zsh theme={null}
        jay init
        ```

        <AccordionGroup>
          <Accordion title="What does this command do?">
            This command will:

            1. Prompt you to enter a few values:
               * Jay API Key
               * Jay Developer ID
               * AI provider API keys (STT, LLM, TTS).
            2. Create a file containing your agent (`agent/main.py`).
            3. Either create a `.env` file or append new values to your existing one.
            4. Request your permission to store your AI provider API keys as encrypted environment variables in our database, which is necessary to run the agent.
          </Accordion>
        </AccordionGroup>

        ## 7: Run Locally

        This command will launch a local playground where you can interact with your agent as you develop it:

        ```zsh theme={null}
        jay run --agent agent/main.py --connect
        ```

        You can close the process when you're done interacting with your agent locally.

        ## 8: Deploy to Production

        First, generate a `requirements.txt` that contains your latest dependencies:

        ```zsh theme={null}
        pip freeze > requirements.txt
        ```

        Then, deploy to production:

        ```zsh theme={null}
        jay deploy --requirement requirements.txt --agent agent/main.py
        ```

        This step will take a few minutes to complete.

        ## 9: Connect to the Deployed Agent

        ```zsh theme={null}
        jay connect --agent agent/main.py
        ```

        ## 10 (optional): Modify Your Agent

        You can change your LLM's responses by opening `agent/main.py`, then navigating to the
        `llm_response_handler` function.

        You can update your LLM to respond with a joke about the moon by making the following modification:

        ```python {3} theme={null}
        async def llm_response_handler(input: LLMResponseHandlerInput):
            client = AsyncOpenAI(api_key=os.environ["OPENAI_API_KEY"])
            messages = input["messages"] + [{"role": "user", "content": "Tell me a joke about the moon."}]
            completion = await client.chat.completions.create(
                model="gpt-4o",
                messages=messages,
                stream=True,
            )
            return completion
        ```

        Test this change locally by running:

        ```zsh theme={null}
        jay run --agent agent/main.py --connect
        ```

        Then, you can redeploy in production by running:

        ```zsh theme={null}
        jay deploy --requirement requirements.txt --agent agent/main.py
        ```

        And finally, you can connect to the deployed agent by running:

        ```zsh theme={null}
        jay connect --agent agent/main.py
        ```
      </Tab>
    </Tabs>
  </Tab>

  <Tab title="Poetry">
    ## 2: Select Your LLM Provider

    <Tabs>
      <Tab title="OpenAI (or OpenAI Compatible)">
        ## 3: Install the Poetry Export Plugin

        You'll need this command later when deploying the agent:

        ```zsh theme={null}
        poetry self add poetry-plugin-export
        ```

        ## 4: Install Jay

        ```zsh theme={null}
        poetry add jay_ai
        ```

        ## 5: Install OpenAI

        Skip this step if it's already installed.

        ```zsh theme={null}
        poetry add "openai>=1.0,<2.0"
        ```

        ## 6: Initialize Your Project

        ```zsh theme={null}
        poetry run jay init
        ```

        <AccordionGroup>
          <Accordion title="What does this command do?">
            This command will:

            1. Prompt you to enter a few values:
               * Jay API Key
               * Jay Developer ID
               * AI provider API keys (STT, LLM, TTS).
            2. Create a file containing your agent (`agent/main.py`).
            3. Either create a `.env` file or append new values to your existing one.
            4. Request your permission to store your AI provider API keys as encrypted environment variables in our database, which is necessary to run the agent.
          </Accordion>
        </AccordionGroup>

        ## 7: Run Locally

        This command will launch a local playground where you can interact with your agent as you develop it:

        ```zsh theme={null}
        poetry run jay run --agent agent/main.py --connect
        ```

        You can close the process when you're done interacting with your agent locally.

        ## 8: Deploy to Production

        First, generate a `requirements.txt` that contains your latest dependencies:

        ```zsh theme={null}
        poetry export --without-hashes --format=requirements.txt > requirements.txt
        ```

        Then, deploy to production:

        ```zsh theme={null}
        poetry run jay deploy --requirement requirements.txt --agent agent/main.py
        ```

        This step will take a few minutes to complete.

        ## 9: Connect to the Deployed Agent

        ```zsh theme={null}
        poetry run jay connect --agent agent/main.py
        ```

        ## 10 (optional): Modify Your Agent

        You can change your LLM's responses by opening `agent/main.py`, then navigating to the
        `llm_response_handler` function.

        You can update your LLM to respond with a joke about the moon by making the following modification:

        ```python {3} theme={null}
        async def llm_response_handler(input: LLMResponseHandlerInput):
            client = AsyncOpenAI(api_key=os.environ["OPENAI_API_KEY"])
            messages = input["messages"] + [{"role": "user", "content": "Tell me a joke about the moon."}]
            completion = await client.chat.completions.create(
                model="gpt-4o",
                messages=messages,
                stream=True,
            )
            return completion
        ```

        Test this change locally by running:

        ```zsh theme={null}
        poetry run jay run --agent agent/main.py --connect
        ```

        Then, you can redeploy in production by running:

        ```zsh theme={null}
        poetry run jay deploy --requirement requirements.txt --agent agent/main.py
        ```

        And finally, you can connect to the deployed agent by running:

        ```zsh theme={null}
        poetry run jay connect --agent agent/main.py
        ```
      </Tab>
    </Tabs>
  </Tab>
</Tabs>

## Next Steps

Next, we recommend learning about the core components of the agent in the [Agent Overview](https://docs.jay.so/get-started/agent-overview).
