---
title: "Get prompt optimization results"
method: GET
path: "/v2/prompt/optimizeResults/{optimization_run_id}"
tags: ["Prompt Optimization"]
---

# Get prompt optimization results

`GET /v2/prompt/optimizeResults/{optimization_run_id}`

Retrieve the complete results of a prompt optimization run, including optimized prompts for all target models.

This endpoint returns the optimized prompts and evaluation metrics for each target model in your optimization request.
Call this endpoint after the optimization status is 'completed' to get your optimized prompts.

**Response Structure:**
- **origin_model**: Baseline performance of your original prompt on the origin model
  - Includes: system_prompt, user_message_template, score, evaluation metrics, cost
- **target_models**: Array of results for each target model
  - Includes: optimized system_prompt, user_message_template, template_fields
  - pre_optimization_score: Performance before optimization
  - post_optimization_score: Performance after optimization
  - Evaluation metrics and cost information

**Using Optimized Prompts:**
1. Extract the `system_prompt` and `user_message_template` from each target model result
2. Use `user_message_template_fields` to know which fields to substitute
3. Apply the optimized prompts when calling the respective target models
4. Compare pre/post optimization scores to see improvement

**Status Handling:**
- If optimization is still processing, target model results will have `result_status: "processing"`
- Only completed target models will have system_prompt and template values
- Failed target models will have `result_status: "failed"` with null values

**Cost Information:**
- Each model result includes cost in USD for the optimization process
- Costs vary based on model pricing and number of evaluation examples
- Typical range: $0.10 - $2.00 per target model

**Best Practices:**
1. Wait for status 'completed' before calling this endpoint
2. Check result_status for each target model
3. Validate that post_optimization_score > pre_optimization_score
4. Save optimized prompts for production use
5. A/B test optimized prompts against originals in production

## Path parameters

- `optimization_run_id` string, required

## Response `200`

Successfully retrieved optimization results

- AdaptationRunResultsResponse — Response model for GET /v2/prompt/optimizeResults/{optimization_run_id} endpoint. Contains the complete results of a prompt adaptation run, including optimized prompts and evaluation metrics for all target models. Use this to retrieve your adapted prompts after the adaptation status is 'completed'. The response includes: - Baseline performance of your original prompt on the origin model - Optimized prompts for each target model with pre/post optimization scores - Evaluation metrics and cost information for each model
  - `evaluation_metric` string, nullable
  - `evaluation_config` string, nullable
  - `id` string, required — Unique ID for this adaptation run
  - `created_at` string, date-time, required — Timestamp when this adaptation run was created
  - `updated_at` string, date-time, nullable, required — Timestamp of last update to this adaptation run
  - `origin_model` OriginModelAdaptationResultsResponse — Baseline results for the origin model in prompt adaptation. Part of AdaptationRunResultsResponse. Contains the performance metrics and prompt configuration for your original prompt on the origin model. This serves as the baseline to compare against optimized prompts for target models. **Fields include:** - Original system prompt and user message template - Baseline performance score and evaluation metrics - Cost of running the baseline evaluation - Job status for the origin model evaluation
    - `model_name` string, nullable, required
    - `score` number, nullable, required
    - `evals` object, nullable, required
    - `cost` number, nullable, required
    - `system_prompt` string, nullable — Original system prompt used for the origin model
    - `user_message_template` string, nullable — Original user message template used for the origin model
    - `result_status` 'created' | 'queued' | 'processing' | 'completed' | 'failed' | 'cancelled' — Status enum for asynchronous jobs (prompt adaptation, custom router training, etc.). Represents the current state of a long-running operation: - **created**: Job has been initialized but not yet queued - **queued**: Job is waiting in the queue to be processed - **processing**: Job is currently being executed - **completed**: Job finished successfully and results are available - **failed**: Job encountered an error and did not complete - **cancelled**: Job was cancelled due to a restart operation
  - `target_models` TargetModelAdaptationResultsResponse[], required — Results for each target model with optimized prompts and improvement scores
    - `model_name` string, required
    - `pre_optimization_score` number, nullable, required
    - `pre_optimization_evals` object, nullable, required
    - `post_optimization_score` number, nullable, required
    - `post_optimization_evals` object, nullable, required
    - `cost` number, nullable, required
    - `task_type` string, nullable, required
    - `system_prompt` string, nullable — Optimized system prompt for this target model. Use this as the system message in your LLM calls
    - `user_message_template` string, nullable — Optimized user message template with placeholders. Substitute fields using your data before calling the LLM
    - `user_message_template_fields` string[], nullable — List of field names to substitute in the template (e.g., ['question', 'context']). These match the curly-brace placeholders in user_message_template
    - `result_status` 'created' | 'queued' | 'processing' | 'completed' | 'failed' | 'cancelled' — Status enum for asynchronous jobs (prompt adaptation, custom router training, etc.). Represents the current state of a long-running operation: - **created**: Job has been initialized but not yet queued - **queued**: Job is waiting in the queue to be processed - **processing**: Job is currently being executed - **completed**: Job finished successfully and results are available - **failed**: Job encountered an error and did not complete - **cancelled**: Job was cancelled due to a restart operation
  - `job_status` 'created' | 'queued' | 'processing' | 'completed' | 'failed' | 'cancelled', required — Status enum for asynchronous jobs (prompt adaptation, custom router training, etc.). Represents the current state of a long-running operation: - **created**: Job has been initialized but not yet queued - **queued**: Job is waiting in the queue to be processed - **processing**: Job is currently being executed - **completed**: Job finished successfully and results are available - **failed**: Job encountered an error and did not complete - **cancelled**: Job was cancelled due to a restart operation
  - `llm_request_metrics` object[], nullable — Metrics for the LLM requests made during the adaptation run. List of {model: str, num_requests: int}.
  - `prototype_mode` boolean — Whether this adaptation run was created with prototype mode (3-24 training examples allowed). Prototype mode may have degraded performance compared to standard mode (25+ examples)

## Other responses

- `401` — Authentication failed or no prompt optimization access
- `403` — Run ID does not belong to user
- `404` — Optimization run ID not found
- `422` — Validation Error

---

[API](https://skmtc.net/not-diamond/apis/not-diamond-api.md) · [All operations](https://skmtc.net/not-diamond/apis/not-diamond-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/not-diamond/not-diamond-api/versions/ea8fcb544470/schema)
