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

# API Reference

> Learn about the parameters and definitions of memory in Compozy.

## JSON Schema

```json https://compozy.dev/schemas/memory.json [expandable] theme={"dark"}
{
  "type": "object",
  "required": ["id", "vector"],
  "properties": {
    "id": {
      "type": "string",
      "description": "Unique identifier for the memory"
    },
    "storage": {
      "type": "object",
      "properties": {
        "use": {
          "type": "string",
          "description": "Storage implementation reference"
        },
        "config": {
          "type": "object",
          "description": "Storage-specific configuration"
        }
      },
      "required": ["use", "config"]
    },
    "vector": {
      "type": "object",
      "properties": {
        "use": {
          "type": "string",
          "description": "Vector store implementation reference"
        },
        "dimensions": {
          "type": "number",
          "description": "Vector dimensions for embeddings"
        },
        "config": {
          "type": "object",
          "description": "Vector store configuration"
        }
      },
      "required": ["use", "dimensions", "config"]
    },
    "embedder": {
      "type": "object",
      "properties": {
        "use": {
          "type": "string",
          "description": "Embedder implementation reference"
        },
        "config": {
          "type": "object",
          "description": "Embedder-specific configuration"
        }
      },
      "required": ["use", "config"]
    },
    "options": {
      "type": "object",
      "properties": {
        "lastMessages": {
          "type": "number",
          "description": "Number of recent messages to include"
        },
        "semanticRecall": {
          "type": "object",
          "properties": {
            "enabled": {
              "type": "boolean",
              "default": true
            },
            "maxResults": {
              "type": "number",
              "default": 5
            }
          }
        },
        "workingMemory": {
          "type": "object",
          "properties": {
            "enabled": {
              "type": "boolean",
              "default": false
            },
            "template": {
              "type": "string",
              "description": "XML template for structured memory"
            }
          }
        }
      }
    }
  }
}
```

## Parameters

<ParamField path="memory" type="object" required>
  Memory configuration for the workflow.
</ParamField>

<ParamField path="memory.id" type="string" required>
  Unique identifier for the memory.
</ParamField>

<ParamField path="memory.storage" type="object">
  Storage backend configuration. Defaults to in-memory if not specified. See [Storage Types](/core/memory/types#storage-types) for available options.

  <Expandable title="Properties">
    <ParamField path="use" type="string" required>
      Storage implementation reference (e.g., `"compozy/storage:postgres"`)
    </ParamField>

    <ParamField path="config" type="object" required>
      Storage-specific configuration options. Common fields:

      * `url`: Connection URL
      * `token`: Authentication token
      * `path`: File path (for SQLite)
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="memory.vector" type="object" required>
  Vector storage configuration for semantic search. See [Vector Types](/core/memory/types#vector-types) for available options.

  <Expandable title="Properties">
    <ParamField path="use" type="string" required>
      Vector store implementation reference (e.g., `"compozy/vector:pg-vector"`)
    </ParamField>

    <ParamField path="dimensions" type="number" required>
      Vector dimensions for embeddings (e.g., 1536 for OpenAI embeddings)
    </ParamField>

    <ParamField path="config" type="object" required>
      Vector store configuration options. Common fields:

      * `url`: Connection URL
      * `apiKey`: API key for managed services
      * `path`: Local path for file-based stores
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="memory.embedder" type="object">
  Embedder configuration for vector search. See [Embedder Types](/core/memory/types#embedder-types) for available options.

  <Expandable title="Properties">
    <ParamField path="use" type="string" required>
      Embedder implementation reference (e.g., `"compozy/embedder:openai"`)
    </ParamField>

    <ParamField path="config" type="object" required>
      Embedder-specific configuration. Common fields:

      * `model`: Model name or identifier
      * `apiKey`: API key for hosted services
      * `project`: Project ID (for cloud services)
    </ParamField>
  </Expandable>
</ParamField>

<ParamField path="memory.options" type="object">
  Memory behavior configuration.

  <Expandable title="Properties">
    <ParamField path="lastMessages" type="number">
      Number of recent messages to include in context
    </ParamField>

    <ParamField path="semanticRecall" type="object">
      Vector search configuration options:

      * `enabled`: Enable/disable semantic search
      * `maxResults`: Maximum number of results to return
    </ParamField>

    <ParamField path="workingMemory" type="object">
      Working memory configuration:

      * `enabled`: Enable/disable working memory
      * `template`: XML template for structured memory
    </ParamField>
  </Expandable>
</ParamField>

## Memory References

<ResponseField name="memory.<id>.current_thread" type="object">
  Current conversation thread data. Example:

  ```json theme={"dark"}
  {
    "thread_id": "thread_123",
    "messages": [
      {
        "role": "user",
        "content": "Hello!",
        "timestamp": "2024-03-20T10:30:00Z"
      }
    ],
    "metadata": {
      "created_at": "2024-03-20T10:30:00Z",
      "updated_at": "2024-03-20T10:30:00Z"
    }
  }
  ```
</ResponseField>

<ResponseField name="memory.<id>.last_messages" type="array">
  Recent message history based on lastMessages configuration. Example:

  ```json theme={"dark"}
  [
    {
      "role": "user",
      "content": "What's the weather?",
      "timestamp": "2024-03-20T10:29:00Z"
    },
    {
      "role": "assistant",
      "content": "It's sunny today.",
      "timestamp": "2024-03-20T10:29:30Z"
    }
  ]
  ```
</ResponseField>

<ResponseField name="memory.<id>.semantic_search" type="array">
  Semantic search results. Example:

  ```json theme={"dark"}
  [
    {
      "content": "Previous relevant conversation",
      "similarity": 0.92,
      "timestamp": "2024-03-19T15:45:00Z",
      "metadata": {
        "thread_id": "thread_122"
      }
    }
  ]
  ```
</ResponseField>
