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

> ## Agent Instructions
> Phaseo Gateway base URL: https://api.phaseo.app/v1. Send `Authorization: Bearer $PHASEO_API_KEY` with every request.
> Model IDs look like `provider/model`, for example `openai/gpt-6-astra`. Do not guess IDs: list them with `GET /v1/models` or check https://phaseo.app/models. `phaseo/free` routes to an available free model and needs no wallet balance.
> For new text integrations prefer `POST /v1/responses`. `POST /v1/chat/completions` (OpenAI format) and `POST /v1/messages` (Anthropic format) suit existing code.
> The full API contract is https://phaseo.app/docs/openapi/v1/openapi.yaml. Official SDKs: `@phaseo/sdk` (TypeScript) and `phaseo` (Python), plus Go, C#, PHP, Ruby and Rust.
> Search these docs over MCP at https://phaseo.app/docs/mcp, and install Phaseo skills with `npx skills add https://phaseo.app/docs`. If a page is wrong or out of date, report it with the MCP `submit_feedback` tool.
> Manage Phaseo accounts with the `phaseo` CLI (`npm install -g @phaseo/cli`, then `phaseo login` or `phaseo login --device-code`), the `/v1` Management API or the MCP server at `https://mcp.phaseo.app/mcp?access=manage`. Do not send users to the dashboard for account tasks. A person is still needed for sign-up, approving a sign-in, paying the first top-up on the checkout link that `phaseo credits add` returns when no card is saved, confirming each saved-card top-up from the emailed link, and account security (password, MFA, passkeys). Create API keys with `phaseo keys create --name <name> --json`; never guess one. Credit top-ups need `phaseo login --scopes billing:write` first. Task map: https://phaseo.app/docs/v1/developers/manage-from-an-agent.md.

# Vorschau einer Ausgabenregel

> Zeigt den aktuellen Wert, die Basis und die nächste Schwelle einer Ausgabenregel.

Erfordert `spend_rules:read`. Es wird nichts gesendet oder gespeichert. Prognose-, Spitzen- und Guthabenregeln enthalten ihr eigenes Objekt `forecast`, `spike` oder `balance`.


## OpenAPI

````yaml de/openapi/v1/openapi.localized.yaml GET /spend-rules/{id}/preview
openapi: 3.0.3
info:
  title: Phaseo Gateway API
  description: >-
    Eine Gateway-API für den Zugriff auf verschiedene KI-Modelle über
    OpenAI-kompatible Endpunkte.
  version: 1.0.0
  contact:
    name: Phaseo
    url: https://phaseo.app
    email: danielbutler500@gmail.com
servers:
  - url: https://api.phaseo.app/v1
    description: Globales Routing
security:
  - BearerAuth: []
tags:
  - name: Gateway
    description: Core Phaseo Gateway operations.
