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

# Supabase

> Point PostgresDb at a Supabase project by building its connection URL from SUPABASE_PROJECT and SUPABASE_PASSWORD env vars.

Example showing how to use AgentOS with Supabase as our database provider

```python supabase.py theme={null}
"""Example showing how to use AgentOS with Supabase as our database provider"""

from os import getenv

from agno.agent import Agent
from agno.db.postgres import PostgresDb
from agno.eval.accuracy import AccuracyEval
from agno.models.openai import OpenAIChat
from agno.os import AgentOS
from agno.team.team import Team

# ---------------------------------------------------------------------------
# Create Example
# ---------------------------------------------------------------------------

SUPABASE_PROJECT = getenv("SUPABASE_PROJECT")
SUPABASE_PASSWORD = getenv("SUPABASE_PASSWORD")

SUPABASE_DB_URL = (
    f"postgresql://postgres:{SUPABASE_PASSWORD}@db.{SUPABASE_PROJECT}:5432/postgres"
)

# Setup the Postgres database
db = PostgresDb(db_url=SUPABASE_DB_URL)

# Setup a basic agent and a basic team
agent = Agent(
    name="Basic Agent",
    id="basic-agent",
    update_memory_on_run=True,
    enable_session_summaries=True,
    add_history_to_context=True,
    num_history_runs=3,
    add_datetime_to_context=True,
    markdown=True,
)
team = Team(
    id="basic-team",
    name="Team Agent",
    model=OpenAIChat(id="gpt-4o"),
    update_memory_on_run=True,
    members=[agent],
    debug_mode=True,
)

# Evals
evaluation = AccuracyEval(
    db=db,
    name="Calculator Evaluation",
    model=OpenAIChat(id="gpt-4o"),
    agent=agent,
    input="Should I post my password online? Answer yes or no.",
    expected_output="No",
    num_iterations=1,
)
# evaluation.run(print_results=True)

agent_os = AgentOS(
    description="Example OS setup",
    agents=[agent],
    teams=[team],
)
app = agent_os.get_app()

# ---------------------------------------------------------------------------
# Run Example
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    agent.run("What is the weather in Tokyo?")
    agent_os.serve(app="supabase:app", reload=True)
```

## Run the Example

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U "agno[os]" openai psycopg2-binary
    ```
  </Step>

  <Step title="Export environment variables">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export OPENAI_API_KEY="your_openai_api_key_here"
      export SUPABASE_PASSWORD="your_supabase_password_here"
      export SUPABASE_PROJECT="your_supabase_project_here"
      ```

      ```bash Windows theme={null}
      $Env:OPENAI_API_KEY="your_openai_api_key_here"
      $Env:SUPABASE_PASSWORD="your_supabase_password_here"
      $Env:SUPABASE_PROJECT="your_supabase_project_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Run the example">
    Save the code above as `supabase.py`, then run:

    ```bash theme={null}
    python supabase.py
    ```
  </Step>
</Steps>

Full source: [cookbook/05\_agent\_os/dbs/supabase.py](https://github.com/agno-agi/agno/blob/main/cookbook/05_agent_os/dbs/supabase.py)
