@leaflow/sdk 0.184.0 → 0.186.0

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.
@@ -647,9 +647,16 @@ export interface RequestResource {
647
647
  * @nullable
648
648
  */
649
649
  api_key_id: string | null;
650
- /** The portion served from the upstream prefix cache, which costs an order of magnitude less than ordinary input */
651
- cache_read_tokens: number;
652
- cache_write_tokens: number;
650
+ /**
651
+ * The portion served from the upstream prefix cache, which costs an order of magnitude less than ordinary input. Null on a request billed on a non-token meter.
652
+ * @nullable
653
+ */
654
+ cache_read_tokens: number | null;
655
+ /**
656
+ * Tokens written to the provider's prompt cache. Null on a request billed on a non-token meter.
657
+ * @nullable
658
+ */
659
+ cache_write_tokens: number | null;
653
660
  /** The error code on failure. Empty on success */
654
661
  error_code: string;
655
662
  /** @nullable */
@@ -658,13 +665,25 @@ export interface RequestResource {
658
665
  first_token_at: string | null;
659
666
  /** A typed request id such as `req_01j...`. Legacy rows may still be returned as a bare UUID. */
660
667
  id: string;
661
- input_tokens: number;
668
+ /**
669
+ * Input tokens the provider billed for. Null on a request billed on a non-token meter, such as image generation, video generation or speech.
670
+ * @nullable
671
+ */
672
+ input_tokens: number | null;
662
673
  /** The model named in the request */
663
674
  model_id: string;
664
675
  /** The request operation, such as video_create or video_retrieve. Absent for historical requests where it was not recorded. */
665
676
  operation?: string;
666
- output_tokens: number;
667
- reasoning_tokens: number;
677
+ /**
678
+ * Output tokens the provider billed for. Null on a request billed on a non-token meter, such as image generation, video generation or speech.
679
+ * @nullable
680
+ */
681
+ output_tokens: number | null;
682
+ /**
683
+ * Reasoning tokens the provider reports separately. Null on a request billed on a non-token meter.
684
+ * @nullable
685
+ */
686
+ reasoning_tokens: number | null;
668
687
  retries: number;
669
688
  /**
670
689
  * Who made the request. `api_key` means one of the project's API keys and `project_token` a project access token on the OpenAI-compatible endpoints; any other value names the Leaflow service that made it on the project's behalf, such as `assistant`, and more services may appear. Null for requests recorded before sources were tracked
@@ -693,11 +712,31 @@ export interface CursorPageRequestResource {
693
712
  }
694
713
  export interface APIKeyUsageResource {
695
714
  api_key_id: string;
696
- cache_read_tokens: number;
697
- cache_write_tokens: number;
698
- input_tokens: number;
699
- output_tokens: number;
700
- reasoning_tokens: number;
715
+ /**
716
+ * Null when this range has no token usage.
717
+ * @nullable
718
+ */
719
+ cache_read_tokens: number | null;
720
+ /**
721
+ * Null when this range has no token usage.
722
+ * @nullable
723
+ */
724
+ cache_write_tokens: number | null;
725
+ /**
726
+ * Null when this range has no token usage.
727
+ * @nullable
728
+ */
729
+ input_tokens: number | null;
730
+ /**
731
+ * Null when this range has no token usage.
732
+ * @nullable
733
+ */
734
+ output_tokens: number | null;
735
+ /**
736
+ * Null when this range has no token usage.
737
+ * @nullable
738
+ */
739
+ reasoning_tokens: number | null;
701
740
  /** Media quantities and their rate dimensions. Null when this range has no media usage. */
702
741
  media?: MediaUsage | null;
703
742
  requests: number;
@@ -706,12 +745,32 @@ export interface APIKeyUsageListResponseBody {
706
745
  items: APIKeyUsageResource[];
707
746
  }
708
747
  export interface ModelUsageResource {
709
- cache_read_tokens: number;
710
- cache_write_tokens: number;
711
- input_tokens: number;
748
+ /**
749
+ * Null when this range has no token usage.
750
+ * @nullable
751
+ */
752
+ cache_read_tokens: number | null;
753
+ /**
754
+ * Null when this range has no token usage.
755
+ * @nullable
756
+ */
757
+ cache_write_tokens: number | null;
758
+ /**
759
+ * Null when this range has no token usage.
760
+ * @nullable
761
+ */
762
+ input_tokens: number | null;
712
763
  model_id: string;
713
- output_tokens: number;
714
- reasoning_tokens: number;
764
+ /**
765
+ * Null when this range has no token usage.
766
+ * @nullable
767
+ */
768
+ output_tokens: number | null;
769
+ /**
770
+ * Null when this range has no token usage.
771
+ * @nullable
772
+ */
773
+ reasoning_tokens: number | null;
715
774
  /** Media quantities and their rate dimensions. Null when this range has no media usage. */
716
775
  media?: MediaUsage | null;
717
776
  requests: number;
@@ -720,23 +779,63 @@ export interface ModelUsageListResponseBody {
720
779
  items: ModelUsageResource[];
721
780
  }
722
781
  export interface TotalsResource {
723
- cache_read_tokens: number;
724
- cache_write_tokens: number;
725
- input_tokens: number;
726
- output_tokens: number;
727
- reasoning_tokens: number;
782
+ /**
783
+ * Null when this range has no token usage.
784
+ * @nullable
785
+ */
786
+ cache_read_tokens: number | null;
787
+ /**
788
+ * Null when this range has no token usage.
789
+ * @nullable
790
+ */
791
+ cache_write_tokens: number | null;
792
+ /**
793
+ * Null when this range has no token usage.
794
+ * @nullable
795
+ */
796
+ input_tokens: number | null;
797
+ /**
798
+ * Null when this range has no token usage.
799
+ * @nullable
800
+ */
801
+ output_tokens: number | null;
802
+ /**
803
+ * Null when this range has no token usage.
804
+ * @nullable
805
+ */
806
+ reasoning_tokens: number | null;
728
807
  /** Media quantities and their rate dimensions. Null when this range has no media usage. */
729
808
  media?: MediaUsage | null;
730
809
  requests: number;
731
810
  }
732
811
  export interface UsageBucketResource {
733
- cache_read_tokens: number;
734
- cache_write_tokens: number;
812
+ /**
813
+ * Null when this range has no token usage.
814
+ * @nullable
815
+ */
816
+ cache_read_tokens: number | null;
817
+ /**
818
+ * Null when this range has no token usage.
819
+ * @nullable
820
+ */
821
+ cache_write_tokens: number | null;
735
822
  /** Start of the bucket, inclusive */
736
823
  from: string;
737
- input_tokens: number;
738
- output_tokens: number;
739
- reasoning_tokens: number;
824
+ /**
825
+ * Null when this range has no token usage.
826
+ * @nullable
827
+ */
828
+ input_tokens: number | null;
829
+ /**
830
+ * Null when this range has no token usage.
831
+ * @nullable
832
+ */
833
+ output_tokens: number | null;
834
+ /**
835
+ * Null when this range has no token usage.
836
+ * @nullable
837
+ */
838
+ reasoning_tokens: number | null;
740
839
  /** Media quantities and their rate dimensions. Null when this range has no media usage. */
741
840
  media?: MediaUsage | null;
742
841
  requests: number;
@@ -42,11 +42,11 @@ import * as zod from "zod";
42
42
  export declare const APIKeyUsageListResponseBody: zod.ZodObject<{
43
43
  items: zod.ZodArray<zod.ZodObject<{
44
44
  api_key_id: zod.ZodUUID;
45
- cache_read_tokens: zod.ZodInt;
46
- cache_write_tokens: zod.ZodInt;
47
- input_tokens: zod.ZodInt;
48
- output_tokens: zod.ZodInt;
49
- reasoning_tokens: zod.ZodInt;
45
+ cache_read_tokens: zod.ZodNullable<zod.ZodInt>;
46
+ cache_write_tokens: zod.ZodNullable<zod.ZodInt>;
47
+ input_tokens: zod.ZodNullable<zod.ZodInt>;
48
+ output_tokens: zod.ZodNullable<zod.ZodInt>;
49
+ reasoning_tokens: zod.ZodNullable<zod.ZodInt>;
50
50
  media: zod.ZodOptional<zod.ZodUnion<readonly [zod.ZodObject<{
51
51
  images: zod.ZodInt;
52
52
  audio_characters: zod.ZodInt;
@@ -41,11 +41,11 @@
41
41
  import * as zod from "zod";
42
42
  export declare const APIKeyUsageResource: zod.ZodObject<{
43
43
  api_key_id: zod.ZodUUID;
44
- cache_read_tokens: zod.ZodInt;
45
- cache_write_tokens: zod.ZodInt;
46
- input_tokens: zod.ZodInt;
47
- output_tokens: zod.ZodInt;
48
- reasoning_tokens: zod.ZodInt;
44
+ cache_read_tokens: zod.ZodNullable<zod.ZodInt>;
45
+ cache_write_tokens: zod.ZodNullable<zod.ZodInt>;
46
+ input_tokens: zod.ZodNullable<zod.ZodInt>;
47
+ output_tokens: zod.ZodNullable<zod.ZodInt>;
48
+ reasoning_tokens: zod.ZodNullable<zod.ZodInt>;
49
49
  media: zod.ZodOptional<zod.ZodUnion<readonly [zod.ZodObject<{
50
50
  images: zod.ZodInt;
51
51
  audio_characters: zod.ZodInt;
@@ -42,11 +42,11 @@ import * as zod from "zod";
42
42
  import { MediaUsage } from "./mediaUsage.zod.js";
43
43
  export const APIKeyUsageResource = zod.strictObject({
44
44
  api_key_id: zod.uuid(),
45
- cache_read_tokens: zod.int(),
46
- cache_write_tokens: zod.int(),
47
- input_tokens: zod.int(),
48
- output_tokens: zod.int(),
49
- reasoning_tokens: zod.int(),
45
+ cache_read_tokens: zod.int().nullable().describe("Null when this range has no token usage."),
46
+ cache_write_tokens: zod.int().nullable().describe("Null when this range has no token usage."),
47
+ input_tokens: zod.int().nullable().describe("Null when this range has no token usage."),
48
+ output_tokens: zod.int().nullable().describe("Null when this range has no token usage."),
49
+ reasoning_tokens: zod.int().nullable().describe("Null when this range has no token usage."),
50
50
  media: zod
51
51
  .union([MediaUsage, zod.null()])
52
52
  .optional()
@@ -42,17 +42,17 @@ import * as zod from "zod";
42
42
  export declare const CursorPageRequestResource: zod.ZodObject<{
43
43
  items: zod.ZodArray<zod.ZodObject<{
44
44
  api_key_id: zod.ZodNullable<zod.ZodUUID>;
45
- cache_read_tokens: zod.ZodInt;
46
- cache_write_tokens: zod.ZodInt;
45
+ cache_read_tokens: zod.ZodNullable<zod.ZodInt>;
46
+ cache_write_tokens: zod.ZodNullable<zod.ZodInt>;
47
47
  error_code: zod.ZodString;
48
48
  finished_at: zod.ZodNullable<zod.z.ZodISODateTime>;
49
49
  first_token_at: zod.ZodNullable<zod.z.ZodISODateTime>;
50
50
  id: zod.ZodString;
51
- input_tokens: zod.ZodInt;
51
+ input_tokens: zod.ZodNullable<zod.ZodInt>;
52
52
  model_id: zod.ZodString;
53
53
  operation: zod.ZodOptional<zod.ZodString>;
54
- output_tokens: zod.ZodInt;
55
- reasoning_tokens: zod.ZodInt;
54
+ output_tokens: zod.ZodNullable<zod.ZodInt>;
55
+ reasoning_tokens: zod.ZodNullable<zod.ZodInt>;
56
56
  retries: zod.ZodInt;
57
57
  source: zod.ZodNullable<zod.ZodString>;
58
58
  started_at: zod.z.ZodISODateTime;
@@ -41,12 +41,12 @@
41
41
  import * as zod from "zod";
42
42
  export declare const ModelUsageListResponseBody: zod.ZodObject<{
43
43
  items: zod.ZodArray<zod.ZodObject<{
44
- cache_read_tokens: zod.ZodInt;
45
- cache_write_tokens: zod.ZodInt;
46
- input_tokens: zod.ZodInt;
44
+ cache_read_tokens: zod.ZodNullable<zod.ZodInt>;
45
+ cache_write_tokens: zod.ZodNullable<zod.ZodInt>;
46
+ input_tokens: zod.ZodNullable<zod.ZodInt>;
47
47
  model_id: zod.ZodString;
48
- output_tokens: zod.ZodInt;
49
- reasoning_tokens: zod.ZodInt;
48
+ output_tokens: zod.ZodNullable<zod.ZodInt>;
49
+ reasoning_tokens: zod.ZodNullable<zod.ZodInt>;
50
50
  media: zod.ZodOptional<zod.ZodUnion<readonly [zod.ZodObject<{
51
51
  images: zod.ZodInt;
52
52
  audio_characters: zod.ZodInt;
@@ -40,12 +40,12 @@
40
40
  */
41
41
  import * as zod from "zod";
42
42
  export declare const ModelUsageResource: zod.ZodObject<{
43
- cache_read_tokens: zod.ZodInt;
44
- cache_write_tokens: zod.ZodInt;
45
- input_tokens: zod.ZodInt;
43
+ cache_read_tokens: zod.ZodNullable<zod.ZodInt>;
44
+ cache_write_tokens: zod.ZodNullable<zod.ZodInt>;
45
+ input_tokens: zod.ZodNullable<zod.ZodInt>;
46
46
  model_id: zod.ZodString;
47
- output_tokens: zod.ZodInt;
48
- reasoning_tokens: zod.ZodInt;
47
+ output_tokens: zod.ZodNullable<zod.ZodInt>;
48
+ reasoning_tokens: zod.ZodNullable<zod.ZodInt>;
49
49
  media: zod.ZodOptional<zod.ZodUnion<readonly [zod.ZodObject<{
50
50
  images: zod.ZodInt;
51
51
  audio_characters: zod.ZodInt;
@@ -41,12 +41,12 @@
41
41
  import * as zod from "zod";
42
42
  import { MediaUsage } from "./mediaUsage.zod.js";
43
43
  export const ModelUsageResource = zod.strictObject({
44
- cache_read_tokens: zod.int(),
45
- cache_write_tokens: zod.int(),
46
- input_tokens: zod.int(),
44
+ cache_read_tokens: zod.int().nullable().describe("Null when this range has no token usage."),
45
+ cache_write_tokens: zod.int().nullable().describe("Null when this range has no token usage."),
46
+ input_tokens: zod.int().nullable().describe("Null when this range has no token usage."),
47
47
  model_id: zod.string(),
48
- output_tokens: zod.int(),
49
- reasoning_tokens: zod.int(),
48
+ output_tokens: zod.int().nullable().describe("Null when this range has no token usage."),
49
+ reasoning_tokens: zod.int().nullable().describe("Null when this range has no token usage."),
50
50
  media: zod
51
51
  .union([MediaUsage, zod.null()])
52
52
  .optional()
@@ -42,17 +42,17 @@ import * as zod from "zod";
42
42
  export declare const requestResourceSourceMax = 64;
43
43
  export declare const RequestResource: zod.ZodObject<{
44
44
  api_key_id: zod.ZodNullable<zod.ZodUUID>;
45
- cache_read_tokens: zod.ZodInt;
46
- cache_write_tokens: zod.ZodInt;
45
+ cache_read_tokens: zod.ZodNullable<zod.ZodInt>;
46
+ cache_write_tokens: zod.ZodNullable<zod.ZodInt>;
47
47
  error_code: zod.ZodString;
48
48
  finished_at: zod.ZodNullable<zod.z.ZodISODateTime>;
49
49
  first_token_at: zod.ZodNullable<zod.z.ZodISODateTime>;
50
50
  id: zod.ZodString;
51
- input_tokens: zod.ZodInt;
51
+ input_tokens: zod.ZodNullable<zod.ZodInt>;
52
52
  model_id: zod.ZodString;
53
53
  operation: zod.ZodOptional<zod.ZodString>;
54
- output_tokens: zod.ZodInt;
55
- reasoning_tokens: zod.ZodInt;
54
+ output_tokens: zod.ZodNullable<zod.ZodInt>;
55
+ reasoning_tokens: zod.ZodNullable<zod.ZodInt>;
56
56
  retries: zod.ZodInt;
57
57
  source: zod.ZodNullable<zod.ZodString>;
58
58
  started_at: zod.z.ZodISODateTime;
@@ -49,22 +49,35 @@ export const RequestResource = zod.strictObject({
49
49
  .describe("Null for a request that did not come through one of the project's API keys."),
50
50
  cache_read_tokens: zod
51
51
  .int()
52
- .describe("The portion served from the upstream prefix cache, which costs an order of magnitude less than ordinary input"),
53
- cache_write_tokens: zod.int(),
52
+ .nullable()
53
+ .describe("The portion served from the upstream prefix cache, which costs an order of magnitude less than ordinary input. Null on a request billed on a non-token meter."),
54
+ cache_write_tokens: zod
55
+ .int()
56
+ .nullable()
57
+ .describe("Tokens written to the provider's prompt cache. Null on a request billed on a non-token meter."),
54
58
  error_code: zod.string().describe("The error code on failure. Empty on success"),
55
59
  finished_at: zod.iso.datetime({ offset: true }).nullable(),
56
60
  first_token_at: zod.iso.datetime({ offset: true }).nullable(),
57
61
  id: zod
58
62
  .string()
59
63
  .describe("A typed request id such as `req_01j...`. Legacy rows may still be returned as a bare UUID."),
60
- input_tokens: zod.int(),
64
+ input_tokens: zod
65
+ .int()
66
+ .nullable()
67
+ .describe("Input tokens the provider billed for. Null on a request billed on a non-token meter, such as image generation, video generation or speech."),
61
68
  model_id: zod.string().describe("The model named in the request"),
62
69
  operation: zod
63
70
  .string()
64
71
  .optional()
65
72
  .describe("The request operation, such as video_create or video_retrieve. Absent for historical requests where it was not recorded."),
66
- output_tokens: zod.int(),
67
- reasoning_tokens: zod.int(),
73
+ output_tokens: zod
74
+ .int()
75
+ .nullable()
76
+ .describe("Output tokens the provider billed for. Null on a request billed on a non-token meter, such as image generation, video generation or speech."),
77
+ reasoning_tokens: zod
78
+ .int()
79
+ .nullable()
80
+ .describe("Reasoning tokens the provider reports separately. Null on a request billed on a non-token meter."),
68
81
  retries: zod.int(),
69
82
  source: zod
70
83
  .string()
@@ -40,11 +40,11 @@
40
40
  */
41
41
  import * as zod from "zod";
42
42
  export declare const TotalsResource: zod.ZodObject<{
43
- cache_read_tokens: zod.ZodInt;
44
- cache_write_tokens: zod.ZodInt;
45
- input_tokens: zod.ZodInt;
46
- output_tokens: zod.ZodInt;
47
- reasoning_tokens: zod.ZodInt;
43
+ cache_read_tokens: zod.ZodNullable<zod.ZodInt>;
44
+ cache_write_tokens: zod.ZodNullable<zod.ZodInt>;
45
+ input_tokens: zod.ZodNullable<zod.ZodInt>;
46
+ output_tokens: zod.ZodNullable<zod.ZodInt>;
47
+ reasoning_tokens: zod.ZodNullable<zod.ZodInt>;
48
48
  media: zod.ZodOptional<zod.ZodUnion<readonly [zod.ZodObject<{
49
49
  images: zod.ZodInt;
50
50
  audio_characters: zod.ZodInt;
@@ -41,11 +41,11 @@
41
41
  import * as zod from "zod";
42
42
  import { MediaUsage } from "./mediaUsage.zod.js";
43
43
  export const TotalsResource = zod.strictObject({
44
- cache_read_tokens: zod.int(),
45
- cache_write_tokens: zod.int(),
46
- input_tokens: zod.int(),
47
- output_tokens: zod.int(),
48
- reasoning_tokens: zod.int(),
44
+ cache_read_tokens: zod.int().nullable().describe("Null when this range has no token usage."),
45
+ cache_write_tokens: zod.int().nullable().describe("Null when this range has no token usage."),
46
+ input_tokens: zod.int().nullable().describe("Null when this range has no token usage."),
47
+ output_tokens: zod.int().nullable().describe("Null when this range has no token usage."),
48
+ reasoning_tokens: zod.int().nullable().describe("Null when this range has no token usage."),
49
49
  media: zod
50
50
  .union([MediaUsage, zod.null()])
51
51
  .optional()
@@ -40,12 +40,12 @@
40
40
  */
41
41
  import * as zod from "zod";
42
42
  export declare const UsageBucketResource: zod.ZodObject<{
43
- cache_read_tokens: zod.ZodInt;
44
- cache_write_tokens: zod.ZodInt;
43
+ cache_read_tokens: zod.ZodNullable<zod.ZodInt>;
44
+ cache_write_tokens: zod.ZodNullable<zod.ZodInt>;
45
45
  from: zod.z.ZodISODateTime;
46
- input_tokens: zod.ZodInt;
47
- output_tokens: zod.ZodInt;
48
- reasoning_tokens: zod.ZodInt;
46
+ input_tokens: zod.ZodNullable<zod.ZodInt>;
47
+ output_tokens: zod.ZodNullable<zod.ZodInt>;
48
+ reasoning_tokens: zod.ZodNullable<zod.ZodInt>;
49
49
  media: zod.ZodOptional<zod.ZodUnion<readonly [zod.ZodObject<{
50
50
  images: zod.ZodInt;
51
51
  audio_characters: zod.ZodInt;
@@ -41,12 +41,12 @@
41
41
  import * as zod from "zod";
42
42
  import { MediaUsage } from "./mediaUsage.zod.js";
43
43
  export const UsageBucketResource = zod.strictObject({
44
- cache_read_tokens: zod.int(),
45
- cache_write_tokens: zod.int(),
44
+ cache_read_tokens: zod.int().nullable().describe("Null when this range has no token usage."),
45
+ cache_write_tokens: zod.int().nullable().describe("Null when this range has no token usage."),
46
46
  from: zod.iso.datetime({ offset: true }).describe("Start of the bucket, inclusive"),
47
- input_tokens: zod.int(),
48
- output_tokens: zod.int(),
49
- reasoning_tokens: zod.int(),
47
+ input_tokens: zod.int().nullable().describe("Null when this range has no token usage."),
48
+ output_tokens: zod.int().nullable().describe("Null when this range has no token usage."),
49
+ reasoning_tokens: zod.int().nullable().describe("Null when this range has no token usage."),
50
50
  media: zod
51
51
  .union([MediaUsage, zod.null()])
52
52
  .optional()
@@ -41,12 +41,12 @@
41
41
  import * as zod from "zod";
42
42
  export declare const UsageTimelineResponseBody: zod.ZodObject<{
43
43
  items: zod.ZodArray<zod.ZodObject<{
44
- cache_read_tokens: zod.ZodInt;
45
- cache_write_tokens: zod.ZodInt;
44
+ cache_read_tokens: zod.ZodNullable<zod.ZodInt>;
45
+ cache_write_tokens: zod.ZodNullable<zod.ZodInt>;
46
46
  from: zod.z.ZodISODateTime;
47
- input_tokens: zod.ZodInt;
48
- output_tokens: zod.ZodInt;
49
- reasoning_tokens: zod.ZodInt;
47
+ input_tokens: zod.ZodNullable<zod.ZodInt>;
48
+ output_tokens: zod.ZodNullable<zod.ZodInt>;
49
+ reasoning_tokens: zod.ZodNullable<zod.ZodInt>;
50
50
  media: zod.ZodOptional<zod.ZodUnion<readonly [zod.ZodObject<{
51
51
  images: zod.ZodInt;
52
52
  audio_characters: zod.ZodInt;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leaflow/sdk",
3
- "version": "0.184.0",
3
+ "version": "0.186.0",
4
4
  "description": "Leaflow 平台 API 的 TypeScript SDK",
5
5
  "license": "MIT",
6
6
  "repository": {