@@ -109,7 +109,7 @@ model CreditGrantTaxConfig {
109109 /**
110110 * Tax code applied to the invoice line item.
111111 */
112- tax_code ? : Tax .TaxCodeReference ;
112+ tax_code ? : Shared . ResourceReference < Tax .TaxCode > ;
113113}
114114
115115/**
@@ -143,63 +143,10 @@ model CreditGrant {
143143 amount : Shared .Numeric ;
144144
145145 /**
146- * Purchase and payment terms of the grant. Present when a funding workflow applies
147- * (funding_method is not `none`).
146+ * Present when a funding workflow applies (funding_method is not `none`).
148147 */
149148 @ visibility (Lifecycle .Read , Lifecycle .Create )
150- purchase ? : {
151- /**
152- * Currency of the purchase amount.
153- */
154- @ visibility (Lifecycle .Read , Lifecycle .Create )
155- currency : Shared .CurrencyCode ;
156-
157- /**
158- * Cost basis per credit unit used to calculate the purchase amount.
159- *
160- * If `per_unit_cost_basis` is 0.50 and credit amount is $100.00, the total charge
161- * is $50.00. The value must be greater than 0. If the cost basis is 0, use
162- * `funding_method=none` instead.
163- *
164- * Defaults to 1.0.
165- */
166- @ visibility (Lifecycle .Read , Lifecycle .Create )
167- per_unit_cost_basis ? : Shared .Numeric = "1.0" ;
168-
169- /**
170- * The purchase amount. Calculated from `per_unit_cost_basis` and credit `amount`.
171- */
172- @ visibility (Lifecycle .Read )
173- amount : Shared .Numeric ;
174-
175- /**
176- * Controls when credits become available for consumption.
177- *
178- * Defaults to `on_creation`.
179- */
180- @ visibility (Lifecycle .Read , Lifecycle .Create )
181- availability_policy ? : CreditAvailabilityPolicy = CreditAvailabilityPolicy .OnCreation ;
182-
183- // TODO: add this option later
184- // /**
185- // * The initial payment settlement status when creating a grant with
186- // * `external` funding method.
187- // *
188- // * Governs the payment state of the grant on creation. If the external
189- // * system tracks payment status, synchronize their state with this system
190- // * so that revenue recognition works as expected.
191- // *
192- // * Defaults to `settled` (the external payment is assumed to be already settled on creation).
193- // */
194- // @visibility(Lifecycle.Create)
195- // external_payment_initial_settlement_status?: CreditPurchasePaymentSettlementStatus = CreditPurchasePaymentSettlementStatus.Settled;
196-
197- /**
198- * Current payment settlement status.
199- */
200- @ visibility (Lifecycle .Read )
201- settlement_status ? : CreditPurchasePaymentSettlementStatus ;
202- };
149+ purchase ? : CreditGrantPurchase ;
203150
204151 /**
205152 * Tax configuration for the grant.
@@ -213,37 +160,14 @@ model CreditGrant {
213160 tax_config ? : CreditGrantTaxConfig ;
214161
215162 /**
216- * Invoice references for the grant. Available when `funding_method` is `invoice`.
163+ * Available when `funding_method` is `invoice`.
217164 */
218165 @ visibility (Lifecycle .Read )
219- invoice ? : {
220- /**
221- * Identifier of the invoice associated with the grant.
222- */
223- @ visibility (Lifecycle .Read )
224- id ? : Shared .ULID ;
225-
226- /**
227- * Identifier of the invoice line associated with the grant.
228- */
229- @ visibility (Lifecycle .Read )
230- line ? : {
231- id : Shared .ULID ;
232- };
233- };
166+ invoice ? : CreditGrantInvoiceReference ;
234167
235- /**
236- * Filters for the credit grant.
237- */
168+ #suppress "@openmeter/api-spec-aip/doc-decorator" "nested model"
238169 @ visibility (Lifecycle .Read , Lifecycle .Create )
239- filters ? : {
240- /**
241- * Limit the credit grant to specific features. If no features are specified, the
242- * credit grant can be used for any feature.
243- */
244- @ example (#["input_tokens" , "output_tokens" ])
245- features ? : Shared .ResourceKey [];
246- };
170+ filters ? : CreditGrantFilters ;
247171
248172 /**
249173 * Draw-down priority of the grant. Lower values have higher priority.
@@ -289,3 +213,94 @@ model CreditGrant {
289213 @ visibility (Lifecycle .Read )
290214 status : CreditGrantStatus ;
291215}
216+
217+ /**
218+ * Purchase and payment terms of the grant.
219+ */
220+ @ friendlyName ("BillingCreditGrantPurchase" )
221+ model CreditGrantPurchase {
222+ /**
223+ * Currency of the purchase amount.
224+ */
225+ @ visibility (Lifecycle .Read , Lifecycle .Create )
226+ currency : Shared .CurrencyCode ;
227+
228+ /**
229+ * Cost basis per credit unit used to calculate the purchase amount.
230+ *
231+ * If `per_unit_cost_basis` is 0.50 and credit amount is $100.00, the total charge
232+ * is $50.00. The value must be greater than 0. If the cost basis is 0, use
233+ * `funding_method=none` instead.
234+ *
235+ * Defaults to 1.0.
236+ */
237+ @ visibility (Lifecycle .Read , Lifecycle .Create )
238+ per_unit_cost_basis ? : Shared .Numeric = "1.0" ;
239+
240+ /**
241+ * The purchase amount. Calculated from `per_unit_cost_basis` and credit `amount`.
242+ */
243+ @ visibility (Lifecycle .Read )
244+ amount : Shared .Numeric ;
245+
246+ /**
247+ * Controls when credits become available for consumption.
248+ *
249+ * Defaults to `on_creation`.
250+ */
251+ @ visibility (Lifecycle .Read , Lifecycle .Create )
252+ availability_policy ? : CreditAvailabilityPolicy = CreditAvailabilityPolicy .OnCreation ;
253+
254+ // TODO: add this option later
255+ // /**
256+ // * The initial payment settlement status when creating a grant with
257+ // * `external` funding method.
258+ // *
259+ // * Governs the payment state of the grant on creation. If the external
260+ // * system tracks payment status, synchronize their state with this system
261+ // * so that revenue recognition works as expected.
262+ // *
263+ // * Defaults to `settled` (the external payment is assumed to be already settled on creation).
264+ // */
265+ // @visibility(Lifecycle.Create)
266+ // external_payment_initial_settlement_status?: CreditPurchasePaymentSettlementStatus = CreditPurchasePaymentSettlementStatus.Settled;
267+
268+ /**
269+ * Current payment settlement status.
270+ */
271+ @ visibility (Lifecycle .Read )
272+ settlement_status ? : CreditPurchasePaymentSettlementStatus ;
273+ }
274+
275+ /**
276+ * Filters for the credit grant.
277+ */
278+ @ friendlyName ("BillingCreditGrantFilters" )
279+ model CreditGrantFilters {
280+ /**
281+ * Limit the credit grant to specific features. If no features are specified, the
282+ * credit grant can be used for any feature.
283+ */
284+ @ example (#["input_tokens" , "output_tokens" ])
285+ features ? : Shared .ResourceKey [];
286+ }
287+
288+ /**
289+ * Invoice references for the grant.
290+ */
291+ @ friendlyName ("BillingCreditGrantInvoiceReference" )
292+ model CreditGrantInvoiceReference {
293+ /**
294+ * Identifier of the invoice associated with the grant.
295+ */
296+ @ visibility (Lifecycle .Read )
297+ id ? : Shared .ULID ;
298+
299+ /**
300+ * Identifier of the invoice line associated with the grant.
301+ */
302+ @ visibility (Lifecycle .Read )
303+ line ? : {
304+ id : Shared .ULID ;
305+ };
306+ }
0 commit comments