npm install @hone/sdk and configure it once at startup.
init
Configure the SDK with your API key. Call it once, early, before any other Hone call.endpoint to target a non-default base URL, such as a local stack:
Load the key from the environment rather than hard-coding it:
init(process.env.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(). Latency is captured automatically from the time between the two calls.
begin options
| Option | Type | Required | Description |
|---|---|---|---|
userId | string | Yes | Pseudonymous identifier for the end user. |
agentName | string | Yes | Name of the agent handling this turn. |
input | string | Yes | The user’s message for this turn. |
end arguments
| Argument | Type | Required | Description |
|---|---|---|---|
output | string | Yes | The agent’s reply. |
success | boolean | No | Whether the turn succeeded. Defaults to true. |
track
track() records a completed turn in a single call. Reach for it when you already have both the input and the output and do not need to hold an interaction open.
| Option | Type | Required | Description |
|---|---|---|---|
userId | string | Yes | Pseudonymous end-user identifier. |
input | string | Yes | The user’s message. |
output | string | Yes | The agent’s reply. |
agentName | string | No | Name of the agent. |
conversationId | string | No | Groups related turns into one conversation. |
Conversation grouping
A conversation is a series of turns between one user and your agent. Pass the sameconversationId across track() calls to thread them together, so the dashboard shows them as one exchange under User Stories.
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.
setProperty and setProperties
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.setProperty for a single key and setProperties 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.