paths:
  /spend-rules/{id}/preview:
    parameters:
      - name: id
        in: path
        required: true
        description: ID der Ausgabenregel.
        schema:
          type: string
          format: uuid
    get:
      tags:
        - Gateway
      summary: Vorschau einer Ausgabenregel
      description: >-
        Gibt den aktuellen Zeitraum der Regel, die bisherigen Ausgaben, die
        Basis, den Prozentsatz und den nächsten Schwellenwert zurück, so
        berechnet wie bei der Auswertung, ohne etwas zu senden oder zu
        speichern.
      operationId: previewSpendRule
      responses:
        '200':
          description: Vorschau der Ausgabenregel
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SpendRulePreviewResponse'
        default:
          description: Anfrage fehlgeschlagen
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    SpendRulePreviewResponse:
      type: object
      required:
        - data
      properties:
        data:
          $ref: '#/components/schemas/SpendRulePreview'
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        ok:
          type: boolean
          example: false
        error:
          description: >-
            Das Fehlerobjekt (`code`, `message`, `type`, `param` und optional
            `metadata`), das OpenAI-kompatible SDKs lesen. Frühere Antworten
            lieferten hier den Code als String; er wird jetzt zusätzlich als
            `code` auf oberster Ebene zurückgegeben.
          oneOf:
            - type: string
            - $ref: '#/components/schemas/ErrorObject'
          example:
            code: validation_error
            message: 'Unknown parameter: foo'
            type: invalid_request_error
            param: foo
        code:
          type: string
          description: Der Fehlercode, derselbe Wert wie `error.code`.
          example: validation_error
        message:
          type: string
          example: Human-readable error message
        description:
          type: string
          example: Additional error details.
        generation_id:
          type: string
          example: G-abc123
        status_code:
          type: integer
          example: 502
        error_type:
          type: string
          enum:
            - user
            - system
          example: system
        error_origin:
          type: string
          enum:
            - user
            - gateway
            - upstream
          example: upstream
        reason:
          type: string
          example: all_candidates_failed
        attempt_count:
          type: integer
          example: 2
        failed_providers:
          type: array
          items:
            type: string
          example:
            - google-ai-studio
            - openai
        failed_statuses:
          type: array
          items:
            type: integer
          example:
            - 403
            - 429
        upstream_error:
          $ref: '#/components/schemas/ErrorUpstreamError'
        failure_sample:
          type: array
          items:
            $ref: '#/components/schemas/ErrorFailureSampleItem'
        provider_failure_diagnostics:
          $ref: '#/components/schemas/ErrorProviderFailureDiagnostics'
        routing_diagnostics:
          $ref: '#/components/schemas/ErrorRoutingDiagnostics'
        provider_candidate_diagnostics:
          $ref: '#/components/schemas/ErrorProviderCandidateDiagnostics'
        provider_enablement:
          $ref: '#/components/schemas/ErrorProviderEnablementDiagnostics'
        missing_pricing_providers:
          type: array
          items:
            type: string
        provider_payment_required_provider:
          type: string
          example: openai
        provider_payment_required_support_notice:
          type: string
          example: >-
            Our upstream provider billing appears to be unavailable. If this
            persists, contact support.
        details:
          type: array
          items:
            type: object
            additionalProperties: true
      additionalProperties: true
    SpendRulePreview:
      type: object
      description: >-
        Wo eine Ausgabenregel gerade steht. Regeln vom Typ rolling haben ihr
        Fenster als period. Regeln vom Typ forecast haben ein forecast-Objekt,
        und ihre Schwellenwerte werden an der Prognose gemessen. Regeln vom Typ
        balance haben das Verbrauchsfenster als period, das verfügbare Guthaben
        als Wert und ein balance-Objekt. Regeln vom Typ spike haben ihr Fenster
        als period, die Ausgaben darin als Wert, den Median desselben Fensters
        über die vorherigen 7 Tage als Basis, den Auslösepunkt als
        next_threshold und ein spike-Objekt.
      required:
        - rule_id
        - metric
        - evaluated
        - computed_at
        - time_zone
        - period
        - value_nanos
        - value_usd
        - base_kind
        - base_ref
        - base_nanos
        - base_usd
        - previous_period
        - forecast
        - percent
        - threshold_percents
        - threshold_amount_nanos
        - threshold_amount_usd
        - reached_threshold_percent
        - next_threshold
        - block_at_nanos
        - block_at_usd
        - balance
        - spike
        - state
        - alert
      properties:
        rule_id:
          type: string
          format: uuid
        metric:
          $ref: '#/components/schemas/SpendRuleMetric'
        evaluated:
          type: boolean
          description: >-
            Ob die Auswertung Metrik, Zeitraum und Basis der Regel unterstützt.
            Jede Regel, die die API annimmt, wird ausgewertet.
        computed_at:
          type: string
          format: date-time
        time_zone:
          type: string
        period:
          type: object
          nullable: true
          required:
            - kind
            - start
            - end
          properties:
            kind:
              $ref: '#/components/schemas/SpendRulePeriod'
            start:
              type: string
              format: date-time
            end:
              type: string
              format: date-time
            window_hours:
              type: integer
              description: 'Nur Regeln vom Typ rolling: die Länge des Fensters in Stunden.'
        value_nanos:
          type: integer
          format: int64
          nullable: true
        value_usd:
          type: number
          nullable: true
        base_kind:
          type: string
          enum:
            - amount
            - workspace_budget
            - key_limit
            - previous_period
          nullable: true
        base_ref:
          type: string
          nullable: true
          enum:
            - daily
            - weekly
            - monthly
        base_nanos:
          type: integer
          format: int64
          nullable: true
        base_usd:
          type: number
          nullable: true
        previous_period:
          type: object
          nullable: true
          description: >-
            Nur Basen vom Typ previous_period: der Abschnitt des vorherigen
            Zeitraums, den die Basis abdeckt (derselbe Zeitpunkt im vorherigen
            Zeitraum, das vorherige Fenster einer rolling-Regel oder der gesamte
            vorherige Zeitraum bei einem forecast). Null für andere Basen.
          required:
            - start
            - end
          properties:
            start:
              type: string
              format: date-time
            end:
              type: string
              format: date-time
        forecast:
          type: object
          nullable: true
          description: >-
            Nur Regeln vom Typ forecast: die Ausgaben am Ende des Zeitraums,
            wenn das bisherige Tempo anhält (eine Gerade ab Beginn des
            Zeitraums, wie sie das Nutzungs-Dashboard projiziert). Null für
            andere Regeln.
          required:
            - ready
            - from
            - projected_nanos
            - projected_usd
            - projected_percent
            - by
            - limit_nanos
            - limit_usd
            - reaches_at
          properties:
            ready:
              type: boolean
              description: >-
                False, bis genug vom Zeitraum vergangen ist, um zu projizieren:
                3 Stunden eines Tages, 24 Stunden einer Woche oder 72 Stunden
                eines Monats.
            from:
              type: string
              format: date-time
              nullable: true
              description: Wann die Prognose beginnt.
            projected_nanos:
              type: integer
              format: int64
              nullable: true
            projected_usd:
              type: number
              nullable: true
            projected_percent:
              type: number
              nullable: true
              description: Die Prognose als Prozentsatz der Basis.
            by:
              type: string
              format: date-time
              description: Das Ende des Zeitraums, für das die Prognose gilt.
            limit_nanos:
              type: integer
              format: int64
              nullable: true
              description: >-
                Woran die Prognose gemessen wird: am Betragsschwellenwert, sonst
                an der Basis.
            limit_usd:
              type: number
              nullable: true
            reaches_at:
              type: string
              format: date-time
              nullable: true
              description: >-
                Wann das bisherige Tempo das Limit erreicht, sofern das vor Ende
                des Zeitraums geschieht.
        percent:
          type: number
          nullable: true
        threshold_percents:
          type: array
          items:
            type: integer
          nullable: true
        threshold_amount_nanos:
          type: integer
          format: int64
          nullable: true
        threshold_amount_usd:
          type: number
          nullable: true
        reached_threshold_percent:
          type: integer
          nullable: true
        next_threshold:
          type: object
          nullable: true
          description: >-
            Der nächste Schwellenwert, den der Wert noch nicht erreicht hat: ein
            Prozentsatz der Basis (null bei Betragsschwellen) und sein Betrag.
          required:
            - percent
            - amount_nanos
            - amount_usd
          properties:
            percent:
              type: integer
              nullable: true
            amount_nanos:
              type: integer
              format: int64
            amount_usd:
              type: number
        block_at_nanos:
          type: integer
          format: int64
          nullable: true
        block_at_usd:
          type: number
          nullable: true
        state:
          type: object
          nullable: true
          required:
            - highest_percent_fired
            - amount_fired_at
            - last_fired_at
            - fire_count
          properties:
            highest_percent_fired:
              type: integer
              nullable: true
            amount_fired_at:
              type: string
              format: date-time
              nullable: true
            last_fired_at:
              type: string
              format: date-time
              nullable: true
            fire_count:
              type: integer
            armed:
              type: boolean
              description: >-
                Regeln vom Typ balance: false nach einer Warnung, bis das
                Guthaben wieder über dem Schwellenwert liegt.
        balance:
          type: object
          nullable: true
          description: >-
            Nur Regeln vom Typ balance: wo das Guthaben steht, so wie die
            Auswertung es sieht. Null für andere Regeln.
          required:
            - balance_usd
            - reserved_usd
            - available_nanos
            - available_usd
            - window_hours
            - burn_usd
            - burn_per_day_usd
            - runway_days_left
            - low_balance
            - low_runway
            - armed
            - auto_top_up_covers
          properties:
            balance_usd:
              type: number
            reserved_usd:
              type: number
            available_nanos:
              type: integer
              format: int64
              description: >-
                Guthaben abzüglich reserviertem Guthaben: der Betrag, gegen den
                Anfragen zugelassen werden.
            available_usd:
              type: number
            window_hours:
              type: integer
            burn_usd:
              type: number
            burn_per_day_usd:
              type: number
            runway_days_left:
              type: number
              nullable: true
              description: >-
                Tage, die das verfügbare Guthaben beim aktuellen Verbrauch
                reicht. Null ohne Ausgaben im Fenster.
            low_balance:
              type: boolean
            low_runway:
              type: boolean
            armed:
              type: boolean
            auto_top_up_covers:
              type: boolean
              description: >-
                Die automatische Aufladung ist aktiv und funktioniert, daher
                wird ein Rückgang ohne Warnung erfasst.
        spike:
          type: object
          nullable: true
          description: >-
            Nur Regeln vom Typ spike: die Ausgaben der letzten window_hours im
            Vergleich zum Median desselben Fensters über die vorherigen 7 Tage,
            so wie die Auswertung sie sieht. Null für andere Regeln.
          required:
            - window_hours
            - current_nanos
            - current_usd
            - baseline_nanos
            - baseline_usd
            - multiple
            - multiplier
            - floor_usd
            - fires_at_nanos
            - fires_at_usd
            - baseline_windows
            - active_windows
            - history_ready
            - spiking
            - cooldown_until
          properties:
            window_hours:
              type: integer
            current_nanos:
              type: integer
              format: int64
            current_usd:
              type: number
            baseline_nanos:
              type: integer
              format: int64
              description: >-
                Der Median desselben Fensters über die vorherigen 7 Tage:
                dieselben Stunden an jedem der 7 Tage davor bei Fenstern unter
                24 Stunden, sonst die vorherigen, nicht überlappenden Fenster,
                die in 7 Tage passen.
            baseline_usd:
              type: number
            multiple:
              type: number
              nullable: true
              description: >-
                Die Ausgaben im Fenster geteilt durch die Basis. Null, wenn die
                Basis 0 ist; dann gilt nur die Untergrenze.
            multiplier:
              type: number
            floor_usd:
              type: number
            fires_at_nanos:
              type: integer
              format: int64
              description: >-
                Was die Ausgaben im Fenster erreichen müssen, um auszulösen: das
                Größere aus dem spike_multiplier-Fachen der Basis und der
                Untergrenze.
            fires_at_usd:
              type: number
            baseline_windows:
              type: integer
              description: >-
                Wie viele Fenster die Basis hat. Eine Regel braucht mindestens
                3.
            active_windows:
              type: integer
              description: Basisfenster, in denen der Workspace etwas ausgegeben hat.
            history_ready:
              type: boolean
              description: >-
                False, bis der Workspace in mindestens 3 Basisfenstern etwas
                ausgegeben hat. Vorher löst die Regel nicht aus.
            spiking:
              type: boolean
              description: Ob die Regel jetzt auslösen würde, vor der Abklingzeit.
            cooldown_until:
              type: string
              format: date-time
              nullable: true
              description: >-
                Wann die Abklingzeit nach der letzten Warnung endet, falls sie
                noch läuft.
        alert:
          type: object
          nullable: true
          description: >-
            Der Text, den eine Warnung jetzt hätte, mit dem höchsten erreichten
            Schwellenwert oder dem ersten.
          required:
            - scope_label
            - title
            - message
          properties:
            scope_label:
              type: string
            title:
              type: string
            message:
              type: string
    ErrorObject:
      type: object
      description: >-
        Ein Gateway-Fehler in der Form, die die SDKs von OpenAI lesen. `type`
        ergibt sich aus dem HTTP-Status: invalid_request_error für die meisten
        4xx, authentication_error (401), insufficient_quota (402),
        permission_error (403), not_found_error (404), rate_limit_error (429),
        service_unavailable (503), overloaded (529) und server_error für andere
        5xx.
      required:
        - code
        - message
        - type
      properties:
        code:
          type: string
          description: Maschinenlesbarer Fehlercode.
          example: validation_error
        message:
          type: string
          description: Verständliche Erklärung des Fehlers.
          example: 'Unknown parameter: foo'
        type:
          type: string
          description: Der Fehlertyp, nach den von OpenAI dokumentierten Fehlertypen.
          enum:
            - invalid_request_error
            - authentication_error
            - permission_error
            - not_found_error
            - rate_limit_error
            - insufficient_quota
            - server_error
            - service_unavailable
            - overloaded
          example: invalid_request_error
        param:
          type: string
          nullable: true
          description: Der Anfrageparameter, der den Fehler verursacht hat, sofern bekannt.
          example: foo
        metadata:
          type: object
          description: >-
            Strukturierte Details, die auch auf oberster Ebene zurückgegeben
            werden, etwa der fehlgeschlagene Anbieter, `reason`,
            `failed_statuses`, `retry_after_seconds` oder `upstream_error`.
          additionalProperties: true
      additionalProperties: true
    ErrorUpstreamError:
      type: object
      properties:
        code:
          type: string
          nullable: true
          example: PERMISSION_DENIED
        message:
          type: string
          nullable: true
          example: The caller does not have permission.
        description:
          type: string
          nullable: true
        param:
          type: string
          nullable: true
    ErrorFailureSampleItem:
      type: object
      properties:
        provider:
          type: string
          nullable: true
        type:
          type: string
          nullable: true
        status:
          type: integer
          nullable: true
        upstream_error_code:
          type: string
          nullable: true
        upstream_error_message:
          type: string
          nullable: true
        upstream_error_description:
          type: string
          nullable: true
        upstream_error_param:
          type: string
          nullable: true
        upstream_payload_preview:
          type: string
          nullable: true
        retryable:
          type: boolean
          nullable: true
      additionalProperties: true
    ErrorProviderFailureDiagnostics:
      type: object
      properties:
        category:
          type: string
          enum:
            - credentials_not_configured
            - credentials_invalid_or_forbidden
            - provider_access_missing
            - region_or_project_restriction
            - model_unavailable_for_endpoint
            - rate_limited
            - server_error
        hint:
          type: string
        provider:
          type: string
          nullable: true
    ErrorRoutingDiagnostics:
      type: object
      properties:
        filterStages:
          type: array
          items:
            type: object
            properties:
              stage:
                type: string
              beforeCount:
                type: integer
              afterCount:
                type: integer
              droppedProviders:
                type: array
                items:
                  type: object
                  properties:
                    providerId:
                      type: string
                      nullable: true
                    reason:
                      type: string
                      nullable: true
                  additionalProperties: true
            additionalProperties: true
      additionalProperties: true
    ErrorProviderCandidateDiagnostics:
      type: object
      properties:
        totalProviders:
          type: integer
        supportsEndpointCount:
          type: integer
        candidateCount:
          type: integer
        droppedUnsupportedEndpoint:
          type: array
          items:
            type: string
        droppedMissingAdapter:
          type: array
          items:
            type: object
            properties:
              providerId:
                type: string
                nullable: true
              endpoint:
                type: string
                nullable: true
            additionalProperties: true
      additionalProperties: true
    ErrorProviderEnablementDiagnostics:
      type: object
      properties:
        capability:
          type: string
        providersBefore:
          type: array
          items:
            type: string
        providersAfter:
          type: array
          items:
            type: string
        dropped:
          type: array
          items:
            type: object
            properties:
              providerId:
                type: string
                nullable: true
              reason:
                type: string
                nullable: true
            additionalProperties: true
      additionalProperties: true
    SpendRuleMetric:
      type: string
      description: >-
        spend: Die Ausgaben haben threshold_amount erreicht. budget_percent: Die
        Ausgaben haben threshold_percents der Basis erreicht. forecast: Die bis
        Zeitraumende projizierten Ausgaben erreichen den Schwellenwert. spike:
        Die Ausgaben der letzten window_hours betragen mindestens das
        spike_multiplier-Fache des Medians desselben Fensters über die
        vorherigen 7 Tage und mindestens spike_floor. balance: Guthaben oder
        Reichweite des Workspace fallen unter den Schwellenwert.
      enum:
        - spend
        - budget_percent
        - forecast
        - spike
        - balance
    SpendRulePeriod:
      type: string
      description: >-
        day, week (ab Montag) oder month in der Zeitzone der Regel, oder rolling
        über die letzten window_hours.
      enum:
        - day
        - week
        - month
        - rolling
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: Authentifizierung mit Bearer-Token

````

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