> For the complete documentation index, see [llms.txt](https://apps.docs.rootflo.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apps.docs.rootflo.ai/gold-loan-calculator-app/gold-loan-calculator-api-real-time.md).

# Gold Loan Calculator API (Real time)

Use this flow before calculating gold loan values.

First validate image quality. Then estimate item weight.

### Prerequisites

* Rootflo API key
* Rootflo API secret
* Gold Estimate Agent ID

### Authentication

Sign both requests with your Rootflo HMAC credentials.

Use the same authentication process across both APIs.

{% content-ref url="/pages/dd2YKnoHkmgvYrEIYsIj" %}
[Authentication](/authentication.md)
{% endcontent-ref %}

### Step 1: Check image quality

Run the image quality check first.

It returns clarity and overlap scores in real time.

Continue only when the image passes your thresholds.

See [Image Quality API (Real time)](/ai-gold-auditor-app/image-quality-api-real-time.md).

### Step 2: Estimate gold weight

Use this endpoint after the image passes the quality check.

#### Endpoint

* **Method:** `POST`
* **URL:** `https://<base_url>/floware/v2/agents/<agent_id>/inference`

#### Headers

* `X-Rootflo-Signature: {{signature}}`
* `X-Rootflo-Timestamp: {{timestamp}}`
* `X-Rootflo-Key: {{hmac_key}}`

#### Request body

Set `output_json_enabled` to `true`.

```json
{
  "nonce": "{{nonce}}",
  "variables": {},
  "inputs": [
    {
      "role": "user",
      "content": {
        "image_base64": "iVBORw0KGgoAAAANS....",
        "mime_type": "image/png"
      }
    },
    {
      "role": "user",
      "content": "estimate the gold weights in the image"
    }
  ],
  "output_json_enabled": true
}
```

#### Example response

```json
{
  "meta": {
    "status": "success",
    "code": 1,
    "error": null
  },
  "data": {
    "message": "Agent inference completed successfully",
    "data": {
      "result": {
        "items": [
          {
            "name": "ring",
            "weight": 20.6
          },
          {
            "name": "chain",
            "weight": 15.2
          }
        ],
        "has_jewellery": true,
        "has_pen": false,
        "has_pan_card": false
      },
      "agent_id": "be6ad499-3517-40e5-823b-f9460733298a",
      "namespace": "default",
      "execution_time": 7.59
    }
  }
}
```

#### Response fields

* `items` — Detected ornaments in the image.
* `items[].name` — Ornament type, such as `ring` or `chain`.
* `items[].weight` — Estimated ornament weight in grams.
* `has_jewellery` — `true` when jewellery is detected.
* `has_pen` — `true` when a pen is detected.
* `has_pan_card` — `true` when a PAN card is detected.

{% hint style="info" %}
A pen or PAN card must be visible for weight estimation. If neither is detected, `items` is empty.
{% endhint %}

### Recommended flow

1. Run the image quality API.
2. Retake the image if quality fails.
3. Call the weight estimation API after the image passes.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://apps.docs.rootflo.ai/gold-loan-calculator-app/gold-loan-calculator-api-real-time.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
