BillingService

Import from @infrared-city/infrared-sdk/billing.

Reads the API's public price list. Available as InfraredClient.billing.

Constructors

Constructor

new BillingService(options): BillingService

Creates the service from the client's base URL, credentials and transport settings.

Parameters
ParameterType
optionsServiceOptions
Returns

BillingService

Methods

getPublicPricing()

getPublicPricing(): Promise<PublicPricing>

Fetches the current public price list.

Returns

Promise<PublicPricing>

The PublicPricing document.

Throws

Error when the API returns an empty response, or the request fails.


quote()

quote(analysisType): Promise<PriceQuote>

The price of one job of an analysis, from the price list. The client keeps the list for 20 minutes; pricingSource says whether the price is "live", "cached" or "stale" (the list could not be fetched again).

Parameters
ParameterTypeDescription
analysisTypestringThe analysis to price.
Returns

Promise<PriceQuote>

Throws

when the list cannot be fetched and the client has none.


estimateWorkflowRunTokens

Import from @infrared-city/infrared-sdk/billing.

estimateWorkflowRunTokens(pricing, workflowId, areaKm2): \{ bracket: string; tokens: number; \} \| null

The tokens a workflow run over an area costs, according to a price list.

Parameters

ParameterTypeDescription
pricingPublicPricingThe price list from BillingService.getPublicPricing.
workflowIdstringThe workflow to price.
areaKm2numberThe area in square kilometres.

Returns

\{ bracket: string; tokens: number; \} \| null

The token cost and the bracket it was priced in, or null when no bracket fits the area or the workflow has no price for that bracket.


PriceQuote

Import from @infrared-city/infrared-sdk.

One job's price for an analysis, with where the price came from.

Extended by

Properties

PropertyModifierTypeDescription
pricingSourcereadonlyPricingSourceWhere the price came from.
pricingVersion?readonlystringThe version of the price list, when it has one.
tokensPerJobreadonlynumberThe tokens charged for one job of the analysis.

PricingSource

Import from @infrared-city/infrared-sdk.

PricingSource = "live" \| "cached" \| "stale"

Where a price came from: "live" (just fetched), "cached" (fetched less than 20 minutes ago) or "stale" (older, because the fetch failed).


PublicPricing

Import from @infrared-city/infrared-sdk/billing.

The price list the API publishes, as returned by BillingService.getPublicPricing. Every section is optional, and any further fields the API adds are kept under their own names.

Indexable

\[extra: string\]: unknown

Properties

PropertyModifierTypeDescription
actionCatalog?readonlyReadonly<Record<string, \{ tokens?: number; \}>>Tokens charged per action, by action name; run-analysis is the price of one analysis job.
analysisType?readonlyReadonly<Record<string, \{ tokens?: number; \}>>Tokens charged for one job, by analysis name.
brackets?readonlyReadonly<Record<string, \{ maxKm2: number \null; \}>>The area brackets used to price workflow runs, by bracket name. maxKm2 is the largest area in square kilometres the bracket covers; null means no upper limit.
effectiveFrom?readonlystringWhen this price list takes effect.
perJob?readonlyReadonly<Record<string, \{ tokens?: number; \}>>Older per-job prices, keyed by model, with an optional default.
version?readonlystring \numberThe version of this price list.
workflows?readonlyReadonly<Record<string, Readonly<Record<string, number>>>>Tokens charged for a whole workflow run, by workflow id and then by bracket name.

resolveBracketName

Import from @infrared-city/infrared-sdk/billing.

resolveBracketName(pricing, areaKm2): string \| null

The name of the area bracket that an area falls in, according to a price list. Brackets are checked from the smallest upper limit up, and a bracket with no upper limit matches any area.

Parameters

ParameterTypeDescription
pricingPublicPricingThe price list from BillingService.getPublicPricing.
areaKm2numberThe area in square kilometres.

Returns

string \| null

The bracket name, or null when the price list has no bracket that fits.


resolveTokensPerJob

Import from @infrared-city/infrared-sdk.

resolveTokensPerJob(pricing, analysisType): number

The tokens one job of an analysis costs, from a price list you already hold.

Parameters

ParameterTypeDescription
pricingPublicPricingThe price list from BillingService.getPublicPricing.
analysisTypeAnalysesNameThe analysis to price.

Returns

number

The tokens for one job, from analysisType..tokens.

Deprecated

Use await client.billing.quote(analysisType), which reads and keeps the price list itself. Removed in 2.0.

Throws

Error when the list has no price for the analysis. The 1.0.x call returned 10 here; the SDK has no built-in price now.


RunEstimate

Import from @infrared-city/infrared-sdk.

The cost and time estimate of a planned run, with the price it used.

Extends

Properties

PropertyModifierTypeDescriptionInherited from
estimatedCostTokensreadonlynumber--
estimatedTimeSreadonlynumber--
pricingSourcereadonlyPricingSourceWhere the price came from.PriceQuote.pricingSource
pricingVersion?readonlystringThe version of the price list, when it has one.PriceQuote.pricingVersion
tokensPerJobreadonlynumberThe tokens charged for one job of the analysis.PriceQuote.tokensPerJob