Data in Literal AI can be exported at any time, as the data is always yours. Exporting data can be useful to train or fine-tune LLM models on production threads. You can export the data via the SDKs. There is also an export button on Literal AI, which shows you how to export the data via the SDKs.

Here’s an example of how to export all Threads:

import os
from literalai import LiteralClient

client = LiteralClient(api_key=os.getenv("LITERAL_API_KEY"))

has_next_page = True
after = None

filters = [
    {
        "field": "createdAt",
        "operator": "gte",
        "value": "2024-04-30T13:24:38.994Z"
    }
]

order_by = {
    "column": "createdAt",
    "direction": "DESC"
}
    
while has_next_page:
    response = client.api.get_threads(
        filters=filters,
        order_by=order_by,
        after=after
    )
    print(response.to_dict())
    has_next_page = response.pageInfo.hasNextPage
    after = response.pageInfo.endCursor