@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 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.
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 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.
