@openmeter/sdk 1.0.0-beta-e1ac49a0f74d → 1.0.0-beta-92db1107743f
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.
- package/dist/cjs/src/client/features.d.cts +3 -0
- package/dist/cjs/src/client/schemas.d.cts +361 -0
- package/dist/cjs/src/zod/index.cjs +156 -17
- package/dist/cjs/src/zod/index.cjs.map +1 -1
- package/dist/cjs/src/zod/index.d.cts +58 -0
- package/dist/src/client/features.d.ts +3 -0
- package/dist/src/client/schemas.d.ts +361 -0
- package/dist/src/zod/index.d.ts +58 -0
- package/dist/src/zod/index.js +139 -0
- package/dist/src/zod/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/src/zod/index.js
CHANGED
|
@@ -5568,6 +5568,12 @@ export const createFeatureBodyKeyMax = 64;
|
|
|
5568
5568
|
export const createFeatureBodyKeyRegExp = /^[a-z0-9]+(?:_[a-z0-9]+)*$/;
|
|
5569
5569
|
export const createFeatureBodyMeterSlugMax = 64;
|
|
5570
5570
|
export const createFeatureBodyMeterSlugRegExp = /^[a-z0-9]+(?:_[a-z0-9]+)*$/;
|
|
5571
|
+
export const createFeatureBodyUnitCostOneOneAmountOneRegExp = /^-?[0-9]+(\.[0-9]+)?$/;
|
|
5572
|
+
export const createFeatureBodyUnitCostOneTwoPricingOneInputPerTokenOneRegExp = /^-?[0-9]+(\.[0-9]+)?$/;
|
|
5573
|
+
export const createFeatureBodyUnitCostOneTwoPricingOneOutputPerTokenOneRegExp = /^-?[0-9]+(\.[0-9]+)?$/;
|
|
5574
|
+
export const createFeatureBodyUnitCostOneTwoPricingOneCacheReadPerTokenOneRegExp = /^-?[0-9]+(\.[0-9]+)?$/;
|
|
5575
|
+
export const createFeatureBodyUnitCostOneTwoPricingOneReasoningPerTokenOneRegExp = /^-?[0-9]+(\.[0-9]+)?$/;
|
|
5576
|
+
export const createFeatureBodyUnitCostOneTwoPricingOneCacheWritePerTokenOneRegExp = /^-?[0-9]+(\.[0-9]+)?$/;
|
|
5571
5577
|
export const CreateFeatureBody = zod
|
|
5572
5578
|
.object({
|
|
5573
5579
|
advancedMeterGroupByFilters: zod
|
|
@@ -5655,6 +5661,85 @@ export const CreateFeatureBody = zod
|
|
|
5655
5661
|
.optional()
|
|
5656
5662
|
.describe('A key is a unique string that is used to identify a resource.'),
|
|
5657
5663
|
name: zod.coerce.string(),
|
|
5664
|
+
unitCost: zod
|
|
5665
|
+
.union([
|
|
5666
|
+
zod
|
|
5667
|
+
.object({
|
|
5668
|
+
amount: zod.coerce
|
|
5669
|
+
.string()
|
|
5670
|
+
.regex(createFeatureBodyUnitCostOneOneAmountOneRegExp)
|
|
5671
|
+
.describe('Numeric represents an arbitrary precision number.')
|
|
5672
|
+
.describe('Fixed per-unit cost amount in USD.'),
|
|
5673
|
+
type: zod.enum(['manual']),
|
|
5674
|
+
})
|
|
5675
|
+
.describe('A fixed per-unit cost amount.'),
|
|
5676
|
+
zod
|
|
5677
|
+
.object({
|
|
5678
|
+
model: zod.coerce
|
|
5679
|
+
.string()
|
|
5680
|
+
.optional()
|
|
5681
|
+
.describe('Static model ID value (e.g., "gpt-4", "claude-3-5-sonnet").\nUse this when the feature tracks a single model.\nMutually exclusive with `modelProperty`.'),
|
|
5682
|
+
modelProperty: zod.coerce
|
|
5683
|
+
.string()
|
|
5684
|
+
.optional()
|
|
5685
|
+
.describe('Meter group-by property that holds the model ID.\nUse this when the meter has a group-by dimension for model.\nMutually exclusive with `model`.'),
|
|
5686
|
+
pricing: zod
|
|
5687
|
+
.object({
|
|
5688
|
+
cacheReadPerToken: zod.coerce
|
|
5689
|
+
.string()
|
|
5690
|
+
.regex(createFeatureBodyUnitCostOneTwoPricingOneCacheReadPerTokenOneRegExp)
|
|
5691
|
+
.describe('Numeric represents an arbitrary precision number.')
|
|
5692
|
+
.optional()
|
|
5693
|
+
.describe('Cost per cache read token in USD.'),
|
|
5694
|
+
cacheWritePerToken: zod.coerce
|
|
5695
|
+
.string()
|
|
5696
|
+
.regex(createFeatureBodyUnitCostOneTwoPricingOneCacheWritePerTokenOneRegExp)
|
|
5697
|
+
.describe('Numeric represents an arbitrary precision number.')
|
|
5698
|
+
.optional()
|
|
5699
|
+
.describe('Cost per cache write token in USD.'),
|
|
5700
|
+
inputPerToken: zod.coerce
|
|
5701
|
+
.string()
|
|
5702
|
+
.regex(createFeatureBodyUnitCostOneTwoPricingOneInputPerTokenOneRegExp)
|
|
5703
|
+
.describe('Numeric represents an arbitrary precision number.')
|
|
5704
|
+
.describe('Cost per input token in USD.'),
|
|
5705
|
+
outputPerToken: zod.coerce
|
|
5706
|
+
.string()
|
|
5707
|
+
.regex(createFeatureBodyUnitCostOneTwoPricingOneOutputPerTokenOneRegExp)
|
|
5708
|
+
.describe('Numeric represents an arbitrary precision number.')
|
|
5709
|
+
.describe('Cost per output token in USD.'),
|
|
5710
|
+
reasoningPerToken: zod.coerce
|
|
5711
|
+
.string()
|
|
5712
|
+
.regex(createFeatureBodyUnitCostOneTwoPricingOneReasoningPerTokenOneRegExp)
|
|
5713
|
+
.describe('Numeric represents an arbitrary precision number.')
|
|
5714
|
+
.optional()
|
|
5715
|
+
.describe('Cost per reasoning token in USD.'),
|
|
5716
|
+
})
|
|
5717
|
+
.describe('Resolved per-token pricing from the LLM cost database.')
|
|
5718
|
+
.optional()
|
|
5719
|
+
.describe("Resolved per-token pricing from the LLM cost database.\nOnly populated in responses when the feature's meter group-by filters\nspecify exact provider and model values."),
|
|
5720
|
+
provider: zod.coerce
|
|
5721
|
+
.string()
|
|
5722
|
+
.optional()
|
|
5723
|
+
.describe('Static LLM provider value (e.g., "openai", "anthropic").\nUse this when the feature tracks a single provider.\nMutually exclusive with `providerProperty`.'),
|
|
5724
|
+
providerProperty: zod.coerce
|
|
5725
|
+
.string()
|
|
5726
|
+
.optional()
|
|
5727
|
+
.describe('Meter group-by property that holds the LLM provider.\nUse this when the meter has a group-by dimension for provider.\nMutually exclusive with `provider`.'),
|
|
5728
|
+
tokenType: zod.coerce
|
|
5729
|
+
.string()
|
|
5730
|
+
.optional()
|
|
5731
|
+
.describe('Static token type value.\nUse this when the feature tracks a single token type (e.g., only input tokens).\nExpected values: input, output, cache_read, reasoning, cache_write.\nMutually exclusive with `tokenTypeProperty`.'),
|
|
5732
|
+
tokenTypeProperty: zod.coerce
|
|
5733
|
+
.string()
|
|
5734
|
+
.optional()
|
|
5735
|
+
.describe('Meter group-by property that holds the token type.\nUse this when the meter has a group-by dimension for token type.\nMutually exclusive with `tokenType`.'),
|
|
5736
|
+
type: zod.enum(['llm']),
|
|
5737
|
+
})
|
|
5738
|
+
.describe('LLM cost lookup configuration.\nMaps meter group-by dimensions to LLM cost database fields.'),
|
|
5739
|
+
])
|
|
5740
|
+
.describe('Per-unit cost configuration for a feature.\nEither a fixed manual amount or a dynamic LLM cost lookup.')
|
|
5741
|
+
.optional()
|
|
5742
|
+
.describe('Optional per-unit cost configuration.\nUse "manual" for a fixed per-unit cost, or "llm" to look up cost\nfrom the LLM cost database based on meter group-by properties.'),
|
|
5658
5743
|
})
|
|
5659
5744
|
.describe('Represents a feature that can be enabled or disabled for a plan.\nUsed both for product catalog and entitlements.');
|
|
5660
5745
|
/**
|
|
@@ -5674,6 +5759,60 @@ This means, if you want to create a new feature with the same key, and then crea
|
|
|
5674
5759
|
export const DeleteFeatureParams = zod.object({
|
|
5675
5760
|
featureId: zod.coerce.string(),
|
|
5676
5761
|
});
|
|
5762
|
+
/**
|
|
5763
|
+
* Query the cost of a feature based on its unit cost configuration and underlying meter usage.
|
|
5764
|
+
For features with manual unit cost, the cost is usage × fixed amount.
|
|
5765
|
+
For features with LLM unit cost, the cost is resolved per row from the LLM cost database.
|
|
5766
|
+
The feature must have a meter and unit cost configured.
|
|
5767
|
+
* @summary Query feature cost
|
|
5768
|
+
*/
|
|
5769
|
+
export const QueryFeatureCostParams = zod.object({
|
|
5770
|
+
featureId: zod.coerce.string(),
|
|
5771
|
+
});
|
|
5772
|
+
export const queryFeatureCostQueryClientIdMax = 36;
|
|
5773
|
+
export const queryFeatureCostQueryWindowTimeZoneDefault = 'UTC';
|
|
5774
|
+
export const queryFeatureCostQueryFilterCustomerIdMax = 100;
|
|
5775
|
+
export const QueryFeatureCostQueryParams = zod.object({
|
|
5776
|
+
clientId: zod.coerce
|
|
5777
|
+
.string()
|
|
5778
|
+
.min(1)
|
|
5779
|
+
.max(queryFeatureCostQueryClientIdMax)
|
|
5780
|
+
.optional()
|
|
5781
|
+
.describe('Client ID\nUseful to track progress of a query.'),
|
|
5782
|
+
filterCustomerId: zod
|
|
5783
|
+
.array(zod.coerce.string())
|
|
5784
|
+
.max(queryFeatureCostQueryFilterCustomerIdMax)
|
|
5785
|
+
.optional()
|
|
5786
|
+
.describe('Filtering by multiple customers.\n\nFor example: ?filterCustomerId=customer-1&filterCustomerId=customer-2'),
|
|
5787
|
+
filterGroupBy: zod
|
|
5788
|
+
.record(zod.string(), zod.coerce.string())
|
|
5789
|
+
.optional()
|
|
5790
|
+
.describe('Simple filter for group bys with exact match.\n\nFor example: ?filterGroupBy[vendor]=openai&filterGroupBy[model]=gpt-4-turbo\n\n⚠️ __Deprecated__: Use `advancedMeterGroupByFilters` instead'),
|
|
5791
|
+
from: zod.coerce
|
|
5792
|
+
.date()
|
|
5793
|
+
.optional()
|
|
5794
|
+
.describe('Start date-time in RFC 3339 format.\n\nInclusive.\n\nFor example: ?from=2025-01-01T00%3A00%3A00.000Z'),
|
|
5795
|
+
groupBy: zod
|
|
5796
|
+
.array(zod.coerce.string())
|
|
5797
|
+
.optional()
|
|
5798
|
+
.describe('If not specified a single aggregate will be returned for each subject and time window.\n`subject` is a reserved group by value.\n\nFor example: ?groupBy=subject&groupBy=model'),
|
|
5799
|
+
subject: zod
|
|
5800
|
+
.array(zod.coerce.string())
|
|
5801
|
+
.optional()
|
|
5802
|
+
.describe('Filtering by multiple subjects.\n\nFor example: ?subject=subject-1&subject=subject-2'),
|
|
5803
|
+
to: zod.coerce
|
|
5804
|
+
.date()
|
|
5805
|
+
.optional()
|
|
5806
|
+
.describe('End date-time in RFC 3339 format.\n\nInclusive.\n\nFor example: ?to=2025-02-01T00%3A00%3A00.000Z'),
|
|
5807
|
+
windowSize: zod
|
|
5808
|
+
.enum(['MINUTE', 'HOUR', 'DAY', 'MONTH'])
|
|
5809
|
+
.optional()
|
|
5810
|
+
.describe('If not specified, a single usage aggregate will be returned for the entirety of the specified period for each subject and group.\n\nFor example: ?windowSize=DAY'),
|
|
5811
|
+
windowTimeZone: zod.coerce
|
|
5812
|
+
.string()
|
|
5813
|
+
.default(queryFeatureCostQueryWindowTimeZoneDefault)
|
|
5814
|
+
.describe('The value is the name of the time zone as defined in the IANA Time Zone Database (http://www.iana.org/time-zones).\nIf not specified, the UTC timezone will be used.\n\nFor example: ?windowTimeZone=UTC'),
|
|
5815
|
+
});
|
|
5677
5816
|
/**
|
|
5678
5817
|
* List all grants for all the subjects and entitlements. This endpoint is intended for administrative purposes only.
|
|
5679
5818
|
To fetch the grants of a specific entitlement please use the /api/v1/subjects/{subjectKeyOrID}/entitlements/{entitlementOrFeatureID}/grants endpoint.
|