lunary API Reference

Classes

ClassDescription
EventQueueA class that represents a queue of events.
ConsumerA class that consumes events from the EventQueue.
UserContextManagerA context manager for setting and resetting user context.

Methods

MethodDescription
config(app_id: str | None = None, verbose: str | None = None, api_url: str | None = None, disable_ssl_verify: bool | None = None)Configures the SDK with the given parameters.
track_event(event_type: str, event_name: str, run_id: uuid, parent_run_id: uuid, name: str, input: Any, output: Any, error: Any, token_usage: Any, user_id: str, user_props: Any, tags: Any, extra: Any) -> NoneTracks an event with the given parameters.
handle_internal_error(e: Exception) -> NoneHandles internal errors.
wrap(fn: Callable, type: str, name: str, user_id: str, user_props: Any, tags: Any, input_parser: Callable, output_parser: Callable) -> CallableWraps a function with monitoring capabilities.
monitor(object: OpenAIUtils) -> NoneMonitors an instance of OpenAIUtils.
identify(user_id: str, user_props: Any) -> UserContextManagerIdentifies a user and sets the user context.

Decorators

DecoratorDescription
agent(name: str, user_id: str, user_props: Any, tags: Any) -> CallableA decorator for marking a function as an agent.
tool(name: str, user_id: str, user_props: Any, tags: Any) -> CallableA decorator for marking a function as a tool.

Context Variables

VariableDescription
user_ctxA context variable for storing the user ID.
user_props_ctxA context variable for storing user properties.

Environment variables

VariableDescription
LUNARY_PUBLIC_KEYYour project's public key
LUNARY_PRIVATE_KEYYour project's private key
LUNARY_VERBOSEEnable verbose logging
LUNARY_API_URLBase URL for the API server. Defaults to https://api.lunary.ai; can be customized for self-hosting or local use.
DISABLE_SSL_VERIFYDisable SSL verification if set to True

Questions? We're here to help.

Email