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

# Create a guardrail

> Creates a guardrail. It starts active and applies to nothing until it is assigned to a key, a member, a role, or made the organization default. Names are unique within the organization (400). `model_rules` is `{"default": "allow" | "deny", "rules": [{"pattern", "action"}]}`: a pattern is a model (`openai/gpt-4o`), a whole provider (`openai/*`) or a Universal AI id (`audio/tts/google`), and `action` is `allow` or `deny`. `rate_limit` is `N/second`, `N/minute`, `N/hour` or `N/day`, within the plan's own limit. `budget_cap` and `budget_period` (`daily`, `weekly`, `monthly`) go together; `budget_alert_percent` (1 to 100) needs them. Requires the `manage:write` scope.



## OpenAPI

````yaml https://api.edenai.run/v2/info/splitted-schema/management_api/openapi.json post /v3/manage/guardrails/
openapi: 3.0.3
info:
  title: Organization Management
  version: '2.0'
  description: Your project description
servers:
  - url: https://api.edenai.run
security: []
paths:
  /v3/manage/guardrails/:
    post:
      tags:
        - Guardrails
      summary: Create a guardrail
      description: >-
        Creates a guardrail. It starts active and applies to nothing until it is
        assigned to a key, a member, a role, or made the organization default.
        Names are unique within the organization (400). `model_rules` is
        `{"default": "allow" | "deny", "rules": [{"pattern", "action"}]}`: a
        pattern is a model (`openai/gpt-4o`), a whole provider (`openai/*`) or a
        Universal AI id (`audio/tts/google`), and `action` is `allow` or `deny`.
        `rate_limit` is `N/second`, `N/minute`, `N/hour` or `N/day`, within the
        plan's own limit. `budget_cap` and `budget_period` (`daily`, `weekly`,
        `monthly`) go together; `budget_alert_percent` (1 to 100) needs them.
        Requires the `manage:write` scope.
      operationId: manage_guardrails_create
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/ManageGuardrailRequestRequest'
          application/x-www-form-urlencoded:
            schema:
              $ref: '#/components/schemas/ManageGuardrailRequestRequest'
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/ManageGuardrailRequestRequest'
        required: true
      responses:
        '201':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Guardrail'
          description: ''
      security:
        - ManagementKeyAuth: []
components:
  schemas:
    ManageGuardrailRequestRequest:
      type: object
      description: >-
        A guardrail's settings. Every field but `name` is optional and left out
        means not set: no

        model rules, no rate limit, no budget. A new guardrail starts active;
        pause it with

        `PUT /v3/manage/guardrails/{guardrail_id}/active`.
      properties:
        name:
          type: string
          minLength: 1
          maxLength: 200
        description:
          type: string
          nullable: true
          default: ''
          maxLength: 500
        model_rules:
          nullable: true
        rate_limit:
          type: string
          nullable: true
          minLength: 1
          maxLength: 15
        budget_cap:
          type: number
          format: double
          maximum: 100000
          minimum: -100000
          exclusiveMaximum: true
          exclusiveMinimum: true
          nullable: true
        budget_period:
          nullable: true
          oneOf:
            - $ref: '#/components/schemas/BudgetPeriodEnum'
            - $ref: '#/components/schemas/NullEnum'
        budget_alert_percent:
          type: integer
          maximum: 100
          minimum: 1
          nullable: true
      required:
        - name
    Guardrail:
      type: object
      properties:
        id:
          type: integer
          readOnly: true
        name:
          type: string
          maxLength: 200
        description:
          type: string
        model_rules:
          nullable: true
        rate_limit:
          type: string
          nullable: true
          maxLength: 15
        budget_cap:
          type: number
          format: double
          maximum: 100000
          minimum: -100000
          exclusiveMaximum: true
          exclusiveMinimum: true
          nullable: true
        budget_period:
          nullable: true
          oneOf:
            - $ref: '#/components/schemas/BudgetPeriodEnum'
            - $ref: '#/components/schemas/BlankEnum'
            - $ref: '#/components/schemas/NullEnum'
        budget_alert_percent:
          type: integer
          maximum: 100
          minimum: 1
          nullable: true
        is_active:
          type: boolean
          readOnly: true
        is_default:
          type: boolean
          description: >-
            Whether this is its organization's default guardrail.


            Pass ``organization`` in the context (every guardrail view does) so
            a list

            reads the default off that one row instead of a query per guardrail.
          readOnly: true
        created_at:
          type: string
          format: date-time
          readOnly: true
        updated_at:
          type: string
          format: date-time
          readOnly: true
      required:
        - created_at
        - id
        - is_active
        - is_default
        - name
        - updated_at
    BudgetPeriodEnum:
      enum:
        - daily
        - weekly
        - monthly
      type: string
      description: |-
        * `daily` - Daily
        * `weekly` - Weekly
        * `monthly` - Monthly
    NullEnum:
      enum:
        - null
    BlankEnum:
      enum:
        - ''
  securitySchemes:
    ManagementKeyAuth:
      type: http
      scheme: bearer
      bearerFormat: opaque
      description: >-
        A management key (created from the organization dashboard or with `POST
        /v3/manage/auth-keys`), sent as `Authorization: Bearer
        <management_key>`. Inference API keys (`sk-eden...`) are not accepted on
        these endpoints.

````

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