GeezerVison is showing docs.learningcommons.org — Configuration - Learning Commons Docs Import and configure the evaluator of your choice.
from learning_commons_evaluators import (
EvaluatorConfig,
GradeLevelAppropriatenessEvaluator,
)
# Pass a config object...
config = EvaluatorConfig(google_api_key="your-google-key")
evaluator = GradeLevelAppropriatenessEvaluator(config)
# ...or pass the same fields as keyword arguments
evaluator = GradeLevelAppropriatenessEvaluator(google_api_key="your-google-key")
Credentials are always passed in explicitly. The SDK never reads them from environment variables.
Options
At runtime, our evaluators default to the provider and model they were validated against – e.g., Grade Level Appropriateness uses Google Gemini out of the box, because it was validated against it during development.We recommend using the validated provider and model for our evaluators, but you can override that default with the model_override or llm_provider option.
| Field | Type | Description |
|---|
google_api_key | str | None | Google API key
Required for evaluators that: | openai_api_key | str | None | OpenAI API key
Required for evaluators that: | anthropic_api_key | str | None | Anthropic API key
Required for evaluators that:- Default to Anthropic
- Have
model_override set to Provider.ANTHROPIC, or - Have
llm_provider set to an Anthropic model
| learning_commons_api_key v1.0.0 | str | None | Learning Commons API key ↗
Required for Academic Standards evaluators, which call the Knowledge Graph REST API
For telemetry, set learning_commons_api_key on the telemetry option instead. | llm_provider v1.3.0 | LLMProvider | Inject your own LLM provider – no vendor API key is needed when this property is set. The evaluator routes every LLM call through it and skips built-in API-key adapters. Cannot be set together with model_override.
For evaluators that take images, like the Graphics evaluators, your provider must set supports_attachments and accept image attachments (ImageAttachment). Otherwise, the evaluator raises a ConfigurationError when you create it. | model_override | ModelOverride | None ↗ | Overrides the evaluator’s default provider and model. Both provider and model are required. See Model override | max_retries | int | Default: 2. Maximum retry attempts for failed evaluator calls. Total attempts are 1 + max_retries. 0 disables retrying | telemetry | bool | TelemetryOptions ↗ | Default: True. Configuration for collecting telemetry. Set learning_commons_api_key on this option to attribute events to your Learning Commons user; omit the key for anonymous events. |
Evaluators are validated and tested against their default models. Results with
other models (using model_override) may vary.
Model override
model_override overrides the evaluator’s default provider and model. Both provider and model are required.
from learning_commons_evaluators import (
EvaluatorConfig,
GradeLevelAppropriatenessEvaluator,
ModelOverride,
Provider,
)
config = EvaluatorConfig(
anthropic_api_key="your-anthropic-key",
model_override=ModelOverride(provider=Provider.ANTHROPIC, model="claude-haiku-4-5-20251001"),
)
evaluator = GradeLevelAppropriatenessEvaluator(config)
Provider is a closed set: Provider.OPENAI, Provider.GOOGLE, and Provider.ANTHROPIC.
An override replaces the evaluator’s own LLM key requirement with the override provider’s. The example above needs anthropic_api_key, not google_api_key. It does not skip credentials for a non-LLM service the evaluator still calls. A model id the provider rejects surfaces as a ConfigurationError when the provider answers.
Logging
Customize how your evaluator logs information.
The SDK uses Python’s standard logging module, attaches a NullHandler to its own logger, and never calls logging.basicConfig() or configures the root logger. Each evaluator logs to a child of learning_commons_evaluators named for its registry id — for example, learning_commons_evaluators.text_complexity.ela_reading.grade_level_appropriateness.
Coming from the TypeScript SDK? There, logger and logLevel are constructor
options. In Python you configure the standard library logger instead.
Log level
Control logging verbosity:
import logging
from learning_commons_evaluators import SDK_LOGGER_NAME
# Your application configures handlers; SDK records propagate to the root
logging.basicConfig(level=logging.DEBUG)
# Quiet the SDK while the rest of your app stays at DEBUG
logging.getLogger(SDK_LOGGER_NAME).setLevel(logging.WARNING)
# Or silence it entirely: the SDK's own NullHandler absorbs the records
logging.getLogger(SDK_LOGGER_NAME).propagate = False
Custom logger
Instead of injecting a logger, point the SDK’s logger at your handlers:
import logging
from learning_commons_evaluators import create_logger
# Pick one: every evaluator in the process...
create_logger(level=logging.INFO)
# ...a single evaluator, named by its registry id...
create_logger("text_complexity.ela_reading.grade_level_appropriateness", level=logging.DEBUG)
# ...or your own handler and format, in place of the default StreamHandler
handler = logging.StreamHandler()
handler.setFormatter(logging.Formatter("[%(levelname)s] %(name)s: %(message)s"))
create_logger(handler=handler, level=logging.INFO)
create_logger attaches a StreamHandler only when the target logger has none of its own, but a handler you pass is always added.
Telemetry
We collect limited usage and performance telemetry by default. This may include performance metrics (latency, token usage), technical metadata (such as SDK version and evaluator type) and related diagnostic information. This telemetry helps us improve evaluator quality, identify edge cases, and optimize performance.
Telemetry never carries the text being evaluated. You can disable telemetry collection through the configuration options.
What you’ll need
While telemetry data collection is not required, we recommend enabling it so
that we can better support your team’s use cases.
Telemetry is on by default. Events are anonymous unless you set learning_commons_api_key on the telemetry option.
To attribute events to your Learning Commons user, generate an API key ↗ and include it in your evaluator’s configuration options:
from learning_commons_evaluators import EvaluatorConfig, TelemetryOptions
# Shorthand: off
config = EvaluatorConfig(google_api_key="...", telemetry=False)
# Granular: on, and attributed to your Learning Commons account
config = EvaluatorConfig(
google_api_key="...",
telemetry=TelemetryOptions(
enabled=True,
learning_commons_api_key="your-learning-commons-api-key",
),
)
We don’t collect your API keys or any user identifiers through the SDK.
What we collect
| Field | Description |
|---|
timestamp | ISO 8601 timestamp when evaluation started | sdk_version | SDK version (e.g., "0.1.0") | evaluator_type | Which evaluator ran (registry id, e.g., "text_complexity.ela_reading.vocabulary_complexity") | grade | Grade level evaluated. Empty for an evaluator that takes none. The wire field is grade, not grade_level | status | Evaluation outcome ("success" or "error") | error_code | Error type if status is "error" (the exception class name, e.g., "ConfigurationError") | latency_ms | Total evaluation time in milliseconds | text_length_chars | Length of input text in characters | provider | LLM provider(s) used (e.g., "openai:gpt-4o", "google:gemini-2.5-pro") | model_override | true if the caller supplied a model_override; omitted otherwise | token_usage | Total tokens consumed (input and output) | metadata.stage_details | Per-stage breakdown for multi-stage evaluators (optional) |
When telemetry is disabled, nothing is sent.
Related topics
QuickstartInstall the SDK and run your first evaluator. EvaluationUnderstand evaluator output fields and types. Error handlingHandle configuration, validation, and API errors. |