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

# Create Runnable

> Create a new runnable

Create a new runnable with the specified configuration. The runnable can be a prompt, flow, or agent.

The `config_content_parsed` field must match the schema for the specified `config_content_type`:

* For `prompt` type: Must follow the `PromptRunnable` schema
* For `flow` type: Must follow the `FlowRunnable` schema
* For `agent` type: Must follow the `AgentRunnable` schema

The `config_content_sha256` field should be the SHA-256 hash of the `config_content` field.


## OpenAPI

````yaml POST /v1/runnables
openapi: 3.1.0
info:
  title: re-factor API Reference
  version: 1.0.0
  description: API specification for re-factor system based on schema definitions
servers: []
security:
  - BearerAuth: []
paths:
  /v1/runnables:
    post:
      summary: Create a new runnable
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Runnable'
      responses:
        '201':
          description: Created runnable
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Runnable'
components:
  schemas:
    Runnable:
      type: object
      required:
        - id
        - account_id
        - name
        - config_content
        - config_content_parsed
        - config_content_type
        - config_content_sha256
        - created_at
        - updated_at
      properties:
        id:
          type: string
          format: uuid
          description: The unique identifier for the runnable
        account_id:
          type: string
          description: The account ID that owns this runnable
        name:
          type: string
          description: The name of the runnable
        description:
          type: string
          description: Optional description of the runnable
        config_content:
          type: string
          description: The raw configuration content
        config_content_parsed:
          oneOf:
            - $ref: '#/components/schemas/CompletionRunnable'
            - $ref: '#/components/schemas/FlowRunnable'
            - $ref: '#/components/schemas/AgentRunnable'
          description: The parsed configuration content
        config_content_type:
          type: string
          enum:
            - prompt
            - flow
            - agent
          description: The type of runnable configuration
        config_content_sha256:
          type: string
          description: SHA256 hash of the configuration content
        created_by:
          type: string
          description: The ID of the user who created this runnable
        created_at:
          type: string
          format: date-time
          description: When the runnable was created
        updated_at:
          type: string
          format: date-time
          description: When the runnable was last updated
        tags:
          type: array
          items:
            type: string
          description: Optional tags for the runnable
    CompletionRunnable:
      allOf:
        - $ref: '#/components/schemas/BaseRunnable'
        - type: object
          required:
            - type
            - prompt
          properties:
            type:
              type: string
              enum:
                - prompt
            prompt:
              $ref: '#/components/schemas/BasePrompt'
    FlowRunnable:
      allOf:
        - $ref: '#/components/schemas/BaseRunnable'
        - type: object
          required:
            - type
            - tasks
          properties:
            type:
              type: string
              enum:
                - flow
            tasks:
              type: array
              items: b1abfff2-df63-4237-82f1-08c83cccd6ff
    AgentRunnable:
      allOf:
        - $ref: '#/components/schemas/BaseRunnable'
        - type: object
          required:
            - type
            - instructions
          properties:
            type:
              type: string
              enum:
                - agent
            instructions:
              type: string
              description: The instructions for the agent
    BaseRunnable:
      type: object
      required:
        - name
        - type
      properties:
        name:
          type: string
          minLength: 2
          description: The name of the runnable
        description:
          type: string
        type:
          type: string
          enum:
            - prompt
            - flow
            - agent
          description: >-
            The type of the runnable. Must be one of "prompt", "flow", or
            "agent".
        llms:
          type: array
          items:
            $ref: '#/components/schemas/LLMConfig'
          minItems: 1
          description: The LLMs configurations for the runnable
        inputs:
          type: array
          items:
            $ref: '#/components/schemas/RunnableInput'
          description: The inputs for the runnable
        schemas:
          type: object
          additionalProperties: true
          description: The schemas for the runnable
    BasePrompt:
      type: object
      properties:
        system:
          type: string
          description: The system message to use for the prompt
        messages:
          type: array
          items:
            oneOf:
              - $ref: '#/components/schemas/UserMessage'
              - $ref: '#/components/schemas/AssistantMessage'
    LLMConfig:
      type: object
      required:
        - name
        - provider
        - model
      properties:
        name:
          type: string
          minLength: 1
        is_default:
          type: boolean
        provider:
          $ref: '#/components/schemas/LLMProvidersEnum'
        model:
          type: string
          minLength: 1
          description: The model to use for the LLM
        params:
          type: object
          additionalProperties: true
    RunnableInput:
      type: object
      required:
        - name
        - description
        - type
      properties:
        name:
          type: string
          minLength: 2
          description: The name of the input. Must be unique within the runnable
        description:
          type: string
          minLength: 1
          description: The description of the input
        type:
          type: string
          enum:
            - text
            - file
            - json
          description: The type of the input
        mime_types:
          type: array
          items:
            type: string
          default:
            - '*/*'
          description: The mime types of the input
        transforms:
          type: array
          items:
            $ref: '#/components/schemas/RunnableInputTransform'
          default: []
        required:
          type: boolean
          default: true
        metadata:
          type: object
          properties:
            schema:
              type: object
              description: JSON Schema v7 object
            required:
              type: boolean
              default: false
    UserMessage:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - user
        content:
          oneOf:
            - type: string
            - type: object
              required:
                - type
              oneOf:
                - type: object
                  required:
                    - type
                    - text
                  properties:
                    type:
                      type: string
                      enum:
                        - text
                    text:
                      type: string
                - type: object
                  required:
                    - type
                    - data
                    - mimeType
                  properties:
                    type:
                      type: string
                      enum:
                        - file
                    data:
                      type: string
                      description: base64-encoded string or URL
                    mimeType:
                      type: string
                - type: object
                  required:
                    - type
                    - image
                    - mimeType
                  properties:
                    type:
                      type: string
                      enum:
                        - image
                    image:
                      type: string
                      description: base64-encoded string or URL
                    mimeType:
                      type: string
    AssistantMessage:
      type: object
      required:
        - role
        - content
      properties:
        role:
          type: string
          enum:
            - assistant
        content:
          type: string
    LLMProvidersEnum:
      type: string
      enum:
        - openai
        - anthropic
        - google
        - google-vertex
        - azure
        - amazon-bedrock
        - xai
      description: The provider to use for LLM access
    RunnableInputTransform:
      type: object
      required:
        - type
      properties:
        name:
          type: string
          minLength: 2
          description: The name of the transform output
        type:
          type: string
          enum:
            - ocr
            - extract_text
            - convert_to_pdf
            - convert_to_image
          description: The type of transform to perform
        provider:
          type: string
          description: The provider to use for the transform
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT

````