@honeyhive/logger package to @honeyhive/api-client.
What changes for you
@honeyhive/logger targets HoneyHive v1 and is being replaced by @honeyhive/api-client, the typed v2 SDK. The two are not drop-in compatible, but you get a lot more in return:
- Full typed access to the v2 API. Beyond logging events, you can manage datasets, datapoints, experiments, metrics, and event search from the same client.
- One
Clientinstance, not per-call config. Set your API key once viaHH_API_KEYinstead of passingapiKey(andproject) on every call. - Project scope is automatic. v2 API keys are scoped to a single project, so the SDK no longer needs a
projectparameter. If you write to multiple projects, construct oneClientper key. - Errors surface instead of being swallowed. Failed calls throw typed errors you can catch, rather than logging to
console.errorand returningundefined.
start, log, update) map onto two namespaces on the new client: client.sessions and client.events.
Install and import
Configuration
See the fullClientConfig reference for every option. The most common settings and mechanism for setting them are below.
| Concept | Logger (@honeyhive/logger) | API client (@honeyhive/api-client) |
|---|---|---|
| API key | apiKey param on every call. | Set the HH_API_KEY environment variable. |
| Project | project param on every call. | Determined by the API key’s project scope. No project parameter exists. |
Data Plane URL (was serverUrl) | serverUrl param, default https://api.honeyhive.ai. | dataPlaneUrl in the Client constructor or HH_DATA_PLANE_URL environment variable, default https://api.dp1.us.honeyhive.ai. serverUrl and HH_API_URL are deprecated aliases. |
| Source / environment | source param, default "dev". | source on the session/event body. Both sessions and events default to "unknown" if omitted. Set it explicitly (e.g. "prod", "staging") if you want to filter by environment. |
| Verbose | verbose per-call. | HH_VERBOSE=true env var (or ClientConfig.verbose). One-shot startup log of resolved URL and masked key. |
TLS / certificate verification
Logger exposed a per-callverify flag (Node-only). The new SDK is isomorphic - it runs in Node and the browser - and TLS verification isn’t something you can flip from JavaScript in the browser, so the SDK doesn’t expose a flag.
In Node, if you genuinely need to disable verification (for example, to talk to an internal HoneyHive deployment with a self-signed cert), use the standard Node environment variables: prefer NODE_EXTRA_CA_CERTS=/path/to/ca.pem to register the internal CA, or NODE_TLS_REJECT_UNAUTHORIZED=0 as a last resort. Do not disable verification against the public HoneyHive endpoint.
In the browser, certificate trust is browser-managed - trust the cert at the OS or browser level.
Retry behavior changed
Function-by-function migration
start(...) → client.sessions.create(...)
See the sessions namespace for the full method reference.
Before:
| Logger | New SDK | Notes |
|---|---|---|
apiKey | Client constructor / HH_API_KEY | Once per client, not per call |
project | - | Determined by API key |
sessionName | session_name | |
source | source | |
sessionId | session_id | UUID still optional; auto-generated if omitted |
config | config | |
inputs | inputs | |
metadata | metadata | |
userProperties | user_properties | |
serverUrl | dataPlaneUrl in the Client constructor / HH_DATA_PLANE_URL | Once per client, not per call. serverUrl and HH_API_URL are deprecated aliases |
verbose | Client constructor / HH_VERBOSE | One-shot startup log, not per-call verbosity |
CreateSessionResponse (which includes both session_id and a separate event_id - see Updating a session below) and throws on failure rather than swallowing the error. See Error handling below.
log(...) → client.events.create(...)
See the events namespace for the full method reference.
Before:
| Logger | New SDK | Notes |
|---|---|---|
apiKey / project | - | Set on the client / API key, not per call |
sessionId | session_id | |
eventName | event_name | |
eventType | event_type | Same union: 'model' | 'tool' | 'chain'. New SDK additionally accepts 'session'. |
durationMs | duration | Renamed: still milliseconds. |
source | source | |
config, inputs, outputs, metadata | same names | |
| - | parent_id, children_ids, error, start_time, end_time, feedback, metrics, user_properties | New optional fields you didn’t have before |
client.events.createBatch({ events: [...] }) - it submits them in a single request.
update(...) → client.events.update(...)
Before:
durationMs → duration, userProperties → user_properties.
Updating a session
This is a meaningful behavior change. In v1, the legacy server treatedsession_id and event_id interchangeably for updates, so logger’s update({ eventId }) would accept either. In v2 it does not - passing a session_id to events.update returns a 400 Bad Request with the message no event with event_id - <id> found.
A session is itself an event with event_type: 'session'. client.sessions.create returns both identifiers:
session_id- the session correlation ID. Use this as thesession_idon child events to associate them with the session.event_id- the row ID of the session-typed event itself. Use this when you want to update the session row.
events.update only merges nine specific fields: metadata, feedback, metrics, outputs, config, user_properties, duration, end_time, children_ids. Other fields are accepted by the server but silently ignored.
End-to-end example
A complete flow - start a session, log a model event, update it with the response - looks like this:@honeyhive/api-client README has the same example with more commentary.
Error handling
Logger swallowed errors by default - when a call failed, it logged toconsole.error and returned null (set verbose: true to make it throw instead). The new SDK throws on failure:
ApiError- the server returned a non-2xx response. Carries.status,.response,.error, and a.parseError()helper that returns a typedErrorResponsewhen the body matches.NetworkError- the request never made it to the server (DNS, connection reset, TLS failure, etc.). Carries.errorwith the underlying cause.
HoneyHiveError, so a single catch (err) { if (err instanceof HoneyHiveError) ... } handles both:
null on failure and kept going), you’ll need to add a try/catch to preserve that behavior - or, better, decide whether failing loud is what you actually want.
What else you get
Migrating opens up a much larger API surface. None of these have a logger equivalent:client.events.search- query events by filter, date range, or evaluation_idclient.events.createBatch- bulk-create events in one requestclient.datasets- create, list, update, delete datasets and add/remove datapointsclient.datapoints- CRUD on datapointsclient.experiments- manage runs, fetch run schemas, compare runsclient.metrics- create, list, run server-side metrics
@honeyhive/api-client README. For the full reference, see the API SDK reference site.
