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

> ## Agent Instructions
> Agents: start with https://docs.pre.dev/agents.md, which has complete recipes, plan access, polling rules, errors and limits.
> Authenticate with the workspace API key (pdk_…) from Integrations → Built-in, sent as Authorization: Bearer <key>.
> REST API: https://api.pre.dev (OpenAPI: https://docs.pre.dev/api-reference/openapi.json). AI Gateway: https://api.pre.dev/v1, OpenAI-compatible (OpenAPI: https://docs.pre.dev/api-reference/ai-gateway.openapi.json).
> pre.dev MCP server: https://api.pre.dev/mcp. Search these docs over MCP at https://docs.pre.dev/mcp.

# Get credit balance

> Read the credit balance selected by your authenticated account or organization.

```bash theme={null}
curl --fail-with-body https://api.pre.dev/credits-balance \
  -H "Authorization: Bearer $PREDEV_API_KEY"
```

Example response:

```json theme={null}
{ "success": true, "creditsRemaining": 42.5 }
```

Credit balances can be fractional. The key determines which account or organization balance is returned; there is no user or organization request parameter.

Use this for budgeting before generation. A balance check does not reserve credits, and specification costs vary. For browser submissions, also check your [queue and in-flight limit](/browser-agents/api/queue-status).

In Node, call `client.getCreditsBalance()`. In Python, `client.get_credits_balance()` returns a `CreditsBalanceResponse` object, so read `balance.creditsRemaining`. This is an exception to the Python SDK's dictionary-shaped specification and browser responses.

## Errors

| Status | When |
| - | - |
| `401` | Missing or invalid key, or a personal key without a paid plan |
| `500` | Unexpected error |

Each status has an example body in the response examples. See [errors and retries](/api-reference/errors).


## OpenAPI

````yaml api-reference/openapi.json GET /credits-balance
openapi: 3.1.0
info:
  title: pre.dev API
  description: >-
    Public REST API for software specifications, browser automation, and credit
    balance. Base URL: https://api.pre.dev. MCP is documented separately at
    https://docs.pre.dev/mcp/tools.
  version: 1.1.0
  contact:
    name: pre.dev Support
    url: https://pre.dev
    email: support@pre.dev
  license:
    name: Proprietary
    url: https://pre.dev/terms
servers:
  - url: https://api.pre.dev
    description: Production API Server
security:
  - apiKeyAuth: []
  - xApiKey: []
tags:
  - name: Specifications
  - name: Browser Agents
  - name: Account
paths:
  /credits-balance:
    get:
      tags:
        - Account
      summary: Get credit balance
      description: >-
        Returns the effective account or organization balance. Fractional
        credits are possible.
      operationId: getCreditsBalance
      responses:
        '200':
          description: Credit balance.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CreditsBalanceResponse'
              example:
                success: true
                creditsRemaining: 412.5
        '401':
          description: Missing, invalid, or ineligible authentication.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                missing_key:
                  summary: No key sent
                  value:
                    error: Missing API key
                    message: >-
                      Please provide an API key via Authorization: Bearer
                      <token> header or x-api-key header
                invalid_key:
                  summary: Unknown key
                  value:
                    error: Authentication failed
                    message: Invalid API key
                no_subscription:
                  summary: Personal key without a paid plan
                  value:
                    error: Authentication failed
                    message: An active subscription is required for this endpoint
        '403':
          description: Access or trial eligibility denied.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: Invalid API Key or Domain
        '500':
          description: Request failed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error: Failed to retrieve credits balance
                message: Retry the request.
components:
  schemas:
    CreditsBalanceResponse:
      type: object
      required:
        - success
        - creditsRemaining
      properties:
        success:
          type: boolean
          description: Whether the request was successful
        creditsRemaining:
          type:
            - number
            - 'null'
          description: Remaining credits. `null` on plans without a credit limit.
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: string
        message:
          type: string
          description: Optional detail; not returned by every endpoint.
        code:
          type: string
          description: Machine-readable code when available.
        actionUrl:
          type: string
          format: uri
        requiresSubscription:
          type: boolean
        trialsUsed:
          type: integer
        maxTrials:
          type: integer
      additionalProperties: true
  securitySchemes:
    apiKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: API key
      description: >-
        Your pre.dev workspace API key (pdk_...) from Integrations, Built-in
        tab: https://pre.dev/projects/integrations?tab=built-in
    xApiKey:
      type: apiKey
      in: header
      name: x-api-key
      description: 'Alternative to Authorization: Bearer.'

````

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