Unstructured-IO / Unstructured-IO/unstructured-api

Calling unstructured api within another api call takes more time

Open
#496 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
951
Forks
192
Avg merge
7d 8h
Merged PRs (30d)
2

Description

Hey, I have a code that uses partition_via_api() function from unstructured to extract images and text. When i run this code from terminal (python3 extractor.py) the overall code completes within 1min. Now, I'm putting the same function in a fastapi endpoint. When the endpoint in called via a request, the same function is triggered, but it takes drastically higher time to make unstructured api call. Any ideas on why this issue or how to solve this?

sample function used:
async def pdf_extracted_images(file_path,filename):

chunks = partition_via_api(
    filename = str(file_path),
    api_key = "api_key", 
    api_url = "https://api.unstructuredapp.io/general/v0/general",
    strategy = "hi_res",
    split_pdf_page = True,
    split_pdf_concurrency_level = 15,
    infer_table_structure = True,
    extract_image_block_types = ["Image"],
    extract_image_block_to_payload = True,
    chunking_strategy = "basic",
    max_characters = 20000,
    combine_text_under_n_chars = 6000,
    new_after_n_chars = 6000,
)
return chunks

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with extractor.py and the pdf_extracted_images function, comparing the direct terminal execution with the FastAPI request path. Trace the partition_via_api call and its request timing in both contexts; done means identifying the cause of the endpoint-specific delay and documenting a reproducible resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
fastapi, python
Domain
api, performance
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.