> ## 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.

# JSON for Agent

> Use JSON files as the database for an Agent.

Use JSON files as the database for an Agent. Useful for simple demos where performance is not critical.

```python json_for_agent.py theme={null}
"""
Use JSON files as the database for an Agent.
Useful for simple demos where performance is not critical.

Run `uv pip install ddgs openai` to install dependencies."""

from agno.agent import Agent
from agno.db.json import JsonDb
from agno.models.openai import OpenAIChat
from agno.tools.websearch import WebSearchTools

# ---------------------------------------------------------------------------
# Setup
# ---------------------------------------------------------------------------
db = JsonDb(db_path="tmp/json_db")

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
    model=OpenAIChat(id="gpt-5.2"),
    db=db,
    session_id="session_storage",
    tools=[WebSearchTools()],
    add_history_to_context=True,
    num_history_runs=3,
)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    agent.print_response("How many people live in France?")
    agent.print_response("What is their national anthem called?")
    agent.print_response("What have we been talking about?")
```

## Run the Example

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

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno ddgs openai
    ```
  </Step>

  <Step title="Export your OpenAI API key">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export OPENAI_API_KEY="your_openai_api_key_here"
      ```

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

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

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

Full source: [cookbook/06\_storage/json\_db/json\_for\_agent.py](https://github.com/agno-agi/agno/blob/main/cookbook/06_storage/json_db/json_for_agent.py)
