aip_sdk.create_metric_config
aip_sdk.create_metric_config(config_name: str, metric_ref: MetricRef, *, workspace_id: str, config_version: str = '1.0.0', params: dict[str, Any] | None = None, prompts: dict[str, PromptConfig] | None = None, client: APIClient | None = None) -> MetricConfig
Create a versioned metric configuration, owned by workspace_id.
Not defaulted from the client's configured workspace, unlike project-scoped resources
elsewhere in this SDK — a config's owning workspace is part of its identity
((workspace_id, config_name, config_version) is the uniqueness key), so it must be
named explicitly rather than assumed.
Parameters
config_namestr: Configuration name, e.g."rubric_prompt_a". Not globally unique — uniqueness is on(workspace_id, config_name, config_version), so a workspace can hold several differently-named configs for the same metric.metric_refMetricRef: The metric implementation this config parameterizes — aMetricRef, not a metric name string.workspace_idstr: Workspace to own the config.config_versionstr: Version of this named configuration.paramsdict[str, Any] | None: Non-prompt parameters for the metric. Read at scoring time for every metric type.promptsdict[str, PromptConfig] | None: Named Jinja2 prompt templates, keyed by slot name. Stored and versioned for any metric, but only agentic trace metrics read this back at scoring time today — seePromptConfig.clientAPIClient | None: Optional pre-configured API client.
Returns
MetricConfigMetricConfig: the created config.
Raises
MetricConfigAlreadyExistsError: If this scope already holds a config at(config_name, config_version).MetricConfigValidationError: If the document fails server-side validation.NotFoundError: Ifworkspace_idnames a workspace that does not exist.ForbiddenError: If the caller lacks a write-capable role for this scope.AuthError: If no credentials are configured.APIError: If creation otherwise fails, or the response is malformed.
Example:
config = aip.create_metric_config(
"rubric_prompt_a",
aip.MetricRef(name="agent.custom_judge_rubric", implementation_version="1.0.0"),
prompts={
"judge": aip.PromptConfig(
prompt_template="Evaluate {{ response }} against {{ criteria }}.",
expected_variables=["response", "criteria"],
)
},
)