LlamaParse
LlamaParse is an API created by LlamaIndex to efficiently parse and represent files for efficient retrieval and context augmentation using LlamaIndex frameworks.
LlamaParse directly integrates with LlamaIndex.
Free plan is up to 1000 pages a day. Paid plan is free 7k pages per week + 0.3c per additional page.
There is a sandbox available to test the API https://cloud.llamaindex.ai/parse ↗.
Read below for some quickstart information, or see the full documentation.
Getting Started
First, login and get an api-key from https://cloud.llamaindex.ai/api-key ↗.
Then, make sure you have the latest LlamaIndex version installed.
NOTE: If you are upgrading from v0.9.X, we recommend following our migration guide, as well as uninstalling your previous version first.
pip uninstall llama-index # run this if upgrading from v0.9.x or older
pip install -U llama-index --upgrade --no-cache-dir --force-reinstall
Lastly, install the package:
pip install llama-parse
Now you can run the following to parse your first PDF file:
import nest_asyncio
nest_asyncio.apply()
from llama_parse import LlamaParse
parser = LlamaParse(
api_key="llx-...",
result_type="markdown",
num_workers=4,
verbose=True,
language="en",
)
documents = parser.load_data("./my_file.pdf")
documents = parser.load_data(["./my_file1.pdf", "./my_file2.pdf"])
documents = await parser.aload_data("./my_file.pdf")
documents = await parser.aload_data(["./my_file1.pdf", "./my_file2.pdf"])
Using with file object
You can parse a file object directly:
import nest_asyncio
nest_asyncio.apply()
from llama_parse import LlamaParse
parser = LlamaParse(
api_key="llx-...",
result_type="markdown",
num_workers=4,
verbose=True,
language="en",
)
with open("./my_file1.pdf", "rb") as f:
documents = parser.load_data(f)
with open("./my_file1.pdf", "rb") as f:
file_bytes = f.read()
documents = parser.load_data(file_bytes)
Using with SimpleDirectoryReader
You can also integrate the parser as the default PDF loader in SimpleDirectoryReader
:
import nest_asyncio
nest_asyncio.apply()
from llama_parse import LlamaParse
from llama_index.core import SimpleDirectoryReader
parser = LlamaParse(
api_key="llx-...",
result_type="markdown",
verbose=True,
)
file_extractor = {".pdf": parser}
documents = SimpleDirectoryReader(
"./data", file_extractor=file_extractor
).load_data()
Full documentation for SimpleDirectoryReader
can be found on the LlamaIndex Documentation.
Examples
Several end-to-end indexing examples can be found in the examples folder
Documentation
https://docs.cloud.llamaindex.ai/
Terms of Service
See the Terms of Service Here.