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

# Suggest Extraction Strategy

> Determine the optimal extraction strategy for a tag based on its name and description.

Returns either 'LLM' (AI-based extraction) or 'REGEX' (pattern-based extraction).

## When to use each strategy

**REGEX** - Use when:
- Values have consistent, predictable formatting (dates, IDs, phone numbers, emails)
- Known exact patterns that repeat predictably
- Structured data with fixed delimiters or formats

**LLM** - Use when:
- Semantic understanding is required
- Values depend on interpreting content, not matching formats
- Classifications, categorizations, sentiment, summaries

## Request Body

| Field              | Type           | Description                                    |
|--------------------|----------------|------------------------------------------------|
| `tag_name`         | `str`          | The name of the tag                            |
| `tag_description`  | `str`          | Description of what the tag captures           |
| `available_values` | `List[str]`    | Optional. Example values to help determine strategy |

## Response

- **200**: Strategy recommendation returned successfully
    - Returns: `{ "strategy": "LLM" }` or `{ "strategy": "REGEX" }`
- **500**: Internal Server Error



## OpenAPI

````yaml /deasy-openapi-stainless.yml post /suggest_strategy
openapi: 3.1.0
info:
  title: FastAPI
  version: 0.1.0
servers:
  - url: /rest/unstructured
security: []
paths:
  /suggest_strategy:
    post:
      tags:
        - Tags
      summary: Suggest Extraction Strategy
      description: >-
        Determine the optimal extraction strategy for a tag based on its name
        and description.


        Returns either 'LLM' (AI-based extraction) or 'REGEX' (pattern-based
        extraction).


        ## When to use each strategy


        **REGEX** - Use when:

        - Values have consistent, predictable formatting (dates, IDs, phone
        numbers, emails)

        - Known exact patterns that repeat predictably

        - Structured data with fixed delimiters or formats


        **LLM** - Use when:

        - Semantic understanding is required

        - Values depend on interpreting content, not matching formats

        - Classifications, categorizations, sentiment, summaries


        ## Request Body


        | Field              | Type           |
        Description                                    |

        |--------------------|----------------|------------------------------------------------|

        | `tag_name`         | `str`          | The name of the
        tag                            |

        | `tag_description`  | `str`          | Description of what the tag
        captures           |

        | `available_values` | `List[str]`    | Optional. Example values to help
        determine strategy |


        ## Response


        - **200**: Strategy recommendation returned successfully
            - Returns: `{ "strategy": "LLM" }` or `{ "strategy": "REGEX" }`
        - **500**: Internal Server Error
      operationId: suggest_strategy_suggest_strategy_post
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/SuggestStrategyRequest'
        required: true
      responses:
        '200':
          description: Successful Response
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/SuggestStrategyResponse'
        '403':
          description: Missing token
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
        '404':
          description: Resource not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
        '422':
          description: Validation Error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPValidationError'
        '429':
          description: Too many requests
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
        '500':
          description: >-
            Internal Server Error. An unexpected error occurred while processing
            the request.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPError'
      security:
        - BasicAuth: []
        - BearerAuth: []
          UserIdAuth: []
      x-codeSamples:
        - lang: Python
          source: |-
            import os
            from unstructured import UnstructuredClient

            client = UnstructuredClient(
                username=os.environ.get("UNSTRUCTURED_USERNAME"),  # This is the default and can be omitted
                password=os.environ.get("UNSTRUCTURED_PASSWORD"),  # This is the default and can be omitted
            )
            response = client.tags.suggest_strategy(
                tag_description="tag_description",
                tag_name="tag_name",
            )
            print(response.strategy)
        - lang: JavaScript
          source: |-
            import UnstructuredClient from 'unstructured-sdk';

            const client = new UnstructuredClient({
              authMethod: 'My Auth Method',
              username: process.env['UNSTRUCTURED_USERNAME'], // This is the default and can be omitted
              password: process.env['UNSTRUCTURED_PASSWORD'], // This is the default and can be omitted
            });

            const response = await client.tags.suggestStrategy({
              tag_description: 'tag_description',
              tag_name: 'tag_name',
            });

            console.log(response.strategy);
components:
  schemas:
    SuggestStrategyRequest:
      properties:
        tag_name:
          type: string
          title: Tag Name
        tag_description:
          type: string
          title: Tag Description
        available_values:
          anyOf:
            - items:
                type: string
              type: array
            - type: 'null'
          title: Available Values
      type: object
      required:
        - tag_name
        - tag_description
      title: SuggestStrategyRequest
      description: Request model for suggesting the optimal extraction strategy for a tag.
    SuggestStrategyResponse:
      properties:
        strategy:
          type: string
          title: Strategy
      type: object
      required:
        - strategy
      title: SuggestStrategyResponse
      description: Response model for tag extraction strategy recommendation.
    HTTPError:
      properties:
        detail:
          type: string
          title: Detail
      type: object
      required:
        - detail
      title: HTTPError
    HTTPValidationError:
      properties:
        detail:
          items:
            $ref: '#/components/schemas/ValidationError'
          type: array
          title: Detail
      type: object
      title: HTTPValidationError
    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
  securitySchemes:
    BasicAuth:
      type: http
      scheme: basic
    BearerAuth:
      type: http
      scheme: bearer
    UserIdAuth:
      type: apiKey
      in: header
      name: X-User-ID

````