Skip to main content
The Python SDK instruments your agent from application code. Install it with pip install honeai and configure it once at startup.

init

Configure the SDK with your API key. Call it once, early, before any other Hone call.
Pass endpoint to target a non-default base URL, such as a local stack:
Load the key from the environment rather than hard-coding it: honeai.init(os.environ["HONE_API_KEY"]). See Authentication.

begin and end

begin() opens an interaction for a single agent turn and returns an object you close with end(). This is the most explicit way to record a turn, and it captures latency automatically from the time between the two calls.
begin parameters
ParameterTypeRequiredDescription
user_idstringYesPseudonymous identifier for the end user.
agent_namestringYesName of the agent handling this turn.
inputstringYesThe user’s message for this turn.
end parameters
ParameterTypeRequiredDescription
outputstringYesThe agent’s reply.
successboolNoWhether the turn succeeded. Defaults to true.
Mark a failed turn so it surfaces in error analytics:

track

track() records a completed turn in a single call. Reach for it when you already have both the input and the output in hand and do not need to hold an interaction open.
Parameters
ParameterTypeRequiredDescription
user_idstringYesPseudonymous end-user identifier.
inputstringYesThe user’s message.
outputstringYesThe agent’s reply.
agent_namestringNoName of the agent.
conversation_idstringNoGroups related turns into one conversation.

Conversation grouping

A conversation is a series of turns between one user and your agent. Pass the same conversation_id across track() calls to thread them together, so the dashboard shows them as one exchange under User Stories rather than as isolated turns.
Generate a fresh id when a new conversation starts, and reuse it for every follow-up turn in that exchange.

identify

identify() attaches traits to a user id. Traits enrich the user profile in the dashboard and become dimensions you can filter and segment on. Keep the id pseudonymous and avoid putting raw personal data in the traits.

set_property and set_properties

Within an open interaction, attach custom properties such as the model used, token counts, or cost. These ride along on the event and power metadata-driven charts and filters.
Use set_property for a single key and set_properties to attach several at once. Define the corresponding keys under Settings → Metadata Keys so they become selectable dimensions in the dashboard.

Full example

To capture MCP tool, resource, and prompt calls automatically, see MCP.