notdiamond 2.2.1 → 2.2.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -119,20 +119,21 @@ export class PromptOptimization extends APIResource {
119
119
  }
120
120
 
121
121
  /**
122
- * Adapt your prompt from one LLM to work optimally across different target LLMs.
122
+ * Optimize your prompt from one LLM to work optimally across different target
123
+ * LLMs.
123
124
  *
124
125
  * This endpoint automatically optimizes your prompt (system prompt + user message
125
126
  * template) to improve accuracy on your use case across various models. Each model
126
127
  * has unique characteristics, and what works well for GPT-5 might not work as well
127
128
  * for Claude or Gemini.
128
129
  *
129
- * **How Prompt Adaptation Works:**
130
+ * **How Prompt Optimization Works:**
130
131
  *
131
132
  * 1. You provide your current prompt and optionally your current origin model
132
- * 2. You specify the target models you want to adapt your prompt to
133
+ * 2. You specify the target models you want to optimize your prompt to
133
134
  * 3. You provide evaluation examples (golden records) with expected answers
134
135
  * 4. The system runs optimization to find the best prompt for each target model
135
- * 5. You receive adapted prompts that perform well on your target models
136
+ * 5. You receive optimized prompts that perform well on your target models
136
137
  *
137
138
  * **Evaluation Metrics:** Choose either a standard metric or provide custom
138
139
  * evaluation:
@@ -169,10 +170,6 @@ export class PromptOptimization extends APIResource {
169
170
  * 4. Use optimized prompts in production with target models
170
171
  * ```
171
172
  *
172
- * **Related Documentation:** See
173
- * https://docs.notdiamond.ai/docs/adapting-prompts-to-new-models for detailed
174
- * guide.
175
- *
176
173
  * @example
177
174
  * ```ts
178
175
  * const response = await client.promptOptimization.optimize({
@@ -238,6 +235,39 @@ export class PromptOptimization extends APIResource {
238
235
  ): APIPromise<PromptOptimizationOptimizeResponse> {
239
236
  return this._client.post('/v2/prompt/optimize', { body, ...options });
240
237
  }
238
+
239
+ /**
240
+ * Get LLM usage costs for a specific prompt optimization run.
241
+ *
242
+ * This endpoint returns the total cost and detailed usage records for all LLM
243
+ * requests made during a prompt optimization run. Use this to track costs
244
+ * associated with optimizing prompts for different target models.
245
+ *
246
+ * **Cost Breakdown:**
247
+ *
248
+ * - Total cost across all models used in the optimization
249
+ * - Individual usage records with provider, model, tokens, and costs
250
+ * - Timestamps for each LLM request
251
+ *
252
+ * **Access Control:**
253
+ *
254
+ * - Only accessible by the user who created the optimization run
255
+ * - Requires prompt optimization access
256
+ *
257
+ * @example
258
+ * ```ts
259
+ * const response =
260
+ * await client.promptOptimization.retrieveCosts(
261
+ * 'optimization_run_id',
262
+ * );
263
+ * ```
264
+ */
265
+ retrieveCosts(
266
+ optimizationRunID: string,
267
+ options?: RequestOptions,
268
+ ): APIPromise<PromptOptimizationRetrieveCostsResponse> {
269
+ return this._client.get(path`/v2/prompt/optimize/${optimizationRunID}/costs`, options);
270
+ }
241
271
  }
242
272
 
