Skip to main content
Document extraction has always been a fascinating challenge. Over the years, advancements in AI have transformed this domain, making it easier to tackle even the most complex use cases. Using tools like Orq, extracting structured data from documents is now both efficient and practical. This cookbook demonstrates how to use Orq for processing PDF invoices by sending them directly to the model as native file attachments and extracting actionable insights. To get started, you’ll need to sign up for an Orq account if you haven’t already. Additionally, we’ve prepared a Google Colab file that you can copy and run right away, allowing you to quickly experiment with document processing after replacing your API key. Step 1: Setting Up the Environment The first step is ensuring the environment is ready. Installing the Orq SDK is quick and straightforward.
Step 2: Identity Tracking (Optional) Identities in Orq.ai help track user interactions and API usage across your application. They can represent users, teams, or projects and enable better analytics and budget management. Create an Identity through the AI Studio:
  1. Go to Identity Analytics in your workspace
  2. Click Create an Identity
  3. Add the user details (name, email, external ID)
  4. Set optional metadata and budget limits
Learn more about creating identities, see Creating an Identity. Step 3: Connecting to Orq Interacting with Orq’s platform starts with client initialization.
Step 4: Locating the PDF Files In this case, we have a few PDF files stored in a Google Drive folder that will be used for demonstration. You can easily replace these with your own files to suit your use case.
Step 5: Deploying for Data Extraction To ensure consistent and structured outputs from the data extraction process, the GPT-4o model can be configured to adhere to a predefined JSON schema. By specifying the schema, the model is guided to generate results in a precise format, reducing ambiguity and ensuring compatibility with downstream systems. Below is an example schema designed for extracting key fields from receipts, including transaction date, vendor name, and payment details. The schema enforces strict adherence, with required fields and specific data types for each property. This approach ensures that outputs are well-structured and can be directly integrated into applications or databases for further analysis, reporting, or automation. Leveraging this JSON schema with the GPT-4o model enhances the reliability of the extraction process, making it an invaluable tool for handling structured data tasks. This is the prompt in Orq.ai:
This is the JSON Schema that helps generate the structured output:
Next, invoke a pre-trained deployment to extract structured data from the invoices. Each PDF is read from disk, base64-encoded, and sent directly to the model as a native file content part — no upload step required. This works with OpenAI, Anthropic, and Google Gemini models.
Feedback Collection (Optional) Feedback in Orq.ai helps track response quality and identify areas for improvement. You can collect user ratings, defect classifications, and corrections to continuously enhance your application. Provide feedback through the AI Studio:
  1. Go to Logs in your workspace
  2. Find the specific deployment invocation
  3. Use the feedback interface to rate responses
  4. Add defect classifications or corrections as needed
What’s Next? Orq’s tools provide robust capabilities for extracting structured data from unstructured PDF documents. With this workflow, you can:
  • Scale Data Processing: Adapt the workflow to handle larger batches of PDF files or seamlessly integrate it into your existing systems.
  • Refine Extraction Outputs: Leverage Orq’s deployment configurations to fine-tune the extraction process for specific document formats, layouts, or fields.
  • Automate End-to-End Workflows: Combine this process with automated pipelines to optimize tasks such as invoice management, financial reporting, or compliance monitoring.
By transforming unstructured PDF data into actionable insights, Orq empowers businesses to streamline operations, improve decision-making, and unlock new efficiencies with ease.