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

# Ausgabenregel abrufen

> Ruft eine Ausgabenregel ab.

Erfordert `spend_rules:read`. Alle Mitglieder des Arbeitsbereichs können Ausgabenregeln lesen.


## OpenAPI

````yaml de/openapi/v1/openapi.localized.yaml GET /spend-rules/{id}
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}:
    parameters:
      - name: id
        in: path
        required: true
        description: ID der Ausgabenregel.
        schema:
          type: string
          format: uuid
    get:
      tags:
        - Gateway
      summary: Ausgabenregel abrufen
      description: Gibt eine Ausgabenregel zurück.
      operationId: getSpendRule
      responses:
        '200':
          description: Ausgabenregel
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SpendRuleResponse'
        default:
          description: Anfrage fehlgeschlagen
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    SpendRuleResponse:
      type: object
      required:
        - data
      properties:
        data:
          $ref: '#/components/schemas/SpendRule'
    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
    SpendRule:
      type: object
      description: >-
        Eine Ausgabenregel: Schwellenwerte in Dollar oder Prozent für einen
        Bereich und einen Zeitraum, die benachrichtigen oder benachrichtigen und
        dann sperren. Beträge werden in Nanodollar und in USD zurückgegeben.
      required:
        - id
        - workspace_id
        - name
        - enabled
        - metric
        - evaluated
        - scope_type
        - scope_id
        - period
        - window_hours
        - time_zone
        - base_kind
        - base_ref
        - base_amount_nanos
        - base_amount_usd
        - threshold_percents
        - threshold_amount_nanos
        - threshold_amount_usd
        - runway_days
        - spike_multiplier
        - spike_floor_nanos
        - spike_floor_usd
        - action
        - block_at_percent
        - block_at_amount_nanos
        - block_at_amount_usd
        - block_free_models
        - cooldown_minutes
        - destination_ids
        - created_by
        - created_at
        - updated_at
      properties:
        id:
          type: string
          format: uuid
        workspace_id:
          type: string
          format: uuid
        name:
          type: string
          minLength: 1
          maxLength: 100
        enabled:
          type: boolean
        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.
        scope_type:
          $ref: '#/components/schemas/SpendRuleScope'
        scope_id:
          type: string
          maxLength: 200
          nullable: true
          description: >-
            Null für den Workspace-Bereich; sonst eine Schlüssel-ID, die
            Benutzer-ID eines Mitglieds, eine Abteilungs-ID, eine Modell-ID oder
            eine Anbieter-ID.
        period:
          $ref: '#/components/schemas/SpendRulePeriod'
        window_hours:
          type: integer
          minimum: 1
          maximum: 720
          nullable: true
          description: >-
            Stunden eines rolling-Fensters: das Spitzenfenster bei Regeln vom
            Typ spike (höchstens 56, damit 3 Fenster in die vorherigen 7 Tage
            passen) und der Verbrauchszeitraum bei Regeln vom Typ balance. Null
            für Kalenderzeiträume.
        time_zone:
          type: string
          maxLength: 64
          nullable: true
          description: >-
            IANA-Zeitzone für Kalenderzeiträume. Null verwendet die
            Abrechnungszeitzone des Workspace.
        base_kind:
          type: string
          enum:
            - amount
            - workspace_budget
            - key_limit
            - previous_period
          nullable: true
          description: >-
            Wovon threshold_percents Prozentsätze sind: amount (base_amount),
            workspace_budget oder key_limit (das Intervall base_ref, das zum
            Zeitraum passen muss) oder previous_period.
        base_ref:
          type: string
          nullable: true
          enum:
            - daily
            - weekly
            - monthly
        base_amount_nanos:
          type: integer
          format: int64
          nullable: true
        base_amount_usd:
          type: number
          nullable: true
        threshold_percents:
          type: array
          items:
            type: integer
            minimum: 1
            maximum: 1000
          minItems: 1
          maxItems: 5
          nullable: true
          description: >-
            Bis zu fünf ganzzahlige Prozentsätze der Basis, sortiert. Jeder löst
            höchstens einmal pro Zeitraum aus; werden mehrere zugleich
            überschritten, wird eine Warnung mit dem höchsten gesendet.
        threshold_amount_nanos:
          type: integer
          format: int64
          nullable: true
        threshold_amount_usd:
          type: number
          nullable: true
        runway_days:
          type: integer
          minimum: 1
          maximum: 365
          nullable: true
        spike_multiplier:
          type: number
          nullable: true
        spike_floor_nanos:
          type: integer
          format: int64
          nullable: true
        spike_floor_usd:
          type: number
          nullable: true
        action:
          $ref: '#/components/schemas/SpendRuleAction'
        block_at_percent:
          type: integer
          minimum: 100
          maximum: 1000
        block_at_amount_nanos:
          type: integer
          format: int64
          nullable: true
        block_at_amount_usd:
          type: number
          nullable: true
        block_free_models:
          type: boolean
          description: Ob eine Sperre auch Anfragen an kostenlose Modelle stoppt.
        cooldown_minutes:
          type: integer
          minimum: 5
          maximum: 43200
          description: >-
            Mindestabstand in Minuten zwischen Warnungen bei rolling-, spike-
            und balance-Regeln.
        destination_ids:
          type: array
          items:
            type: string
            format: uuid
          maxItems: 50
          description: >-
            Benachrichtigungsziele für die Warnungen dieser Regel. Leer bedeutet
            die Route für Spend Alerts des Workspace.
        created_by:
          type: string
          format: uuid
          nullable: true
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
      additionalProperties: false
    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
    SpendRuleScope:
      type: string
      enum:
        - workspace
        - key
        - member
        - department
        - model
        - provider
    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
    SpendRuleAction:
      type: string
      description: >-
        notify, oder benachrichtigen und dann sperren, sobald die Ausgaben
        block_at_percent der Basis oder block_at_amount erreichen. Das Sperren
        erfolgt nach bestem Bemühen und greift Minuten nach dem Schwellenwert.
        Solange das Sperren im Gateway ausgeschaltet ist, wird eine Regel, die
        mit dem Sperren beginnen würde, mit einem 400 abgelehnt, und eine Regel,
        die bereits sperrt, benachrichtigt nur.
      enum:
        - notify
        - block
  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.