#!/bin/bash
set -e

API_KEY="a1a09aad41aa43abbe23122fa1996544"
ENDPOINT="https://api.clarifai.com/v2/users/deepseek-ai/apps/deepseek-ocr/models/DeepSeek-OCR/versions/c52cf7da9b1c4095b07e2a1ccb842811/outputs"

B64=$(base64 001.jpg | tr -d '\n')

JSON=$(jq -n \
    --arg b64 "$B64" \
    '{
        inputs: [
            {
                data: {
                    image: {
                        base64: $b64
                    },
                    text: "Extract all text"
                }
            }
        ]
    }')

response=$(curl -s -X POST "$ENDPOINT" \
    -H "Authorization: Key $API_KEY" \
    -H "Content-Type: application/json" \
    -d "$JSON")

echo "$response" | jq .