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

# Train a Rasa model

> Trains a new Rasa model. Depending on the data given only a dialogue model, only a NLU model, or a model combining a trained dialogue model with an NLU model will be trained. The new model is not loaded by default.



## OpenAPI

````yaml /openapi/pro.yaml post /model/train
openapi: 3.0.1
info:
  title: Rasa - Server Endpoints
  version: 1.0.0
  description: >-
    The Rasa server provides endpoints to retrieve trackers of conversations as
    well as endpoints to modify them. Additionally, endpoints for training and
    testing models are provided.
servers:
  - url: http://localhost:5005
    description: Local development server
security: []
paths:
  /model/train:
    post:
      tags:
        - Model
      summary: Train a Rasa model
      description: >-
        Trains a new Rasa model. Depending on the data given only a dialogue
        model, only a NLU model, or a model combining a trained dialogue model
        with an NLU model will be trained. The new model is not loaded by
        default.
      operationId: trainModel
      parameters:
        - in: query
          name: save_to_default_model_directory
          schema:
            type: boolean
            default: true
            description: >-
              If `true` (default) the trained model will be saved in the default
              model directory, if `false` it will be saved in a temporary
              directory
        - in: query
          name: force_training
          schema:
            type: boolean
            default: false
            description: Force a model training even if the data has not changed
        - in: query
          name: augmentation
          schema:
            type: string
            default: 50
            description: How much data augmentation to use during training
        - in: query
          name: num_threads
          schema:
            type: string
            default: 1
            description: Maximum amount of threads to use when training
        - $ref: '#/components/parameters/callback_url'
      requestBody:
        required: true
        description: The training data should be in YAML format.
        content:
          application/yaml:
            schema:
              $ref: '#/components/schemas/YAMLTrainingRequest'
            example: |
              pipeline: []

              policies: []

              intents:
                - greet
                - goodbye

              entities: []

              slots:
                contacts_list:
                  type: text
                  mappings:
                    - type: custom
                      action: list_contacts

              actions:
                - list_contacts

              forms: {}
              e2e_actions: []

              responses:
                utter_greet:
                - text: "Hey! How are you?"

                utter_goodbye:
                - text: "Bye"

                utter_list_contacts:
                - text: "You currently have the following contacts:\n{contacts_list}"

                utter_no_contacts:
                - text: "You have no contacts in your list."

              session_config:
                session_expiration_time: 60
                carry_over_slots_to_new_session: true

              nlu:
              - intent: greet
                examples: |
                  - hey
                  - hello

              - intent: goodbye
                examples: |
                  - bye
                  - goodbye

              rules:

              - rule: Say goodbye anytime the user says goodbye
                steps:
                - intent: goodbye
                - action: utter_goodbye

              stories:

              - story: happy path
                steps:
                - intent: greet
                - action: utter_greet
                - intent: goodbye
                - action: utter_goodbye

              flows:
                 list_contacts:
                    name: list your contacts
                    description: show your contact list
                    steps:
                      - action: list_contacts
                        next:
                        - if: "slots.contacts_list"
                          then:
                            - action: utter_list_contacts
                              next: END
                        - else:
                            - action: utter_no_contacts
                              next: END
      responses:
        '200':
          description: Zipped Rasa model
          headers:
            filename:
              schema:
                type: string
              description: File name of the trained model.
          content:
            application/octet-stream:
              schema:
                $ref: '#/components/schemas/TrainingResult'
        '204':
          $ref: '#/components/responses/204Callback'
        '400':
          $ref: '#/components/responses/400BadRequest'
        '401':
          $ref: '#/components/responses/401NotAuthenticated'
        '403':
          $ref: '#/components/responses/403NotAuthorized'
        '500':
          $ref: '#/components/responses/500ServerError'
      security:
        - TokenAuth: []
        - JWT: []
