General Concepts
Sync & Async Client
UiForm offers both synchronous and asynchronous client interfaces, making it versatile for different application needs. The asynchronous client (AsyncUiForm
) is ideal for high-performance, non-blocking applications where multiple tasks run concurrently. For simpler or blocking operations, the synchronous client (UiForm
) provides a straightforward approach.
Here’s how you can use both:
Both clients provide the same core functionality, enabling you to list models, create messages, extract data from documents, and more, with the flexibility to match your application’s concurrency model.
Pagination
Many top-level resources have support for bulk fetches via list API methods. For instance, you can list extraction links, list email addresses, and list logs. These list API methods share a common structure, taking at least these four parameters: limit, order, after, and before.
UiForm utilizes pagination via the after and before parameters. Both parameters take an existing object ID value and return objects in either descending or ascending order by creation time.
Idempotency
The UiForm API supports idempotency which guarantees that performing the same operation multiple times will have the same result as if the operation were performed only once. This is handy in situations where you may need to retry a request due to a failure or prevent accidental duplicate requests from creating more than one resource.
To achieve idempotency, you can add Idempotency-Key request header to any UiForm API request with a unique string as the value. Each subsequent request matching this unique string will return the same response. We suggest using v4 UUIDs for idempotency keys to avoid collisions.
Idempotency keys expire after 24 hours. The UiForm API will generate a new response if you submit a request with an expired key.
Rate Limits
UiForm implements rate limiting to ensure stable service for all users. The API uses a rolling window rate limit with the following configuration:
- 300 requests per 60-second window
- Applies across the following API endpoints:
POST /v1/documents/extractions
POST /v1/documents/create_messages
When you exceed the rate limit, the API will return a 429 Too Many Requests
response. The response headers will include:
For high-volume applications, we can provide a dedicated plan. Contact us for more information.
Modality
LLM works with text and image data. UiForm converts documents into different modalities, based on the document type.
Native modalities
Here are the list of native modalities supported by UiForm:
You can also use the modality
parameter to specify the modality of the document and override the default modality.
Image Settings
When processing images, several factors can affect the LLM’s ability to accurately interpret and extract information. The image_settings parameter allows you to tune images settings to improve extraction quality.
API Reference
Image preprocessing operations to optimize document analysis.
Matching JSON Objects with an internal database
Structured generation will output JSON objects. To match these JSON objects with objects from an internal database, we recommend you to use the Levenshtein distance. The steps are the following:
Normalize the values
Normalize the values of the JSON object by:
- Flattening nested values
- Removing all spacing
- Removing accents This makes it match the format in the internal database.
Compare using Levenshtein distance
Compare the normalized values using the Levenshtein distance algorithm to find matches.
Here is a python example: