---
title: Billing
source: https://infrared.city/docs/sdk/1.1/api/typescript/billing/
---

# Billing

<a id="billingservice"></a>

## BillingService

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

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

### Constructors

<a id="billingservice-constructor"></a>

#### Constructor

> **new BillingService**(`options`): `BillingService`

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

##### Parameters

| Parameter | Type |
| ------ | ------ |
| `options` | [`ServiceOptions`](client.md#serviceoptions) |

##### Returns

`BillingService`

### Methods

<a id="billingservice-getpublicpricing"></a>

#### getPublicPricing()

> **getPublicPricing**(): `Promise`&lt;[`PublicPricing`](billing.md#publicpricing)&gt;

Fetches the current public price list.

##### Returns

`Promise`&lt;[`PublicPricing`](billing.md#publicpricing)&gt;

The `PublicPricing` document.

##### Throws

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

***

<a id="billingservice-quote"></a>

#### quote()

> **quote**(`analysisType`): `Promise`&lt;[`PriceQuote`](billing.md#pricequote)&gt;

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

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `analysisType` | `string` | The analysis to price. |

##### Returns

`Promise`&lt;[`PriceQuote`](billing.md#pricequote)&gt;

##### Throws

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

***

<a id="estimateworkflowruntokens"></a>

## 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

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `pricing` | [`PublicPricing`](billing.md#publicpricing) | The price list from `BillingService.getPublicPricing`. |
| `workflowId` | `string` | The workflow to price. |
| `areaKm2` | `number` | The 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.

***

<a id="pricequote"></a>

## PriceQuote

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

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

### Extended by

- [`RunEstimate`](billing.md#runestimate)

### Properties

| Property | Modifier | Type | Description |
| ------ | ------ | ------ | ------ |
| <a id="pricequote-pricingsource"></a> `pricingSource` | `readonly` | [`PricingSource`](billing.md#pricingsource) | Where the price came from. |
| <a id="pricequote-pricingversion"></a> `pricingVersion?` | `readonly` | `string` | The version of the price list, when it has one. |
| <a id="pricequote-tokensperjob"></a> `tokensPerJob` | `readonly` | `number` | The tokens charged for one job of the analysis. |

***

<a id="pricingsource"></a>

## 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).

***

<a id="publicpricing"></a>

## 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

| Property | Modifier | Type | Description |
| ------ | ------ | ------ | ------ |
| <a id="publicpricing-actioncatalog"></a> `actionCatalog?` | `readonly` | `Readonly`&lt;`Record`&lt;`string`, \{ `tokens?`: `number`; \}&gt;&gt; | Tokens charged per action, by action name; `run-analysis` is the price of one analysis job. |
| <a id="publicpricing-analysistype"></a> `analysisType?` | `readonly` | `Readonly`&lt;`Record`&lt;`string`, \{ `tokens?`: `number`; \}&gt;&gt; | Tokens charged for one job, by analysis name. |
| <a id="publicpricing-brackets"></a> `brackets?` | `readonly` | `Readonly`&lt;`Record`&lt;`string`, \{ `maxKm2`: `number` \| `null`; \}&gt;&gt; | 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. |
| <a id="publicpricing-effectivefrom"></a> `effectiveFrom?` | `readonly` | `string` | When this price list takes effect. |
| <a id="publicpricing-perjob"></a> `perJob?` | `readonly` | `Readonly`&lt;`Record`&lt;`string`, \{ `tokens?`: `number`; \}&gt;&gt; | Older per-job prices, keyed by model, with an optional `default`. |
| <a id="publicpricing-version"></a> `version?` | `readonly` | `string` \| `number` | The version of this price list. |
| <a id="publicpricing-workflows"></a> `workflows?` | `readonly` | `Readonly`&lt;`Record`&lt;`string`, `Readonly`&lt;`Record`&lt;`string`, `number`&gt;&gt;&gt;&gt; | Tokens charged for a whole workflow run, by workflow id and then by bracket name. |

***

<a id="resolvebracketname"></a>

## 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

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `pricing` | [`PublicPricing`](billing.md#publicpricing) | The price list from `BillingService.getPublicPricing`. |
| `areaKm2` | `number` | The area in square kilometres. |

### Returns

`string` \| `null`

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

***

<a id="resolvetokensperjob"></a>

## 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

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `pricing` | [`PublicPricing`](billing.md#publicpricing) | The price list from `BillingService.getPublicPricing`. |
| `analysisType` | [`AnalysesName`](requests.md#analysesname) | The analysis to price. |

### Returns

`number`

The tokens for one job, from `analysisType.<name>.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.

***

<a id="runestimate"></a>

## RunEstimate

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

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

### Extends

- [`PriceQuote`](billing.md#pricequote)

### Properties

| Property | Modifier | Type | Description | Inherited from |
| ------ | ------ | ------ | ------ | ------ |
| <a id="runestimate-estimatedcosttokens"></a> `estimatedCostTokens` | `readonly` | `number` | - | - |
| <a id="runestimate-estimatedtimes"></a> `estimatedTimeS` | `readonly` | `number` | - | - |
| <a id="runestimate-pricingsource"></a> `pricingSource` | `readonly` | [`PricingSource`](billing.md#pricingsource) | Where the price came from. | [`PriceQuote`](billing.md#pricequote).[`pricingSource`](billing.md#pricequote-pricingsource) |
| <a id="runestimate-pricingversion"></a> `pricingVersion?` | `readonly` | `string` | The version of the price list, when it has one. | [`PriceQuote`](billing.md#pricequote).[`pricingVersion`](billing.md#pricequote-pricingversion) |
| <a id="runestimate-tokensperjob"></a> `tokensPerJob` | `readonly` | `number` | The tokens charged for one job of the analysis. | [`PriceQuote`](billing.md#pricequote).[`tokensPerJob`](billing.md#pricequote-tokensperjob) |

***