components:
  parameters:
    callback_url:
      in: query
      name: callback_url
      description: >-
        If specified the call will return immediately with an empty response and
        status code 204. The actual result or any errors will be sent to the
        given callback URL as the body of a post request.
      example: https://example.com/rasa_evaluations
      schema:
        type: string
        default: None
      required: false
  schemas:
    YAMLTrainingRequest:
      type: object
      properties:
        pipeline:
          description: Pipeline list
          type: array
        policies:
          description: Policies list
          type: array
        entities:
          description: Entity list
          type: array
        slots:
          description: Slots list
          type: array
        actions:
          description: Action list
          type: array
        forms:
          description: Forms list
          type: array
        e2e_actions:
          description: E2E Action list
          type: array
        responses:
          description: Bot response templates
          type: object
          additionalProperties:
            $ref: '#/components/schemas/TemplateDescription'
        session_config:
          description: Session configuration options
          type: object
          properties:
            session_expiration_time:
              type: integer
            carry_over_slots_to_new_session:
              type: boolean
        nlu:
          description: Rasa NLU data, array of intents
          type: array
        rules:
          description: Rule list
          type: array
        stories:
          description: Rasa Core stories in YAML format
          type: array
        flows:
          description: Rasa Pro flows in YAML format
          type: object
        force:
          type: boolean
          description: Force a model training even if the data has not changed
          example: false
          deprecated: true
        save_to_default_model_directory:
          type: boolean
          description: >-
            If `true` (default) the trained model will be saved in the default
            model directory, if `false` it will be saved in a temporary
            directory
          deprecated: true
    TrainingResult:
      type: string
      format: binary
    TemplateDescription:
      type: object
      properties:
        text:
          type: string
          description: Template text
      required:
        - text
    Error:
      type: object
      properties:
        version:
          type: string
          description: Rasa version
        status:
          type: string
          enum:
            - failure
          description: Status of the requested action
        message:
          type: string
          description: Error message
        reason:
          type: string
          description: Error category
        details:
          type: object
          description: Additional error information
        help:
          type: string
          description: Optional URL to additonal material
        code:
          type: number
          description: HTTP status code
  responses:
    204Callback:
      description: >-
        The incoming request specified a `callback_url` and hence the request
        will return immediately with an empty response. The actual response will
        be sent to the provided `callback_url` via POST request.
    400BadRequest:
      description: Bad Request
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            version: 1.0.0
            status: failure
            reason: BadRequest
            code: 400
    401NotAuthenticated:
      description: User is not authenticated.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            version: 1.0.0
            status: failure
            reason: NotAuthenticated
            message: User is not authenticated to access resource.
            code: 401
    403NotAuthorized:
      description: User has insufficient permission.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            version: 1.0.0
            status: failure
            reason: NotAuthorized
            message: User has insufficient permission to access resource.
            code: 403
    500ServerError:
      description: An unexpected error occurred.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            version: 1.0.0
            status: ServerError
            message: An unexpected error occurred.
            code: 500
  securitySchemes:
    TokenAuth:
      type: apiKey
      in: query
      name: token
      description: >
        A plaintext token to secure your server, specified at startup in the
        argument `--auth-token thisismysecret`
    JWT:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >
        A JWT token that is signed using the JWT secret specified at startup in
        the argument `--jwt-secret thisismysecret`,

        using the `HS256` algorithm.


        The token's payload must contain an object under the `user` key,

        which in turn must contain the `username` and `role` attributes.

        The following is an example payload for a JWT token:


        ```json

        {
            "user": {
                "username": "<sender_id>",
                "role": "user"
            }
        }

        ```


        If the `role` is `admin`, all endpoints are accessible.

        If the `role` is `user`, endpoints with a `sender_id` parameter are only
        accessible

        if the `sender_id` matches the payload's `username` property.


        For the user trackers endpoint (`GET /users/{user_id}/trackers`), you
        should use `user_id` instead of `username` in the payload.

        In this case, the path `user_id` parameter is matched against the
        payload's `username` property. For example:


        ```json

        {
            "user": {
                "username": "<user_id>",
                "role": "user"
            }
        }

        ```

````