> ## Documentation Index
> Fetch the complete documentation index at: https://docs.keenable.ai/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Every page is listed in https://docs.keenable.ai/llms.txt. To pick a product for a job, read https://docs.keenable.ai/choose.md
> Setup steps for agents, covering the SDKs, the MCP server and the CLI: https://docs.keenable.ai/skill.md
> Keenable search and fetch work without an API key. To add them to code, use the official SDK for the project's language: https://docs.keenable.ai/sdks.md
> Without a key, call POST https://api.keenable.ai/v1/search/public or GET https://api.keenable.ai/v1/fetch/public with an X-Keenable-Title header that names your app.
> With a key, send it in the X-API-Key header and read it from the KEENABLE_API_KEY environment variable. Never ask a user to paste a key into chat. Every access method: https://docs.keenable.ai/auth.md
> To get an API key without the console, use device login: https://docs.keenable.ai/authentication.md#device-login
> MCP server: https://api.keenable.ai/mcp (no key, or X-API-Key; keyless Codex uses https://api.keenable.ai/mcp-public), or https://api.keenable.ai/mcp-oauth for OAuth sign-in. These docs are an MCP server at https://docs.keenable.ai/mcp and the OpenAPI spec is at https://docs.keenable.ai/api-reference/openapi.json
> Keenable searches and fetches public web pages. If a question needs no web information, skip the call.
> On 402 with an API key (code insufficient_credits), stop and ask a human to add credits; don't retry. On 429, wait the number of seconds in Retry-After, then retry. Before you ship, follow https://docs.keenable.ai/production.md
> Every error, with its cause and fix, is in https://docs.keenable.ai/errors.md and moving from another search API is covered in https://docs.keenable.ai/migrate.md
> Before you compare Keenable with another search API, read https://docs.keenable.ai/guides/evaluate-search-apis.md

# Get billing

> Read what each call costs with GET /v1/billing and, with an API key, your organization's balance and this month's usage. Free, read-only, key optional.

