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

# Quickstart

> Store and search your first memory in under five minutes.

## Prerequisites

* A Thrindex account and organization at [app.thrindex.com](https://app.thrindex.com).
* An API key with **Write** (`memory:write`) and **Read** (`memory:read`) scopes. Copy it when shown — it cannot be retrieved again.

***

## Store and search a memory

<Tabs>
  <Tab title="Python">
    **Install**

    ```bash theme={null}
    pip install thrindex
    ```

    **Store a memory**

    ```python theme={null}
    from thrindex import Thrindex

    client = Thrindex(api_key="th_live_...")

    memory_id = client.add(
        content="User prefers weekly email digests over push notifications.",
        agent_id="support-agent",
        user_id="user-42",
    )
    print(memory_id)  # "3f2e1d0c-..."
    ```

    The call returns immediately with `202 Accepted`. The memory is processed in the background and available for search within a few seconds.

    **Search memories**

    ```python theme={null}
    results = client.search(
        query="how does the user want to be contacted",
        agent_id="support-agent",
        user_id="user-42",
    )

    for hit in results:
        print(f"[{hit.score:.3f}] {hit.content}")
    ```

    `results` is a list of `SearchHit` objects ordered by relevance score. Inject the top results into your system prompt.
  </Tab>

  <Tab title="TypeScript">
    **Install**

    ```bash theme={null}
    npm install thrindex
    ```

    **Store a memory**

    ```typescript theme={null}
    import { ThrindexClient } from 'thrindex';

    const client = new ThrindexClient({ apiKey: 'th_live_...' });

    const memoryId = await client.add({
      content: 'User prefers weekly email digests over push notifications.',
      agentId: 'support-agent',
      userId: 'user-42',
    });
    console.log(memoryId); // "3f2e1d0c-..."
    ```

    **Search memories**

    ```typescript theme={null}
    const results = await client.search({
      query: 'how does the user want to be contacted',
      agentId: 'support-agent',
      userId: 'user-42',
    });

    for (const hit of results) {
      console.log(`[${hit.score.toFixed(3)}] ${hit.content}`);
    }
    ```
  </Tab>

  <Tab title="REST (curl)">
    **Store a memory**

    ```bash theme={null}
    curl -X POST https://api.thrindex.com/v1/memories \
      -H "Authorization: Bearer th_live_..." \
      -H "Content-Type: application/json" \
      -d '{
        "content": "User prefers weekly email digests over push notifications.",
        "agent_id": "support-agent",
        "user_id": "user-42"
      }'
    ```

    ```json theme={null}
    {
      "id": "3f2e1d0c-...",
      "status": "queued"
    }
    ```

    **Search memories**

    ```bash theme={null}
    curl -X POST https://api.thrindex.com/v1/memories/search \
      -H "Authorization: Bearer th_live_..." \
      -H "Content-Type: application/json" \
      -d '{
        "query": "how does the user want to be contacted",
        "agent_id": "support-agent",
        "user_id": "user-42"
      }'
    ```

    ```json theme={null}
    {
      "results": [
        {
          "id": "3f2e1d0c-...",
          "content": "User prefers weekly email digests over push notifications.",
          "score": 0.934,
          "importance": 0.8,
          "confidence": 1.0,
          "agent_id": "support-agent",
          "user_id": "user-42",
          "level": 0,
          "status": "active",
          "created_at": "2026-05-24T17:00:00Z"
        }
      ],
      "latency_ms": 42,
      "cache_hit": false
    }
    ```
  </Tab>
</Tabs>

***

## Typical agent loop

This is the recommended pattern for using Thrindex in a conversational agent:

```python theme={null}
from thrindex import Thrindex

client = Thrindex(api_key="th_live_...")

def handle_turn(agent_id: str, user_id: str, user_message: str) -> str:
    # 1. Retrieve relevant memories before calling the LLM
    memories = client.search(
        query=user_message,
        agent_id=agent_id,
        user_id=user_id,
        k=5,
    )

    # 2. Build system prompt with memory context
    memory_block = "\n".join(f"- {m.content}" for m in memories)
    system_prompt = f"User context from previous sessions:\n{memory_block}"

    # 3. Call your LLM (any provider)
    response = your_llm_call(system_prompt=system_prompt, user_message=user_message)

    # 4. Store the turn as a new memory for future sessions
    client.add(
        content=user_message,
        agent_id=agent_id,
        user_id=user_id,
    )

    return response
```

<Note>
  Always call the API from your backend. Never put API keys in browser code or mobile clients.
</Note>

***

## Next steps

<CardGroup cols={2}>
  <Card title="How it works" icon="gear" href="/concepts/how-it-works">
    Understand memory levels, processing pipeline, and the search ranking model.
  </Card>

  <Card title="Python SDK" icon="python" href="/sdks/python">
    Full method reference, async client, batch operations, and error handling.
  </Card>

  <Card title="TypeScript SDK" icon="square-js" href="/sdks/typescript">
    Complete TypeScript reference with type definitions for every response.
  </Card>

  <Card title="LLM Integrations" icon="robot" href="/sdks/integrations">
    Drop-in wrappers for OpenAI, Anthropic, LangChain, and LlamaIndex.
  </Card>
</CardGroup>
