### Install Python Dependencies Source: https://developers.llamaindex.ai/llamaparse/sheets/examples/llama_index Sets up a virtual environment and installs Python dependencies from requirements.txt. ```bash python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate pip install -r requirements.txt ``` -------------------------------- ### Install LlamaCloud SDK (Python) Source: https://developers.llamaindex.ai/llamaparse/cloud-index-v2/getting_started Install the LlamaCloud SDK for Python using pip. ```bash pip install llama-cloud ``` -------------------------------- ### Install LlamaParse SDK and Pandas Source: https://developers.llamaindex.ai/llamaparse/parse/examples/parse_financial_tables Install the necessary libraries for parsing financial documents and data manipulation. ```bash pip install llama-cloud pandas ``` -------------------------------- ### Install llama-cloud SDK and pandas Source: https://developers.llamaindex.ai/llamaparse/parse/examples/parse_charts_pandas Install the necessary Python libraries for LlamaParse and data analysis. ```bash pip install llama-cloud>=1.0 pandas ``` -------------------------------- ### Install RabbitMQ with Helm Source: https://developers.llamaindex.ai/llamaparse/self_hosting/configuration/db_and_queues/overview Installs RabbitMQ using the Bitnami Helm chart. Ensure you have a `rabbitmq.yaml` file for custom configurations. ```bash helm upgrade --install rabbitmq \ oci://registry-1.docker.io/bitnamicharts/rabbitmq \ -f rabbitmq.yaml --wait --timeout 10m ``` -------------------------------- ### TypeScript SDK: Create and Extract File Source: https://developers.llamaindex.ai/llamaparse/extract/guides/extensions This TypeScript example demonstrates how to upload a file and start an extraction job using the LlamaCloud SDK. It configures the extraction with a data schema, tier, and source citation options, and includes a loop to poll for the job's completion status. ```typescript import fs from 'fs'; import LlamaCloud from '@llamaindex/llama-cloud'; const client = new LlamaCloud({ apiKey: 'your_api_key', }); const fileObj = await client.files.create({ file: fs.createReadStream('path/to/your/document.pdf'), purpose: 'extract', }); let job = await client.extract.create({ file_input: fileObj.id, configuration: { data_schema: { /* your extraction schema */ }, tier: 'agentic', cite_sources: true, confidence_scores: true, }, }); // Poll for completion while (!['COMPLETED', 'FAILED', 'CANCELLED'].includes(job.status)) { await new Promise((r) => setTimeout(r, 2000)); job = await client.extract.get(job.id); } ``` -------------------------------- ### Install llama-cloud and zod (TypeScript/JavaScript) Source: https://developers.llamaindex.ai/llamaparse/extract/examples/extract_repeating_entities Install the llama-cloud package and zod for schema validation using npm. ```bash npm install @llamaindex/llama-cloud zod ``` -------------------------------- ### Install PostgreSQL using Helm Source: https://developers.llamaindex.ai/llamaparse/self_hosting/configuration/db_and_queues/overview Use this Helm command to install PostgreSQL. Ensure you have a postgresql.yaml file for custom configurations. ```bash helm upgrade --install postgresql \ oci://registry-1.docker.io/bitnamicharts/postgresql \ -f postgresql.yaml --wait --timeout 10m ``` -------------------------------- ### Install llama-cloud Source: https://developers.llamaindex.ai/llamaparse/parse/examples/parse_granular_bboxes Install the llama-cloud library to interact with the LlamaParse API. Ensure you are using version 1.0 or higher. ```bash pip install llama-cloud>=1.0 httpx ``` -------------------------------- ### Parse Job Start Response Source: https://developers.llamaindex.ai/llamaparse/llamaparse/getting_started Example response when starting a parse job, indicating the job ID and its initial status. ```json { "id": "c0defee1-76a0-42c3-bbed-094e4566b762", "status": "PENDING" } ``` -------------------------------- ### Install LlamaCloud on Azure Source: https://developers.llamaindex.ai/llamaparse/self_hosting/cloud-specific-guides/azure/setup Add the LlamaIndex Helm repository, update it, and install LlamaCloud using a custom values file. Monitor the deployment status. ```bash helm repo add llamaindex https://run-llama.github.io/helm-charts helm repo update helm install llamacloud llamaindex/llamacloud -f azure-values.yaml --namespace llamacloud kubectl get pods --namespace llamacloud -w ``` -------------------------------- ### Install kube-prometheus-stack Helm Chart Source: https://developers.llamaindex.ai/llamaparse/self_hosting/monitoring/monitoring Add the Prometheus Community Helm repository, update it, and install the kube-prometheus-stack chart with a custom values file. ```bash helm repo add prometheus-community https://prometheus-community.github.io/helm-charts helm repo update helm install kube-prometheus-stack prometheus-community/kube-prometheus-stack \ -f kube-prometheus-stack.yaml ``` -------------------------------- ### Download Parquet File using Presigned URL (HTTP) Source: https://developers.llamaindex.ai/llamaparse/sheets Download the Parquet file by making a GET request to the presigned URL obtained in the previous step. The response content is saved directly to a .parquet file. This example also shows how to load and view the first few rows using pandas. ```bash # Step 2: Download the parquet file using the presigned URL curl -X GET "https://s3.amazonaws.com/..." -o region.parquet # Load with pandas python -c "import pandas as pd; df = pd.read_parquet('region.parquet'); print(df.head())" ``` -------------------------------- ### Install LlamaParse and Dependencies Source: https://developers.llamaindex.ai/llamaparse/parse/examples/async_parse_folder Install the necessary Python libraries, including `llama-cloud`, `python-dotenv`, and `requests`, using pip. ```bash pip install llama-cloud python-dotenv requests ``` -------------------------------- ### Example Ingress Status Output Source: https://developers.llamaindex.ai/llamaparse/self_hosting/configuration/ingress Example output from checking the ingress resource status, showing the ingress name, class, hosts, and age. ```text NAME CLASS HOSTS ADDRESS PORTS AGE llamacloud-ingress nginx llamacloud.example 80, 443 10m ``` -------------------------------- ### Example Output of Async Folder Parsing Source: https://developers.llamaindex.ai/llamaparse/parse/examples/async_parse_folder This output shows the console logs during the asynchronous parsing of PDF files. It indicates the number of files found, the start and completion of parsing for each file, and a final summary of the operation. ```text Found 2 PDF files to parse Processing 2 files with max 5 concurrent operations... Starting parse: attention.pdf Starting parse: bert.pdf Started parsing the file under job_id 1a7b8f3b-9119-4e38-954d-b67b8e96b3d6 Started parsing the file under job_id 28123aeb-dd3e-4398-b754-0cb101a3b78b ✓ Completed: attention.pdf (15 pages) ✓ Completed: bert.pdf (16 pages) PARSE SUMMARY Total files: 2 Successful: 2 Failed: 0 Total time: 10.00 seconds Average time per file: 5.00 seconds ``` -------------------------------- ### Install MongoDB using Helm Source: https://developers.llamaindex.ai/llamaparse/self_hosting/configuration/db_and_queues/overview Install MongoDB using Helm. A mongodb.yaml file is required for specific configurations. ```bash helm upgrade --install \ mongodb oci://registry-1.docker.io/bitnamicharts/mongodb \ -f mongodb.yaml --wait --timeout 10m ``` -------------------------------- ### Initialize and Run ResumeBookAgent Source: https://developers.llamaindex.ai/llamaparse/extract/examples/split_and_extract_resume_book Initializes the ResumeBookAgent and runs it with a specified PDF file path. This is the starting point for processing a resume book. ```python agent = ResumeBookAgent(timeout=1000) resp = await agent.run(start_event=StartEvent(file_path="resume_book.pdf")) ``` -------------------------------- ### Install LlamaCloud and OpenAI Libraries Source: https://developers.llamaindex.ai/llamaparse/parse/examples/parse_excel_sheets Install the necessary libraries for LlamaCloud and OpenAI integration. Ensure you are using version 1.0.0b3 or higher for llama-cloud. ```bash !pip install 'llama-cloud>=1.0.0b3' !pip install llama-index-llms-openai ``` -------------------------------- ### Install LlamaCloud SDK (Python) Source: https://developers.llamaindex.ai/llamaparse/classify/examples/classify_contract_types Install the LlamaCloud Python SDK using pip. Ensure you are using version 1.6 or later. ```bash pip install llama-cloud>=1.6 ``` -------------------------------- ### Install Dependencies Source: https://developers.llamaindex.ai/llamaparse/extract/examples/split_and_extract_resume_book Install the necessary LlamaCloud, requests, and LlamaIndex workflows libraries. Ensure you are using llama-cloud version 2.1 or later. ```bash pip install llama-cloud>=2.1 requests llama-index-workflows ``` -------------------------------- ### Install LlamaParse Python SDK Source: https://developers.llamaindex.ai/llamaparse/parse/examples/parse_pdf_outputs Install the LlamaParse Python SDK using pip. Ensure you are using version 1.0 or higher. ```bash pip install llama-cloud>=1.0 ``` -------------------------------- ### List Running Pods After Installation Source: https://developers.llamaindex.ai/llamaparse/self_hosting/installation Command to list pods and their status after installing the LlamaCloud Helm chart. Expected output shows all necessary pods running. ```bash kubectl get pods -n llamacloud ``` -------------------------------- ### Install All LlamaParse Agent Skills Source: https://developers.llamaindex.ai/llamaparse Installs all available LlamaParse agent skills using the skills CLI. Requires Node 18+. ```bash npx skills add run-llama/llamaparse-agent-skills ``` -------------------------------- ### Install Redis using Helm Source: https://developers.llamaindex.ai/llamaparse/self_hosting/configuration/db_and_queues/overview Deploy Redis using Helm. Customize with a redis.yaml file for specific settings. ```bash helm upgrade --install redis \ oci://registry-1.docker.io/bitnamicharts/redis \ -f redis.yaml --wait --timeout 10m ``` -------------------------------- ### Install Llama Cloud SDK Source: https://developers.llamaindex.ai/llamaparse/parse/examples/parse_with_prompts Install the necessary Python package for interacting with the Llama Cloud API. This is a prerequisite for using the parsing functionalities. ```bash pip install llama-cloud ``` -------------------------------- ### Example Response with Images Content Metadata Source: https://developers.llamaindex.ai/llamaparse/parse/guides/retrieving-results Illustrates the structure for 'images_content_metadata', which includes a list of images with individual download URLs. ```json { "job": { ... }, "images_content_metadata": { "total_count": 3, "images": [ { "index": 0, "filename": "image_0.png", "content_type": "image/png", "size_bytes": 12345, "presigned_url": "https://s3.amazonaws.com/..." }, { "index": 1, "filename": "image_1.jpg", "content_type": "image/jpeg", "size_bytes": 23456, "presigned_url": "https://s3.amazonaws.com/..." } ] } } ``` -------------------------------- ### Add Helm Repository and Install Chart Source: https://developers.llamaindex.ai/llamaparse/self_hosting/installation Commands to add the LlamaIndex Helm repository, update the cache, create a namespace, and install the LlamaCloud Helm chart. ```bash # Add the Helm repository helm repo add llamaindex https://run-llama.github.io/helm-charts # Update your local Helm chart cache helm repo update # Create the llamacloud namespace kubectl create ns llamacloud # Install the Helm chart helm install llamacloud llamaindex/llamacloud -f values.yaml --namespace llamacloud ``` -------------------------------- ### Install LlamaParse SDK and TypeScript Runner Source: https://developers.llamaindex.ai/llamaparse/parse/examples/parse_pdf_typescript Install the necessary npm packages for LlamaParse integration and TypeScript development. ```bash npm install @llamaindex/llama-cloud npm install --save-dev tsx typescript @types/node ``` -------------------------------- ### Install External Temporal with Helm Source: https://developers.llamaindex.ai/llamaparse/self_hosting/configuration/db_and_queues/overview Installs an external Temporal instance using the official Temporal Helm chart. Requires a `temporal.yaml` for custom configurations. ```bash helm install --repo https://go.temporal.io/helm-charts \ temporal temporal -f temporal.yaml ``` -------------------------------- ### Install LlamaCloud SDK (TypeScript) Source: https://developers.llamaindex.ai/llamaparse/classify/examples/classify_contract_types Install the LlamaCloud TypeScript SDK using npm. Ensure you are using version 1.6 or later. ```bash npm install @llamaindex/llama-cloud ``` -------------------------------- ### Example Response with Content Fields Source: https://developers.llamaindex.ai/llamaparse/parse/guides/retrieving-results Demonstrates the structure of an API response when requesting content fields like text and markdown. ```json { "job": { "id": "pjb-123", "status": "COMPLETED" }, "text": { "pages": [ { "page_number": 1, "text": "This is the extracted text from page 1..." } ] }, "markdown": { "pages": [ { "page_number": 1, "markdown": "# Heading\n\nThis is markdown content..." } ] } } ``` -------------------------------- ### Example DataFrame Output Source: https://developers.llamaindex.ai/llamaparse/parse/examples/parse_charts_pandas Displays the resulting Pandas DataFrame after loading and processing chart data. ```text DataFrame: Fiscal Year Budget Deficit (Billions of Dollars) \ 0 2020 $3,131.9 1 2021 $2,775.6 2 2022 $1,375.5 3 2023 $1,695.2 4 2024 $1,832.8 Net Operating Cost (Billions of Dollars) 0 $3,841.4 1 $3,094.9 2 $4,171.0 3 $3,417.2 4 $2,425.0 ``` -------------------------------- ### Create and Navigate to Project Directory Source: https://developers.llamaindex.ai/llamaparse/parse/examples/parse_pdf_typescript Initialize a new Node.js project and change into its directory. ```bash mkdir parse-tutorial && cd parse-tutorial ``` -------------------------------- ### File Upload Response Source: https://developers.llamaindex.ai/llamaparse/llamaparse/getting_started Example response after uploading a file, containing the file ID needed for starting a parse job. ```json { "id": "cafe1337-e0dd-4762-b5f5-769fef112558" } ``` -------------------------------- ### Typical Sync Workflow (Python) Source: https://developers.llamaindex.ai/llamaparse/cloud-index-v2/syncing Demonstrates adding a file, triggering a sync, and polling for completion. Ensure the index status returns to 'ready' before resuming operations. ```python import asyncio # Add a new file to the directory with open("new-report.pdf", "rb") as f: file_obj = await client.files.create(file=f, purpose="user_data") await client.beta.directories.files.add( directory_id, file_id=file_obj.id, ) # Trigger a sync await client.beta.indexes.sync(index_id) # Wait for it to finish while True: idx = await client.beta.indexes.get(index_id) status = idx.metadata["status"] if idx.metadata else "unknown" if status == "ready": print("Sync complete!") break elif status == "failed": print("Sync failed:", idx.metadata["error_message"]) break await asyncio.sleep(2) ``` -------------------------------- ### Typical Sync Workflow (TypeScript) Source: https://developers.llamaindex.ai/llamaparse/cloud-index-v2/syncing Demonstrates adding a file, triggering a sync, and polling for completion. Ensure the index status returns to 'ready' before resuming operations. ```typescript import fs from "fs"; // Add a new file const fileObj = await client.files.create({ file: fs.createReadStream("new-report.pdf"), purpose: "user_data", }); await client.beta.directories.files.add(directoryId, { file_id: fileObj.id, }); // Trigger a sync await client.beta.indexes.sync(indexId); // Wait for it to finish while (true) { const idx = await client.beta.indexes.get(indexId); const status = (idx.metadata?.status as string) ?? "unknown"; if (status === "ready") { console.log("Sync complete!"); break; } else if (status === "failed") { console.error("Sync failed:", idx.metadata?.error_message); break; } await new Promise((r) => setTimeout(r, 2000)); } ``` -------------------------------- ### External Temporal Helm Chart Values Source: https://developers.llamaindex.ai/llamaparse/self_hosting/configuration/db_and_queues/overview Example `values.yaml` for an external Temporal Helm chart installation. Configures service accounts, web settings, and persistence. ```yaml serviceAccount: create: true name: temporal-server web: additionalEnv: - name: TEMPORAL_CSRF_COOKIE_INSECURE value: "true" service: port: 80 server: config: namespaces: create: true persistence: default: driver: "sql" sql: driver: postgres12 host: port: 5432 database: temporal user: password: maxConns: 20 maxIdleConns: 20 maxConnLifetime: "1h" visibility: driver: "sql" sql: driver: postgres12 host: port: 5432 database: temporal_visibility user: password: maxConns: 20 maxIdleConns: 20 maxConnLifetime: "1h" cassandra: enabled: false mysql: enabled: false postgresql: enabled: false prometheus: enabled: false grafana: enabled: false elasticsearch: enabled: false schema: createDatabase: enabled: true setup: enabled: true update: enabled: true ``` -------------------------------- ### Centralized LLM Provider Configuration Source: https://developers.llamaindex.ai/llamaparse/self_hosting/configuration/llm_integrations/overview Use `config.llms.providerConfigs` for advanced setups like custom endpoints, multiple credentials, or custom headers. This example shows configurations for OpenAI and Anthropic via a gateway. ```yaml config: llms: providerConfigs: - id: "my-openai-config" provider: "openai" model_id: "openai-gpt-4o" provider_model_name: "@openai/gpt-4o" # Optional: custom model name for gateway credentials: api_key: "sk-..." base_url: "https://api.gateway.com/v1" # Optional: custom endpoint headers: # Optional: custom headers x-api-key: "your-gateway-key" - id: "my-anthropic-config" provider: "anthropic" model_id: "anthropic-sonnet-4.5" provider_model_name: "@anthropic/claude-sonnet-4-5" # Optional: custom model name for gateway credentials: api_key: "sk-ant-..." base_url: "https://api.gateway.com" # Optional: custom endpoint headers: # Optional: custom headers x-api-key: "your-gateway-key" ``` -------------------------------- ### Install TypeScript Dependencies Source: https://developers.llamaindex.ai/llamaparse/sheets/examples/llama_index Installs TypeScript project dependencies using npm, pnpm, or yarn. ```bash npm install # or pnpm install # or yarn install ``` -------------------------------- ### Install Specific Helm Chart Version Source: https://developers.llamaindex.ai/llamaparse/self_hosting/installation Command to install a specific version of the LlamaCloud Helm chart. ```bash helm install llamacloud llamaindex/llamacloud --version x.y.z -f values.yaml --namespace llamacloud ``` -------------------------------- ### Minimal `values.yaml` for Self-Hosting Source: https://developers.llamaindex.ai/llamaparse/self_hosting/installation This configuration sets up essential services like PostgreSQL, MongoDB, RabbitMQ, and Redis. It also enables Temporal for orchestration and configures OpenAI API access. Ensure you replace placeholder values with your actual credentials and keys. ```yaml license: key: postgresql: host: "postgresql" port: "5432" database: "llamacloud" username: password: mongodb: host: "mongodb" port: "27017" username: password: rabbitmq: scheme: "amqp" host: "rabbitmq" port: "5672" username: password: redis: scheme: "redis" host: "redis-master" port: "6379" db: 0 # Deploy Temporal as a subchart (host/port auto-configured) temporal: deploy: true # Temporal subchart configuration (uses same PostgreSQL instance) temporal-subchart: server: config: persistence: default: sql: driver: postgres12 host: "postgresql" port: 5432 database: temporal user: password: visibility: sql: driver: postgres12 host: "postgresql" port: 5432 database: temporal_visibility user: password: config: llms: openAi: apiKey: frontend: enabled: true parseOcr: gpu: true authentication: basicAuth: enabled: true validEmailDomain: "llamaindex.ai" # this is optional, but recommended for production deployments jwtSecret: ``` ```yaml license: key: postgresql: host: "postgresql" port: "5432" database: "llamacloud" username: password: mongodb: host: "mongodb" port: "27017" username: password: rabbitmq: scheme: "amqp" host: "rabbitmq" port: "5672" username: password: redis: scheme: "redis" host: "redis-master" port: "6379" db: 0 # Deploy Temporal as a subchart (host/port auto-configured) temporal: deploy: true # Temporal subchart configuration (uses same PostgreSQL instance) temporal-subchart: server: config: persistence: default: sql: driver: postgres12 host: "postgresql" port: 5432 database: temporal user: password: visibility: sql: driver: postgres12 host: "postgresql" port: 5432 database: temporal_visibility user: password: config: llms: azureOpenAi: secret: "" deployments: [] frontend: enabled: true parseOcr: gpu: true authentication: basicAuth: enabled: true validEmailDomain: "llamaindex.ai" # this is optional, but recommended for production deployments jwtSecret: ``` -------------------------------- ### Create Project Directory Source: https://developers.llamaindex.ai/llamaparse/sheets/examples/llama_index Creates a new project directory and subdirectories for data, scripts, and reports. ```bash mkdir coding-agent-analysis cd coding-agent-analysis # Create directories mkdir data # For extracted parquet files mkdir scripts # For analysis scripts mkdir reports # For output reports ``` -------------------------------- ### Initialize LlamaCloud Client (Python) Source: https://developers.llamaindex.ai/llamaparse/classify/examples/classify_contract_types Initialize the LlamaCloud client in Python. The API key can be set as an environment variable. ```python import os from llama_cloud import LlamaCloud client = LlamaCloud(api_key=os.environ["LLAMA_CLOUD_API_KEY"]) ``` -------------------------------- ### Initialize LlamaCloud Client (Python) Source: https://developers.llamaindex.ai/llamaparse/cloud-index-v2/getting_started Initialize the asynchronous LlamaCloud client with your API key. ```python from llama_cloud import AsyncLlamaCloud client = AsyncLlamaCloud(api_key="") ``` -------------------------------- ### Install llama-cloud Python Package Source: https://developers.llamaindex.ai/llamaparse/extract/examples/extract_repeating_entities Install the llama-cloud Python package using pip. Ensure you are using version 2.1 or later. ```bash pip install llama-cloud>=2.1 ``` -------------------------------- ### Connect to Llama Cloud (Python) Source: https://developers.llamaindex.ai/llamaparse/extract/examples/batch_extraction_cookbook Initialize the Llama Cloud client with your API key for Python. ```python import os from llama_cloud import LlamaCloud, AsyncLlamaCloud client = LlamaCloud(api_key=os.environ["LLAMA_CLOUD_API_KEY"]) ``` -------------------------------- ### Install llama-cloud Python Package Source: https://developers.llamaindex.ai/llamaparse/extract/examples/extract_data_with_citations Install the llama-cloud Python package using pip. This is the first step to using LlamaExtract in Python. ```python !pip install llama-cloud>=2.1 ``` -------------------------------- ### Run Basic Parser Source: https://developers.llamaindex.ai/llamaparse/sheets/examples/coding_agent Execute a basic script to parse budget data with metadata. Ensure the script is executable and the input file is correctly specified. ```bash python3 scripts/parse_budget_with_metadata.py ``` -------------------------------- ### Start Parse Job (REST API) Source: https://developers.llamaindex.ai/llamaparse/llamaparse/getting_started API endpoint to start a parsing job after uploading a file, using a cURL command. ```APIDOC ## Start Parse Job (REST API) ### Description Initiate a parsing job for a previously uploaded file. This endpoint takes the file ID and parsing tier as input and returns a job ID to track the parsing progress. ### Method POST ### Endpoint `/api/v2/parse` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **file_id** (string) - Required - The ID of the file to parse. - **tier** (string) - Required - The parsing tier to use (e.g., 'agentic'). - **version** (string) - Optional - The version of the parser to use (e.g., 'latest'). ### Request Example ```bash curl -X POST \ 'https://api.cloud.llamaindex.ai/api/v2/parse' \ -H 'Accept: application/json' \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer $LLAMA_CLOUD_API_KEY" \ --data '{ "file_id": "", "tier": "agentic", "version": "latest" }' ``` ### Response #### Success Response (200) - **id** (string) - The unique identifier for the parse job. - **status** (string) - The initial status of the job (e.g., 'PENDING'). ``` -------------------------------- ### List Extract and Parse Configurations in Python Source: https://developers.llamaindex.ai/llamaparse/extract/examples/using_saved_configurations Use the client.get method to list all saved configurations, filtering by product type for 'extract_v2' or 'parse_v2'. This is useful for managing and referencing existing configurations programmatically. ```python # List all extract configurations extract_configs = client.get( "/api/v1/beta/configurations", cast_to=dict, options={"params": {"product_type": "extract_v2"}}, ) for cfg in extract_configs.get("data", []): print(f" {cfg['name']} ({cfg['id']})") # List all parse configurations parse_configs = client.get( "/api/v1/beta/configurations", cast_to=dict, options={"params": {"product_type": "parse_v2"}}, ) for cfg in parse_configs.get("data", []): print(f" {cfg['name']} ({cfg['id']})") ``` -------------------------------- ### Install Specific LlamaParse Skill Source: https://developers.llamaindex.ai/llamaparse Installs a specific LlamaParse agent skill, such as 'llamaparse', using the skills CLI. Requires Node 18+. ```bash npx skills add run-llama/llamaparse-agent-skills --skill llamaparse ``` -------------------------------- ### Build a Function Agent Source: https://developers.llamaindex.ai/llamaparse/sheets/examples/llama_index Assemble a FunctionAgent with a specified LLM, tools, and system prompt. This is the foundational step for creating an agent. ```python from llama_index.core.agent import FunctionAgent from llama_index.llms.openai import OpenAI # Setup the LLM to use llm = OpenAI(model="gpt-4.1", api_key=api_key) # Create tools - just one simple code execution tool for now tools = [execute_code] # Configure agent agent = FunctionAgent(tools=tools, llm=llm, system_prompt=system_prompt) ``` -------------------------------- ### Example Response with Metadata Fields Source: https://developers.llamaindex.ai/llamaparse/parse/guides/retrieving-results Shows an API response containing metadata fields, which provide presigned URLs for downloading result files. ```json { "job": { "id": "pjb-123", "status": "COMPLETED" }, "result_content_metadata": { "md": { "size_bytes": 45678, "exists": true, "presigned_url": "https://s3.amazonaws.com/bucket/path/output.md?signature=..." }, "fullText": { "size_bytes": 23456, "exists": true, "presigned_url": "https://s3.amazonaws.com/bucket/path/output.txt?signature=..." } } } ``` -------------------------------- ### Create and Run a Parse Batch Job (Python) Source: https://developers.llamaindex.ai/llamaparse/batches/getting_started This Python snippet demonstrates how to create an ephemeral directory, upload PDF files from a local directory, and then create a batch job to parse these files using the `parse_v2` configuration. It prints the batch ID and its initial status. ```python import asyncio from datetime import datetime, timedelta, timezone from pathlib import Path from llama_cloud import AsyncLlamaCloud client = AsyncLlamaCloud(api_key="") configuration_id = "cfg-PARSE_AGENTIC" expires_at = (datetime.now(timezone.utc) + timedelta(days=2)).isoformat() directory = await client.beta.directories.create( name="invoice-batch", type="ephemeral", expires_at=expires_at, ) for path in Path("./invoices").glob("*.pdf"): await client.beta.directories.files.upload( directory.id, upload_file=path, display_name=path.name, ) batch = await client.batches.create( source_directory_id=directory.id, config={ "job": { "type": "parse_v2", "configuration_id": configuration_id, }, }, ) print(batch.id, batch.status) ``` -------------------------------- ### Example Classification Result Source: https://developers.llamaindex.ai/llamaparse/classify/examples/classify_contract_types This is an example of the output received after a classification job is complete, showing the predicted contract type and the model's reasoning. ```text Classification Result: affiliate_agreements Classification Reason: The document is titled 'MARKETING AFFILIATE AGREEMENT' and repeatedly refers to one party as the 'Marketing Affiliate.' The agreement outlines the rights and obligations of the 'Marketing Affiliate' (MA) to market, sell, and support certain technology products, and details the relationship between the company and the affiliate. There is no mention of joint branding, shared trademarks, or collaborative marketing under both parties' brands, which would be indicative of a co-branding agreement. The content is entirely consistent with an affiliate agreement, where one party (the affiliate) is authorized to market and sell the products of another company, rather than a co-branding arrangement. Therefore, the best match is 'affiliate_agreements' with very high confidence. ``` -------------------------------- ### Install or Upgrade Llama Agents CRDs Source: https://developers.llamaindex.ai/llamaparse/self_hosting/configuration/agent-deployments Use this command to install or upgrade the `llama-agents-crds` chart. Ensure you specify the correct version validated against your LlamaCloud chart. ```bash helm upgrade --install llama-agents-crds \ --version \ oci://registry-1.docker.io/llamaindex/llama-agents-crds ``` -------------------------------- ### Agent Analysis Summary Example Source: https://developers.llamaindex.ai/llamaparse/sheets/examples/coding_agent An example of the output the agent might provide after analyzing a spreadsheet, detailing extraction results, data structure, and formatting patterns. ```text Summary of financial_report_q1.xlsx Analysis 1. Extraction Results (from job_metadata.json:30-38) Extracted Regions: - 1 table region extracted successfully - Sheet name: "Q1 Summary" - Location: A1:D5 - Title: "Q1 Financial Summary" - Description: A financial summary tracking key metrics for Q1 (January-March) 2. Region Data Structure Columns: - Category (text): Financial line items - January (int64): Q1 month 1 values - February (int64): Q1 month 2 values - March (int64): Q1 month 3 values Data: 4 rows × 4 columns containing: - Revenue: $104,818 (Jan), $84,197 (Feb), $111,619 (Mar) - Cost of Goods Sold: $43,106, $46,318, $44,907 - Operating Expenses: $26,630, $20,736, $26,611 - Net Income: $15,251, $34,701, $39,718 All numeric values are properly typed as int64. 3. Cell Metadata Formatting Patterns Formatting Summary: - 16 total cells (4 rows × 4 columns) - No bold formatting detected - No colored cells (all background_color_rgb = 0.0) - No merged cells - No special formatting (dates, percentages, currency markers) - Uniform font size: 11pt throughout - Standard alignment: All cells use default alignment (0.0) Data Types: - 12 Number cells (all financial values) - 4 Text cells (category labels) Key Observations The spreadsheet has a clean, minimal structure with no visual formatting applied. The header row (A1:D1 with "Category", "January", "February", "March") was used to create the DataFrame column names but isn't included in the metadata export since only rows 2-5 (the data rows) are captured. The data is well-structured as a simple financial table ready for analysis without requiring cleanup. ``` -------------------------------- ### Initialize LlamaCloud Client Source: https://developers.llamaindex.ai/llamaparse/parse/guides/recipes Initialize the LlamaCloud client with your API key. You can either pass the key directly or set it as an environment variable. ```python from llama_cloud import LlamaCloud client = LlamaCloud(api_key="llx-...") # or set LLAMA_CLOUD_API_KEY in your env ``` -------------------------------- ### Sync Global Admins API Response Example Source: https://developers.llamaindex.ai/llamaparse/self_hosting/configuration/global-admin This is an example of the JSON response when synchronizing global admin permissions. It shows added, skipped, and erroneous email addresses. ```json { "added": ["admin1@company.com", "earliest-user@company.com"], "skipped": ["admin2@company.com"], "errors": ["nonexistent@company.com"] } ``` -------------------------------- ### Create a Directory (Python) Source: https://developers.llamaindex.ai/llamaparse/cloud-index-v2/getting_started Create a new directory to organize your source files. The directory ID is printed upon successful creation. ```python directory = await client.beta.directories.create( name="my-docs", description="Product documentation", ) print(directory.id) # e.g. "dir-abc123" ``` -------------------------------- ### Basic Spreadsheet Extraction with LlamaSheets SDK (Python) Source: https://developers.llamaindex.ai/llamaparse/sheets Demonstrates uploading a spreadsheet, extracting regions and tables using the LlamaCloud SDK, and downloading the results as Parquet files. Requires the `llama-cloud` and `httpx` libraries. ```python from llama_cloud import LlamaCloud, AsyncLlamaCloud client = LlamaCloud() # Upload a spreadsheet file_obj = client.files.create(file="example_sheet.xlsx", purpose="parse") file_id = file_obj.id # Extract tables from the spreadsheet result = client.beta.sheets.parse( file_id=file_id, config={ "generate_additional_metadata": True, }, ) # Print extracted regions print(result.regions) # Download result parquet files assert result.regions is not None for region in result.regions: assert region.region_id is not None parquet_region_resp = client.beta.sheets.get_result_table( region_type=region.region_type, # type: ignore spreadsheet_job_id=result.id, region_id=region.region_id, ) url = parquet_region_resp.url with httpx.Client() as httpx_client: resp = httpx_client.get(url) with open(f"./downloaded_region_{region.region_id}.parquet", "wb") as f: f.write(resp.content) print(f"Downloaded parquet for region {region.region_id}") parquet_metadata_resp = client.beta.sheets.get_result_table( region_type="cell_metadata", spreadsheet_job_id=result.id, region_id=region.region_id, ) url = parquet_metadata_resp.url with httpx.Client() as httpx_client: resp = httpx_client.get(url) with open(f"./downloaded_region_{region.region_id}_metadata.parquet", "wb") as f: f.write(resp.content) print(f"Downloaded parquet metadata for region {region.region_id}") ``` -------------------------------- ### Install Llama Cloud and Zod for TypeScript Source: https://developers.llamaindex.ai/llamaparse/extract/examples/extract_data_with_citations Install the necessary packages for Llama Cloud and Zod in your TypeScript project using npm. Zod is often used for schema validation. ```bash npm install @llamaindex/llama-cloud zod ```