> [!NOTE]
>
> Billing is in beta. Its fields can change without notice. See [Versioning](https://docs.keenable.ai/versioning.md).

Read what each call costs and, with an API key, how much your organization has left and has spent this month. The call is read-only and free, and it takes no parameters.

## When to use it

Call it before a large job to check that the balance covers it, or let an agent check its own budget. Over MCP, the [`get_billing`](https://docs.keenable.ai/mcp-server#get_billing) tool returns the same object.

Without a key, you get the public list prices and `account: null`. Keyless calls are limited to 60 requests per minute per IP address, separate from the search and fetch [rate limits](https://docs.keenable.ai/rate-limits.md).

```json theme={"theme":{"light":"github-light-high-contrast","dark":"dark-plus"}}
{
  "object": "billing",
  "prices": [
    { "sku": "search.pro", "unit": "search", "unit_price": { "amount": 0.004, "currency": "usd" } },
    { "sku": "search.realtime", "unit": "search", "unit_price": { "amount": 0.004, "currency": "usd" } },
    { "sku": "search.extra_result", "unit": "result", "unit_price": { "amount": 0, "currency": "usd" } },
    { "sku": "fetch", "unit": "page", "unit_price": { "amount": 0.004, "currency": "usd" } },
    { "sku": "fetch.live", "unit": "page", "unit_price": { "amount": 0.004, "currency": "usd" } }
  ],
  "account": null
}
```

`search.extra_result` counts each result past the first 10 in one search. It's listed at `0` because results past 10 aren't charged: a search costs the same whether it returns 1 result or 50.

With a key, `prices` lists your organization's own prices. Each one adds `list_unit_price` and `source`: `list` when you pay the list price, `contract` when your organization has its own. A SKU without a price on your plan is left out. `account` adds:

* `balance.available`: what you can still spend, your unused free allowance plus your purchased balance. It's negative only if your organization may go into debt and has.
* `balance.purchased`: the part you bought. It's spent after the free allowance.
* `usage.since`: when the current monthly period started, the day your free allowance last renewed.
* `usage.cost`: everything charged since then, the same spend your balance subtracts.
* `usage.line_items`: `quantity` and `cost` for `search`, `search.extra_result` and `fetch`. Other charged products count toward `usage.cost` but have no line item, so the line items can add up to less than `usage.cost`.
* `billing_url`: the console page where a person can [top up](https://docs.keenable.ai/credits.md#monthly-allowance).
* `as_of`: when the values were read. Usage can lag recent calls by about a minute.

Every amount is a `Money` object: `amount` is a number in US dollars, with up to nine decimal places, and `currency` is `usd`. Prices under a cent keep every digit, such as `0.0005`.

## Caching

Without a key, the response carries `Cache-Control: public, max-age=300`, so you can cache the list prices for 5 minutes. With a key, it carries `Cache-Control: private, no-cache`. Both carry `Vary: Authorization, X-API-Key`, so a shared cache never serves the public prices in answer to a call with a key.

## Errors

A call with a key that isn't accepted never falls back to the public view.

| Status | `code` | When |
| - | - | - |
| `400` | [`unknown_parameter`](https://docs.keenable.ai/errors#unknown-parameter) | The request has a query parameter. The call takes none. |
| `401` | [`invalid_api_key`](https://docs.keenable.ai/errors#invalid-api-key) | The key is malformed, unknown or expired. |
| `403` | [`credentials_forbidden`](https://docs.keenable.ai/errors#credentials-forbidden) | The key was revoked. |
| `409` | [`no_active_organization`](https://docs.keenable.ai/errors#no-active-organization) | You signed in, over MCP for example, but your account has no active organization. |
| `429` | [`rate_limited`](https://docs.keenable.ai/errors#rate-limited) | Without a key, your IP address sent more than 60 calls in a minute. Wait for `Retry-After`. |
| `500` | [`balance_check_unavailable`](https://docs.keenable.ai/errors#balance-check-unavailable) | Your balance couldn't be read. Retry after `Retry-After`. The call never reports a balance of 0 instead. |
| `500` | [`billing_account_not_found`](https://docs.keenable.ai/errors#billing-account-not-found) | Your organization has no billing record. Retrying won't help: contact support with the `request_id`. |

## SDK and MCP

| Client | Call |
| - | - |
| Python, TypeScript | `client.billing()` |
| Go | `client.Billing(ctx, nil)` |
| Rust | `client.billing()` |
| MCP | `get_billing`, no arguments |

## Related pages

* [Balance and usage](https://docs.keenable.ai/credits.md) explains the free allowance, the prepaid balance and `usage` on each response.
* [Pricing](https://docs.keenable.ai/pricing.md) lists the standard price of each SKU.


## OpenAPI

````yaml GET /v1/billing
openapi: 3.0.3
info:
  title: Keenable API
  version: 1.0.0
  description: Web search, page fetching and monitors API.
servers:
  - url: https://api.keenable.ai
    description: Production
security:
  - apiKey: []
  - bearerAuth: []
paths:
  /v1/billing:
    get:
      tags:
        - Billing
      summary: Get billing
      description: >-
        Returns what each call costs and, with an API key, how much your
        organization has left and has spent this month. The key is optional:
        without one you get the public list prices and `account: null`, limited
        to 60 requests per minute per IP address. Read-only and free. In beta:
        fields can change.
      operationId: billing
      responses:
        '200':
          description: Prices and, with an API key, your organization's balance and usage
          headers:
            X-Request-Id:
              $ref: '#/components/headers/XRequestId'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Billing'
        '400':
          description: >-
            The request has a query parameter. `GET /v1/billing` takes none.
            Remove it; retrying unchanged returns the same error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '401':
          description: >-
            The key is malformed, unknown or expired (`invalid_api_key`), or the
            bearer token isn't valid. A call without a key isn't an error: it
            returns the public prices.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '403':
          description: >-
            The API key was revoked (`credentials_forbidden`). Create a new key
            in the console; retrying with the same key returns the same error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '409':
          description: >-
            The signed-in account has no active organization
            (`no_active_organization`). Create or join one in the console, or
            call with an API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
        '429':
          description: >-
            Without a key, your IP address sent more than 60 requests in a
            minute. Wait for `Retry-After`, then retry, or send an API key.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ApiError'
          headers:
            Retry-After:
              $ref: '#/components/headers/RetryAfter'
        '500':
          $ref: '#/components/responses/InternalError'
        '503':
          $ref: '#/components/responses/AuthUnavailable'
      security:
        - apiKey: []
        - bearerAuth: []
        - {}
      x-codeSamples:
        - lang: typescript
          label: TypeScript
          source: |
            import { Keenable } from "keenable";

            async function main() {
              // reads KEENABLE_API_KEY from the environment
              const client = new Keenable();
              const billing = await client.billing();
              if (billing.account) {
                const available = billing.account.balance.available;
                console.log("Available:", available.amount, available.currency);
              }
              for (const price of billing.prices) {
                console.log(price.sku, price.unitPrice.amount, "per", price.unit);
              }
            }

            main();
        - lang: python
          label: Python
          source: |
            from keenable import Keenable

            # reads KEENABLE_API_KEY from the environment
            client = Keenable()
            billing = client.billing()
            if billing.account:
                available = billing.account.balance.available
                print("Available:", available.amount, available.currency)
            for price in billing.prices:
                print(price.sku, price.unit_price.amount, "per", price.unit)
        - lang: go
          label: Go
          source: "package main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"log\"\n\n\t\"github.com/keenableai/keenable-sdk/go\"\n)\n\nfunc main() {\n\t// reads KEENABLE_API_KEY from the environment\n\tclient, err := keenable.New(nil)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tdefer client.Close()\n\n\tbilling, err := client.Billing(context.Background(), nil)\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tif billing.Account != nil {\n\t\tavailable := billing.Account.Balance.Available\n\t\tfmt.Println(\"Available:\", available.Amount, available.Currency)\n\t}\n\tfor _, price := range billing.Prices {\n\t\tfmt.Println(price.SKU, price.UnitPrice.Amount, \"per\", price.Unit)\n\t}\n}\n"
        - lang: rust
          label: Rust
          source: |
            use keenable::Client;

            #[tokio::main]
            async fn main() -> Result<(), keenable::Error> {
                // reads KEENABLE_API_KEY from the environment
                let client = Client::new()?;
                let billing = client.billing().await?;
                if let Some(account) = &billing.account {
                    let available = &account.balance.available;
                    println!("Available: {} {}", available.amount, available.currency);
                }
                for price in &billing.prices {
                    println!("{} {} per {}", price.sku, price.unit_price.amount, price.unit);
                }
                Ok(())
            }
        - lang: bash
          label: curl
          source: |
            curl https://api.keenable.ai/v1/billing \
              -H "X-API-Key: $KEENABLE_API_KEY"
components:
  headers:
    XRequestId:
      description: ID of this request. Include it when you report a problem.
      schema:
        type: string
    RetryAfter:
      description: Seconds to wait before retrying.
      schema:
        type: integer
      example: 1
  schemas:
    Billing:
      type: object
      required:
        - object
        - prices
        - account
      properties:
        object:
          type: string
          enum:
            - billing
        prices:
          type: array
          items:
            $ref: '#/components/schemas/BillingPrice'
          description: >-
            Without an API key, the public list prices. With one, your
            organization's prices; a SKU without a price on your plan is left
            out.
        account:
          type: object
          allOf:
            - $ref: '#/components/schemas/BillingAccount'
          nullable: true
          description: null without an API key.
    ApiError:
      type: object
      required:
        - error
      properties:
        error:
          type: string
          description: Short error title, such as `Invalid parameter` or `Not found`.
          example: Invalid parameter
        message:
          type: string
          description: What went wrong and what to change. Sometimes absent.
          example: '"max_results": must be an integer between 1 and 50'
        details:
          description: Structured details, when the error has any.
        retryAfter:
          type: integer
          description: >-
            Seconds to wait before retrying. Present on `429` responses from
            Keenable's own rate limits, matching the `Retry-After` header.
    BillingPrice:
      type: object
      required:
        - sku
        - unit
        - unit_price
      properties:
        sku:
          type: string
          description: >-
            What is billed, as named in the price list, for example search.pro
            or fetch.live. search.extra_result is each result past the first 10
            in one search; it is listed at 0 because extra results are not
            charged.
          example: search.pro
        unit:
          type: string
          enum:
            - search
            - result
            - page
          description: What one unit is.
        unit_price:
          allOf:
            - $ref: '#/components/schemas/Money'
          description: Price of one unit.
        list_unit_price:
          allOf:
            - $ref: '#/components/schemas/Money'
          description: The public list price of one unit. Only with an API key.
        source:
          type: string
          enum:
            - list
            - contract
          description: >-
            list when unit_price is the public list price, contract when the
            organization has its own price. Only with an API key.
    BillingAccount:
      type: object
      required:
        - balance
        - usage
        - billing_url
        - as_of
      properties:
        balance:
          type: object
          required:
            - available
            - purchased
          properties:
            available:
              allOf:
                - $ref: '#/components/schemas/Money'
              description: >-
                What the organization can still spend: its unused free allowance
                for this month plus its purchased balance.
            purchased:
              allOf:
                - $ref: '#/components/schemas/Money'
              description: >-
                The part of the balance that was bought. It is spent after the
                free allowance.
        usage:
          type: object
          required:
            - since
            - cost
            - line_items
          properties:
            since:
              type: string
              format: date-time
              description: >-
                Start of the current monthly period, when the free allowance
                last renewed.
            cost:
              allOf:
                - $ref: '#/components/schemas/Money'
              description: >-
                Everything the organization was charged since the start of the
                period, the same spend the balance subtracts. It can be more
                than the sum of line_items when other products are charged.
            line_items:
              type: array
              items:
                $ref: '#/components/schemas/BillingUsageLine'
              description: >-
                Search and fetch usage. Other charged products count toward cost
                but have no line item.
        billing_url:
          type: string
          format: uri
          description: Console page where a person can add funds.
        as_of:
          type: string
          format: date-time
          description: When this was read. Usage can lag recent calls by about a minute.
    Money:
      type: object
      description: An amount of money.
      required:
        - amount
        - currency
      properties:
        amount:
          type: number
          description: >-
            Amount in US dollars, up to nine decimal places (a price per request
            is a fraction of a cent). Negative for an organization allowed a
            negative balance that is in debt.
          example: 0.004
        currency:
          type: string
          enum:
            - usd
          description: Lowercase ISO 4217 currency code.
    BillingUsageLine:
      type: object
      required:
        - sku
        - quantity
        - cost
      properties:
        sku:
          type: string
          enum:
            - search
            - search.extra_result
            - fetch
          description: >-
            What was used: searches of every mode, results past 10, and fetches
            of every kind.
        quantity:
          type: integer
          description: Units used since the start of the period.
        cost:
          allOf:
            - $ref: '#/components/schemas/Money'
          description: What those units cost.
  responses:
    InternalError:
      description: Keenable had an internal error. Retry up to 3 times with backoff.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
    AuthUnavailable:
      description: >-
        Keenable couldn't verify your key right now (`Authentication temporarily
        unavailable`). Wait for `Retry-After` (5 seconds), then retry.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/ApiError'
      headers:
        Retry-After:
          $ref: '#/components/headers/RetryAfter'
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: X-API-Key
      description: >-
        Your API key, such as `keen_...`. Create one in the Keenable console. If
        you send both this header and `Authorization`, the API uses this one.
    bearerAuth:
      type: http
      scheme: bearer
      description: >-
        Your API key sent as `Authorization: Bearer keen_...`, for clients that
        only support bearer tokens.

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.