Class: ReductoAI::Resources::Parse
- Inherits:
-
Object
- Object
- ReductoAI::Resources::Parse
- Includes:
- AsyncPayload
- Defined in:
- lib/reducto_ai/resources/parse.rb
Overview
Each parse operation consumes credits based on document complexity. See Reducto documentation for pricing details.
Parse resource for document parsing operations.
Converts documents (PDFs, images, etc.) into structured formats like Markdown, JSON, or HTML. Supports both synchronous and asynchronous modes.
Instance Method Summary collapse
-
#async(input:, async: nil, **options) ⇒ Hash
Parses a document asynchronously.
-
#initialize(client) ⇒ Parse
constructor
private
A new instance of Parse.
-
#sync(input:, **options) ⇒ Hash
Parses a document synchronously.
Constructor Details
#initialize(client) ⇒ Parse
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Parse.
36 37 38 |
# File 'lib/reducto_ai/resources/parse.rb', line 36 def initialize(client) @client = client end |
Instance Method Details
#async(input:, async: nil, **options) ⇒ Hash
Parses a document asynchronously.
Returns immediately with a job_id. Poll with Jobs#retrieve to get results.
104 105 106 107 108 109 110 111 112 113 |
# File 'lib/reducto_ai/resources/parse.rb', line 104 def async(input:, async: nil, **) raise ArgumentError, "input is required" if input.nil? normalized_input = normalize_input(input) payload = { input: normalized_input } apply_async_payload!(payload, async) payload.merge!(.compact) @client.post("/parse_async", payload) end |
#sync(input:, **options) ⇒ Hash
Parses a document synchronously.
Blocks until parsing completes and returns the full result.
68 69 70 71 72 73 74 |
# File 'lib/reducto_ai/resources/parse.rb', line 68 def sync(input:, **) raise ArgumentError, "input is required" if input.nil? normalized_input = normalize_input(input) payload = { input: normalized_input, ** }.compact @client.post("/parse", payload) end |