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

# Quickstart

> Deploy a Hyrex App in 5 minutes

<img className="rounded-xl h-64 w-64" src="https://mintcdn.com/kura/VpUBXWpSCrFpuC0V/images/hyrax_computer.png?fit=max&auto=format&n=VpUBXWpSCrFpuC0V&q=85&s=ef5ee32fbd9ac8067d1a5b8e81bc88fd" alt="Hyrax Hero" width="1024" height="1024" data-path="images/hyrax_computer.png" />

## My First Hyrex Task

Step 1. Install Hyrex in your project:

<CodeGroup>
  ```bash Installation theme={null}
  pip install hyrex
  ```
</CodeGroup>

Step 2. Initialize your postgres database the Hyrex CLI.
Note that the database URL should be a [Postgres connection string](https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING).

<CodeGroup>
  ```bash Initialize Database theme={null}
  hyrex init --database_url="ADD_URL_HERE"
  ```
</CodeGroup>

Step 3. Initialize the Hyrex object in your project and decorate a task.

<CodeGroup>
  ```python Create a Task theme={null}
  from settings import hy
  from pydantic import BaseModel, Field

  hy = Hyrex(
    app_id="kindex-worker",
    conn=settings.hy_database_url,
    error_callback=task_error_callback,
  )

  class DeliverEmailContext(BaseModel):
      email: str
      subject: str
      body: str

  @hy.task
  def deliver_email(context: DeliverEmailContext):
      url = "EMAIL_PROVIDER_API"
      r = requests.post(url, body=context.model_dump())
      if r.status_code == 200:
          print("Success!")
      else:
          print("Something went wrong...")
  ```
</CodeGroup>

Step 4: Send the task to be executed asynchronously. Here `deliver_email` is a hyrex task

<CodeGroup>
  ```python Use the task theme={null}
  from tasks import deliver_email, DeliverEmailContext

  email_args = SendEmailContext(
    email="bart@hyrex.io"
    subject="Breakfast is ready!"
    body="like I said... breakfast is ready!"
  )

  # Call the function synchronously.
  # Behaves just like a normal Python function.
  deliver_email(email_args)

  # Use .send(...) to call the function asynchronously.
  # Submits the task to the Hyrex task queue.
  task = deliver_email.send(email_args)

  ```
</CodeGroup>

There you go! You now have a distributed task queue!
