---
title: "Get LLM cost for a prompt optimization run"
method: GET
path: "/v2/prompt/optimize/{optimization_run_id}/costs"
tags: ["Prompt Optimization"]
---

# Get LLM cost for a prompt optimization run

`GET /v2/prompt/optimize/{optimization_run_id}/costs`

Get LLM usage costs for a specific prompt optimization run.

This endpoint returns the total cost and detailed usage records for all LLM requests
made during a prompt optimization run. Use this to track costs associated with
optimizing prompts for different target models.

**Cost Breakdown:**
- Total cost across all models used in the optimization
- Individual usage records with provider, model, tokens, and costs
- Timestamps for each LLM request

**Access Control:**
- Only accessible by the user who created the optimization run
- Requires prompt optimization access

## Path parameters

- `optimization_run_id` string, required

## Response `200`

Successfully retrieved optimization run costs

- AdaptationRunCostResponse — Response model for GET /v2/prompt/optimize/{optimization_run_id}/costs endpoint. Contains the total LLM costs and detailed usage records for a prompt adaptation run. Use this to track costs associated with optimizing prompts for different target models.
  - `optimization_run_id` string, required — Unique identifier for the adaptation run
  - `total_cost` number, required — Total cost in USD across all LLM requests in this adaptation run
  - `usage_records` LLMUsageResponse[], required — Detailed usage records for each LLM request made during the adaptation
    - `id` string, required — Unique identifier for this usage record
    - `user_id` string, required — User ID who made the request
    - `organization_id` string, required — Organization ID associated with the request
    - `adaptation_run_id` string, required — Adaptation run ID this usage is associated with
    - `provider` string, required — LLM provider (e.g., 'openai', 'anthropic', 'google')
    - `model` string, required — Model name (e.g., 'gpt-4', 'claude-3-opus-20240229')
    - `input_tokens` integer, required — Number of input tokens consumed
    - `output_tokens` integer, required — Number of output tokens generated
    - `input_cost` number, required — Cost of input tokens in USD
    - `output_cost` number, required — Cost of output tokens in USD
    - `total_cost` number, required — Total cost (input + output) in USD
    - `timestamp` number, required — Unix timestamp when the request was made
    - `task_type` string, required — Type of task: 'pre-optimization evaluation', 'optimization', or 'post-optimization evaluation'

## Other responses

- `401` — Authentication failed
- `403` — Access denied - optimization run does not belong to user
- `404` — Optimization run 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)
