@honeyhive/api-client is a type-safe TypeScript client for the HoneyHive REST API. It provides a one-to-one mapping of methods to API endpoints, organized into namespaces: client.datasets, client.datapoints, client.experiments, etc.
Built on openapi-fetch, the client handles response parsing, query serialization, and error handling automatically. All request and response types are generated from the OpenAPI specification, so your editor provides full autocompletion and type checking for every API call.
If you’re coming from the legacy @honeyhive/logger package, see the migration guide.
Installation
Quick start
Create a session (trace) and log an OpenAI call:Example: Creating and populating a dataset
Authorization
The HoneyHive API authenticates requests using an API key sent as a Bearer token in theAuthorization header. There are three ways to provide a project API key, and an ingestion key has its own slot alongside it.
Environment variable (recommended)
Set theHH_PROJECT_API_KEY environment variable. The client reads it automatically when no projectApiKey option is provided:
projectApiKey option
Pass the key directly inClientConfig.
Never hard-code the key or commit it to source control. Always read it from a secret store or environment variable.
Ingestion API key
An ingestion API key (hh_ingst_) can be held alongside the project key, in the HH_INGESTION_API_KEY environment variable or the ingestionApiKey option. The methods that create sessions and create or update events (singly or in batches) send it when it is set, and fall back to the project key otherwise. Every other method uses the project key and never the ingestion key.
404. Construction fails only when neither key is available and no middleware is supplied. The ingestion key’s value is checked at construction: anything that is not an hh_ingst_ key throws, naming where the value came from and the expected prefix.
Custom middleware
For advanced scenarios (rotating keys, fetching tokens at request time), you can supply custom middleware that sets theAuthorization header on each request. Middleware runs after the initial headers are set, so it will override any API key provided via projectApiKey or HH_PROJECT_API_KEY.
When middleware is provided without an API key, the client skips the missing-key error and assumes the middleware handles authentication. If both are provided, the API key sets the initial header and the middleware can override it per-request.
The required header format is Authorization: Bearer <api-key>.
Middleware interface.
Data plane URL
By default the client talks tohttps://api.dp1.us.honeyhive.ai. To point at a self-hosted deployment or a staging environment, set the HH_DATA_PLANE_URL environment variable or pass dataPlaneUrl:
Verbose logging
Setverbose: true (or the HH_VERBOSE environment variable to true) to log the resolved data plane URL, a masked API key, and the SDK package + version when the client is constructed. Useful for confirming which environment and credential the client is configured with.
console.error (stderr in Node, devtools in the browser) and only fires once per client construction. An explicit verbose: false overrides HH_VERBOSE. The masked project API key keeps the recognized prefix (hh_ for a project key, hh_ro_ for a read-only project key) and the last 4 characters; anything else renders as 8 fixed-width asterisks. An ingestion key renders as hh_ingst_<key id>_******, showing its id and none of its secret.