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

# Create Policy

> Create a routing policy in the organization. A policy is a named chain of models with a strategy: `fallback`, `load_balance`, or `latency`. Use the policy name as the `model` in inference requests to route through it. Requires an API key with write manage permissions.

Create a routing policy in your organization. A policy is a named chain of models with one strategy: `fallback` tries models in order, `load_balance` splits traffic by weight, and `latency` picks the fastest model. Once created, use the policy name as the `model` in inference requests, for example `policy/production-chat`.

[Fallback policies →](/features/fallback-policies) · [Load balancing policies →](/features/load-balancing-policies)


## OpenAPI

````yaml POST /v1/manage/policy
openapi: 3.0.3
info:
  title: Requesty Management API
  description: >-
    Requesty Management API for API key management, groups, members, and
    organization settings.
  version: 1.0.0
servers:
  - url: https://api-v2.requesty.ai
    description: Management API endpoint
security:
  - BearerAuth: []
paths:
  /v1/manage/policy:
    servers:
      - url: https://api-v2.requesty.ai
        description: Management API endpoint
    post:
      summary: Create policy
      description: >-
        Create a routing policy in the organization. A policy is a named chain
        of models with a strategy: `fallback`, `load_balance`, or `latency`. Use
        the policy name as the `model` in inference requests to route through
        it. Requires an API key with write manage permissions.
      operationId: createPolicy
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreatePolicyRequest'
      responses:
        '200':
          description: Policy created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/PolicyResponse'
        '400':
          description: >-
            Bad request - missing name, unsupported scope, or invalid policy
            configuration.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '401':
          description: Unauthorized - missing or invalid Authorization header.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '403':
          description: Forbidden - API key does not have write manage permissions.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
        '500':
          description: Internal server error.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
components:
  schemas:
    CreatePolicyRequest:
      type: object
      required:
        - name
        - config
        - scope
      properties:
        name:
          type: string
          description: >-
            Policy name. Use it as the `model` in inference requests, for
            example `policy/production-chat`.
          example: production-chat
        config:
          $ref: '#/components/schemas/PolicyConfig'
        scope:
          type: string
          enum:
            - POLICY_SCOPE_ORGANIZATION
          description: >-
            Policy scope. The Management API only accepts
            `POLICY_SCOPE_ORGANIZATION`.
          example: POLICY_SCOPE_ORGANIZATION
      example:
        name: production-chat
        config:
          fallback:
            models:
              - model: openai/gpt-4o
                key: POLICY_KEY_REQUESTY_FIRST
                retries: 2
              - model: anthropic/claude-sonnet-4
                key: POLICY_KEY_BYOK_FIRST
                retries: 1
        scope: POLICY_SCOPE_ORGANIZATION
    PolicyResponse:
      type: object
      properties:
        policy:
          $ref: '#/components/schemas/PolicyObject'
    ErrorResponse:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - origin
            - message
          properties:
            origin:
              type: string
              enum:
                - router
                - provider
              description: >-
                Whether the error originated from Requesty's router or an
                upstream provider.
            message:
              type: string
              description: Human-readable error description.
    PolicyConfig:
      type: object
      description: >-
        Policy strategy and model chain. Set exactly one of `fallback`,
        `load_balance`, or `latency`, with at least one model.
      properties:
        fallback:
          type: object
          description: Try models in order, moving to the next when a request fails
          properties:
            models:
              type: array
              items:
                $ref: '#/components/schemas/PolicyFallbackModel'
        load_balance:
          type: object
          description: Distribute requests across models by weight
          properties:
            models:
              type: array
              items:
                $ref: '#/components/schemas/PolicyLoadBalanceModel'
        latency:
          type: object
          description: Route each request to the model with the lowest observed latency
          properties:
            models:
              type: array
              items:
                $ref: '#/components/schemas/PolicyLatencyModel'
    PolicyObject:
      type: object
      properties:
        id:
          type: string
          format: uuid
          description: The policy ID
        name:
          type: string
          description: The policy name
        config:
          $ref: '#/components/schemas/PolicyConfig'
        organization_id:
          type: string
          description: The organization ID that owns this policy
        author_id:
          type: string
          description: The user ID that created the policy
        scope:
          type: string
          enum:
            - POLICY_SCOPE_ORGANIZATION
          description: >-
            Policy scope. The Management API only accepts
            `POLICY_SCOPE_ORGANIZATION`.
          example: POLICY_SCOPE_ORGANIZATION
    PolicyFallbackModel:
      type: object
      required:
        - model
        - key
        - retries
      properties:
        model:
          type: string
          description: Model identifier in `provider/model` form
          example: openai/gpt-4o
        key:
          type: string
          enum:
            - POLICY_KEY_BYOK_ONLY
            - POLICY_KEY_NON_BYOK_ONLY
            - POLICY_KEY_REQUESTY_FIRST
            - POLICY_KEY_BYOK_FIRST
          description: >-
            Which credentials to use for this model: `POLICY_KEY_BYOK_ONLY` uses
            only your own provider key, `POLICY_KEY_NON_BYOK_ONLY` uses only
            Requesty's key, `POLICY_KEY_REQUESTY_FIRST` and
            `POLICY_KEY_BYOK_FIRST` try one and fall back to the other.
          example: POLICY_KEY_REQUESTY_FIRST
        retries:
          type: integer
          description: >-
            Number of attempts for this model before moving to the next one in
            the chain. Must be at least 1.
          example: 2
          minimum: 1
    PolicyLoadBalanceModel:
      type: object
      required:
        - model
        - key
        - weight
      properties:
        model:
          type: string
          description: Model identifier in `provider/model` form
          example: openai/gpt-4o
        key:
          type: string
          enum:
            - POLICY_KEY_BYOK_ONLY
            - POLICY_KEY_NON_BYOK_ONLY
            - POLICY_KEY_REQUESTY_FIRST
            - POLICY_KEY_BYOK_FIRST
          description: >-
            Which credentials to use for this model: `POLICY_KEY_BYOK_ONLY` uses
            only your own provider key, `POLICY_KEY_NON_BYOK_ONLY` uses only
            Requesty's key, `POLICY_KEY_REQUESTY_FIRST` and
            `POLICY_KEY_BYOK_FIRST` try one and fall back to the other.
          example: POLICY_KEY_REQUESTY_FIRST
        weight:
          type: integer
          description: >-
            Relative share of traffic sent to this model. Must be greater than
            0.
          example: 1
          minimum: 1
    PolicyLatencyModel:
      type: object
      required:
        - model
        - key
      properties:
        model:
          type: string
          description: Model identifier in `provider/model` form
          example: openai/gpt-4o
        key:
          type: string
          enum:
            - POLICY_KEY_BYOK_ONLY
            - POLICY_KEY_NON_BYOK_ONLY
            - POLICY_KEY_REQUESTY_FIRST
            - POLICY_KEY_BYOK_FIRST
          description: >-
            Which credentials to use for this model: `POLICY_KEY_BYOK_ONLY` uses
            only your own provider key, `POLICY_KEY_NON_BYOK_ONLY` uses only
            Requesty's key, `POLICY_KEY_REQUESTY_FIRST` and
            `POLICY_KEY_BYOK_FIRST` try one and fall back to the other.
          example: POLICY_KEY_REQUESTY_FIRST
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: API key for authentication

````