Skip to main content
Metadata serves as a powerful tool for enriching objects with additional context, details, or configuration that can be instrumental in customizing and enhancing the functionality of each object. Specifically, the metadata field is available on Thread, Step, User, and Generation objects within the platform.

How to add metadata to a Run or a Step

import os, asyncio
from literalai import LiteralClient

from dotenv import load_dotenv
load_dotenv()

import os
from literalai import LiteralClient
literal_client = LiteralClient(api_key=os.getenv("LITERAL_API_KEY"))

@literal_client.step(type="run", name="my_step")
def my_step(input_message=None):
    current_step = literal_client.get_current_step()
    # some code, llm call, tool call, etc.
    current_step.metadata = {"region": "europe"}
    answer = "answer"
    return answer

my_step("Hello")

literal_client.flush_and_stop()
I