243
273
  /**
@@ -313,7 +343,8 @@ export interface RequestProvider {
313
343
  }
314
344
 
315
345
  /**
316
- * Response model for GET /v2/prompt/adaptResults/{adaptation_run_id} endpoint.
346
+ * Response model for GET /v2/prompt/optimizeResults/{optimization_run_id}
347
+ * endpoint.
317
348
  *
318
349
  * Contains the complete results of a prompt adaptation run, including optimized
319
350
  * prompts and evaluation metrics for all target models. Use this to retrieve your
@@ -572,6 +603,106 @@ export interface PromptOptimizationOptimizeResponse {
572
603
  optimization_run_id: string;
573
604
  }
574
605
 
606
+ /**
607
+ * Response model for GET /v2/prompt/optimize/{optimization_run_id}/costs endpoint.
608
+ *
609
+ * Contains the total LLM costs and detailed usage records for a prompt adaptation
610
+ * run. Use this to track costs associated with optimizing prompts for different
611
+ * target models.
612
+ */
613
+ export interface PromptOptimizationRetrieveCostsResponse {
614
+ /**
615
+ * Unique identifier for the adaptation run
616
+ */
617
+ optimization_run_id: string;
618
+
619
+ /**
620
+ * Total cost in USD across all LLM requests in this adaptation run
621
+ */
622
+ total_cost: number;
623
+
624
+ /**
625
+ * Detailed usage records for each LLM request made during the adaptation
626
+ */
627
+ usage_records: Array<PromptOptimizationRetrieveCostsResponse.UsageRecord>;
628
+ }
629
+
630
+ export namespace PromptOptimizationRetrieveCostsResponse {
631
+ /**
632
+ * Individual LLM usage record with token counts and cost breakdown.
633
+ *
634
+ * Returned by GET /llm-usage endpoint and included in AdaptationRunCostResponse.
635
+ * Each record represents a single LLM API call with detailed usage metrics.
636
+ */
637
+ export interface UsageRecord {
638
+ /**
639
+ * Unique identifier for this usage record
640
+ */
641
+ id: string;
642
+
643
+ /**
644
+ * Adaptation run ID this usage is associated with
645
+ */
646
+ adaptation_run_id: string;
647
+
648
+ /**
649
+ * Cost of input tokens in USD
650
+ */
651
+ input_cost: number;
652
+
653
+ /**
654
+ * Number of input tokens consumed
655
+ */
656
+ input_tokens: number;
657
+
658
+ /**
659
+ * Model name (e.g., 'gpt-4', 'claude-3-opus-20240229')
660
+ */
661
+ model: string;
662
+
663
+ /**
664
+ * Organization ID associated with the request
665
+ */
666
+ organization_id: string;
667
+
668
+ /**
669
+ * Cost of output tokens in USD
670
+ */
671
+ output_cost: number;
672
+
673
+ /**
674
+ * Number of output tokens generated
675
+ */
676
+ output_tokens: number;
677
+
678
+ /**
679
+ * LLM provider (e.g., 'openai', 'anthropic', 'google')
680
+ */
681
+ provider: string;
682
+
683
+ /**
684
+ * Type of task: 'pre-optimization evaluation', 'optimization', or
685
+ * 'post-optimization evaluation'
686
+ */
687
+ task_type: string;
688
+
689
+ /**
690
+ * Unix timestamp when the request was made
691
+ */
692
+ timestamp: number;
693
+
694
+ /**
695
+ * Total cost (input + output) in USD
696
+ */
697
+ total_cost: number;
698
+
699
+ /**
700
+ * User ID who made the request
701
+ */
702
+ user_id: string;
703
+ }
704
+ }
705
+
575
706
  export interface PromptOptimizationOptimizeParams {
576
707
  /**
577
708
  * List of field names that will be substituted into the template. Must match keys
@@ -586,7 +717,7 @@ export interface PromptOptimizationOptimizeParams {
586
717
  system_prompt: string;
587
718
 
588
719
  /**
589
- * List of models to adapt the prompt for. Maximum count depends on your
720
+ * List of models to optimize the prompt for. Maximum count depends on your
590
721
  * subscription tier (Free: 1, Starter: 3, Startup: 5, Enterprise: 10)
591
722
  */
592
723
  target_models: Array<RequestProvider>;
@@ -646,6 +777,7 @@ export declare namespace PromptOptimization {
646
777
  type PromptOptimizationGetOptimizationResultsResponse as PromptOptimizationGetOptimizationResultsResponse,
647
778
  type PromptOptimizationGetOptimziationStatusResponse as PromptOptimizationGetOptimziationStatusResponse,
648
779
  type PromptOptimizationOptimizeResponse as PromptOptimizationOptimizeResponse,
780
+ type PromptOptimizationRetrieveCostsResponse as PromptOptimizationRetrieveCostsResponse,
649
781
  type PromptOptimizationOptimizeParams as PromptOptimizationOptimizeParams,
650
782
  };
651
783
  }
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '2.2.1'; // x-release-please-version
1
+ export const VERSION = '2.2.3'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.2.1";
1
+ export declare const VERSION = "2.2.3";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.2.1";
1
+ export declare const VERSION = "2.2.3";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '2.2.1'; // x-release-please-version
4
+ exports.VERSION = '2.2.3'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.2.1'; // x-release-please-version
1
+ export const VERSION = '2.2.3'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map