v2

latestOpenAPI 3.1.02026-07-26103975.6 KB
Prompt Optimization

Get LLM cost for a prompt optimization run

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
get/v2/prompt/optimize/{optimization_run_id}/costs

Path parameters

optimization_run_idstring required

Response

Successfully retrieved optimization run costs

optimization_run_idstring required

Unique identifier for the adaptation run

total_costnumber required

Total cost in USD across all LLM requests in this adaptation run

Example response

{
  "optimization_run_id": "550e8400-e29b-41d4-a716-446655440000",
  "total_cost": 0.0456,
  "usage_records": [
    {
      "id": "llm_usage_123",
      "input_cost": 0.0125,
      "input_tokens": 250,
      "model": "gpt-4",
      "optimization_run_id": "550e8400-e29b-41d4-a716-446655440000",
      "organization_id": "org_xyz",
      "output_cost": 0.006,
      "output_tokens": 100,
      "provider": "openai",
      "task_type": "optimization",
      "timestamp": 1705320600.123456,
      "total_cost": 0.0185,
      "user_id": "user_abc"
    }
  ]
}