Skip to main content

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_name str: 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_ref MetricRef: The metric implementation this config parameterizes — a MetricRef, not a metric name string.
  • workspace_id str: Workspace to own the config.
  • config_version str: Version of this named configuration.
  • params dict[str, Any] | None: Non-prompt parameters for the metric. Read at scoring time for every metric type.
  • prompts dict[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 — see PromptConfig.
  • client APIClient | None: Optional pre-configured API client.

Returns

Raises

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"],
)
},
)