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

# Billing

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

## BillingService

Import from `@infrared-city/infrared-sdk-ts/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="default_tokens_per_job"></a>

## DEFAULT_TOKENS_PER_JOB

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

> `const` **DEFAULT\_TOKENS\_PER\_JOB**: `10` = `10`

Tokens billed for one tile-sized job when live pricing is not available.

***

<a id="estimated_seconds_per_tile"></a>

## ESTIMATED_SECONDS_PER_TILE

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

> `const` **ESTIMATED\_SECONDS\_PER\_TILE**: `10` = `10`

Rough wall-clock time, in seconds, that one tile-sized job takes. Used for
estimates only.

***

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

## estimateWorkflowRunTokens

Import from `@infrared-city/infrared-sdk-ts/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="per_job_model_keys"></a>

## PER_JOB_MODEL_KEYS

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

> `const` **PER\_JOB\_MODEL\_KEYS**: `Readonly`&lt;`Record`&lt;[`AnalysesName`](requests.md#analysesname), `string`&gt;&gt;

For each analysis, the key of its entry in the older `perJob` section of
`PublicPricing`. Several analyses can share one key.

***

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

## PublicPricing

Import from `@infrared-city/infrared-sdk-ts/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 (see `PER_JOB_MODEL_KEYS`) 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-ts/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-ts/billing`.

> **resolveTokensPerJob**(`pricing`, `analysisType`): `number`

The tokens one job of an analysis costs, according to a price list.

The price listed for the analysis wins. When there is none, the
`run-analysis` action price is used, then the older `perJob` entries (the
analysis's own, then `default`), and finally `DEFAULT_TOKENS_PER_JOB`.
Entries that are not finite, non-negative numbers are skipped.

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

Tokens for one job.

***
