honeyhive.config.models.base
Base configuration models for HoneyHive SDK.
This module provides the base Pydantic models that contain common fields shared across different domain-specific configurations. This approach eliminates duplication while maintaining type safety and validation.
The models follow graceful degradation principles - invalid values are logged
as warnings and replaced with safe defaults to prevent crashing the host application.
That rule covers values the SDK can do without. Two things raise instead: a
connection argument of the wrong type at an entry point (checked in
honeyhive.config.resolved; _present there says why), and a present
ingestion_api_key of the wrong kind, here and in the resolver alike, because
whoever set it meant to, and dropping it silently would send telemetry with the
wrong key and lose it with no signal.
RESOLVED_FIELDS
module-attribute
BaseHoneyHiveConfig
Bases: BaseSettings
Base configuration model with common HoneyHive fields.
This base class contains fields that are commonly used across different parts of the SDK (tracer, API client, evaluation, etc.) to avoid duplication and ensure consistent validation.
Common Fields
- api_key: HoneyHive API key for authentication (from HH_API_KEY)
- ingestion_api_key: Ingestion API key for sending traces and events (from HH_INGESTION_API_KEY; optional, api_key is used for those requests when unset)
- server_url: HoneyHive API URL (from HH_API_URL)
- project: Deprecated project name (optional; backend infers scope from API key)
- test_mode: Enable test mode (no data sent to backend)
- verbose: Enable verbose logging
Example
This class is not used directly but inherited by domain-specific configs:
class TracerConfig(BaseHoneyHiveConfig): ... session_name: Optional[str] = None ... source: str = "dev"
config = TracerConfig(api_key="hh_...", project="my-project") print(config.api_key) # Inherited from base hh_...
Source code in src/honeyhive/config/models/base.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | |
api_key
class-attribute
instance-attribute
api_key: Optional[str] = Field(
default_factory=environment_api_key,
description="HoneyHive API key for authentication",
examples=["hh_1234567890abcdef"],
)
ingestion_api_key
class-attribute
instance-attribute
ingestion_api_key: Optional[str] = Field(
default_factory=environment_ingestion_api_key,
description="Ingestion API key (begins with hh_ingst_) sent with requests that create sessions or write events. When unset, api_key is used for those requests too.",
examples=["hh_ingst_..."],
)
server_url
class-attribute
instance-attribute
server_url: str = Field(
default_factory=environment_api_url,
description="Custom HoneyHive server URL",
examples=[
DEFAULT_API_URL,
"https://custom.honeyhive.com",
],
)
project
class-attribute
instance-attribute
project: Optional[str] = Field(
default=None,
description="Deprecated. Legacy project name accepted for backwards compatibility but no longer used — the backend infers project context from the API key. Will be removed in v2.0.",
examples=["my-llm-project", "chatbot-v2"],
)
test_mode
class-attribute
instance-attribute
test_mode: bool = Field(
default=False,
description="Enable test mode (no data sent to backend)",
)
verbose
class-attribute
instance-attribute
verbose: bool = Field(
default=False,
description="Enable verbose logging output and debug mode",
)
settings_customise_sources
classmethod
settings_customise_sources(
settings_cls: type[BaseSettings],
init_settings: PydanticBaseSettingsSource,
env_settings: PydanticBaseSettingsSource,
dotenv_settings: PydanticBaseSettingsSource,
file_secret_settings: PydanticBaseSettingsSource,
) -> tuple[PydanticBaseSettingsSource, ...]
Exclude the resolver's fields from the environment source.
Source code in src/honeyhive/config/models/base.py
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | |
validate_api_key
classmethod
Validate API key format with graceful degradation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
Any
|
The API key value to validate |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
The validated and normalized API key, or None if invalid |
Source code in src/honeyhive/config/models/base.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 | |
validate_ingestion_api_key
classmethod
Apply the ingestion key's shape rule to an explicitly constructed value.
Values from the resolver arrive already checked; this covers
Config(ingestion_api_key=...). None and a blank string mean unset,
so api_key is used for ingestion too. Anything else was set on purpose
and must be an ingestion API key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
Any
|
The ingestion API key value to validate |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
The validated key, or None when unset |
Raises:
| Type | Description |
|---|---|
ValueError
|
The value is not a string, or is present and is not an ingestion API key. |
Source code in src/honeyhive/config/models/base.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
validate_server_url
classmethod
Apply the API URL shape rule to an explicitly constructed value.
Values from the resolver arrive already normalized; this covers
Config(server_url=...). Absent or blank means the default.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
Any
|
The server URL to validate |
required |
Returns:
| Type | Description |
|---|---|
str
|
The normalized URL, or the default when absent or malformed |
Source code in src/honeyhive/config/models/base.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |
validate_project
classmethod
Validate project name format with graceful degradation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
Any
|
The project name to validate |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
The validated and normalized project name, or None if invalid |
Source code in src/honeyhive/config/models/base.py
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | |
validate_boolean_fields
classmethod
Validate boolean fields with graceful degradation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
v
|
Any
|
The value to validate as boolean |
required |
Returns:
| Type | Description |
|---|---|
bool
|
The validated boolean value, or False if invalid |
Source code in src/honeyhive/config/models/base.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 | |