---
title: "Create Code Metric Generation"
method: POST
path: "/code-metric-generations"
tags: ["code-metric-generation"]
---

# Create Code Metric Generation

`POST /code-metric-generations`

Generate scorer code from a user message (natural language, existing code, or combination).

Creates a background job that calls an LLM with the code metric generation system prompt.
Returns a generation ID for polling.

**Response:** 202 Accepted with generation ID.

## Request body

- CreateCodeMetricGenerationRequest — Request to generate scorer code from a user message.
  - `user_message` string, required — Natural language, code, or combination
  - `node_type` string, nullable — Selected scoreable node type (llm, retriever, trace, agent, workflow, tool, session)
  - `output_type` 'boolean' | 'categorical' | 'count' | 'discrete' | 'freeform' | 'percentage' | 'multilabel' | 'retrieved_chunk_list_boolean' | 'boolean_multilabel' — Enumeration of output types.
  - `model_name` string, nullable — Model alias to use for generation. Defaults to best available.

## Response `202`

Successful Response

- CreateCodeMetricGenerationResponse — Response with generation ID for polling.
  - `id` string, uuid4, required
  - `status` 'generating' | 'completed' | 'failed', required

## Other responses

- `422` — Validation Error

---

[API](https://skmtc.net/galileo/apis/galileo-api-server.md) · [All operations](https://skmtc.net/galileo/apis/galileo-api-server/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/galileo/galileo-api-server/revisions/933e8c8e6366/schema)
