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

# Task Generate

> Endpoint to generate a task from a natural language instruction and a list of API specifications.

Args:
    payload (TaskGenerate): The input containing:
        - `instruction` (str): Natural language prompt describing the intended task.
        - `specs` (List[str]): API spec names to consider when generating the task.

Returns:
    TaskCreate: A structured task object (not persisted), including task name, actions, and metadata.

Raises:
    HTTPException 500: If an error occurs during the generation process.



## OpenAPI

````yaml post /api/task/generate
openapi: 3.1.0
info:
  title: Apigene
  description: Apigene API
  version: 1.0.0
  contact:
    name: Apigene Support
    url: https://app.apigene.ai
    email: support@apigene.ai
servers:
  - url: https://app.apigene.ai
security:
  - BearerAuth: []
paths:
  /api/task/generate:
    post:
      tags:
        - Task
      summary: Task Generate
      description: >-
        Endpoint to generate a task from a natural language instruction and a
        list of API specifications.


        Args:
            payload (TaskGenerate): The input containing:
                - `instruction` (str): Natural language prompt describing the intended task.
                - `specs` (List[str]): API spec names to consider when generating the task.

        Returns:
            TaskCreate: A structured task object (not persisted), including task name, actions, and metadata.

        Raises:
            HTTPException 500: If an error occurs during the generation process.
      operationId: task_generate
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/TaskGenerate'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/TaskCreate-Output'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
      security:
        - BearerAuth: []
components:
  schemas:
    TaskGenerate:
      properties:
        instruction:
          type: string
          title: Instruction
          description: Instruction.
        specs:
          items:
            $ref: '#/components/schemas/SelectedSpecs'
          type: array
          title: Specs
          description: Selected API specs.
      type: object
      required:
        - instruction
        - specs
      title: TaskGenerate
    TaskCreate-Output:
      properties:
        name:
          type: string
          title: Name
          description: The Task name.
        actions:
          items:
            $ref: '#/components/schemas/TaskAction'
          type: array
          title: Actions
        visibility:
          $ref: '#/components/schemas/Visibility'
          description: 'Task visibility: ''private'' (default) or ''public'''
          default: private
        initial_input:
          type: string
          title: Initial Input
          description: The initial user input for the task, default is None
        schedule:
          $ref: '#/components/schemas/Schedule'
          description: Optional schedule information for the task
          default:
            frequency: manual
            hour: '00:00'
            day: Monday
        state:
          $ref: '#/components/schemas/TaskState'
          description: 'Task state: ''enabled'' (default) or ''disabled'''
          default: enabled
        category:
          type: string
          title: Category
          description: Task category
          default: Other
      type: object
      required:
        - name
        - actions
      title: TaskCreate
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    SelectedSpecs:
      properties:
        api_name:
          type: string
          title: Api Name
          description: Name of the API.
        domain_url:
          type: string
          title: Domain Url
          description: API domain url.
      type: object
      required:
        - api_name
        - domain_url
      title: SelectedSpecs
    TaskAction:
      properties:
        api_name:
          type: string
          title: Api Name
          description: Name of the API.
        domain_url:
          type: string
          title: Domain Url
          description: API domain URL.
          default: ''
        user_input:
          type: string
          title: User Input
          description: User input data.
      type: object
      required:
        - api_name
        - user_input
      title: TaskAction
    Visibility:
      type: string
      enum:
        - private
        - public
      title: Visibility
    Schedule:
      properties:
        frequency:
          $ref: '#/components/schemas/ScheduleFrequency'
          description: 'Schedule frequency: ''daily'' or ''weekly'''
        hour:
          type: string
          title: Hour
          description: Hour of the day in 4 digit format to run the task
          default: '00:00'
        day:
          type: string
          title: Day
          description: Day of the week to run the task
          default: Monday
      type: object
      required:
        - frequency
      title: Schedule
    TaskState:
      type: string
      enum:
        - disabled
        - enabled
      title: TaskState
    ValidationError:
      properties:
        loc:
          items:
            anyOf:
              - type: string
              - type: integer
          type: array
          title: Location
        msg:
          type: string
          title: Message
        type:
          type: string
          title: Error Type
      type: object
      required:
        - loc
        - msg
        - type
      title: ValidationError
    ScheduleFrequency:
      type: string
      enum:
        - manual
        - daily
        - weekly
      title: ScheduleFrequency
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        JWT Authorization header using the Bearer scheme. Example:
        'Authorization: Bearer {token}'

````