v1

API Reference

Everything you need to integrate Empower API in minutes.

Authentication

All API requests require an Authorization header containing your API key as a Bearer token.

curl -X POST https://api.2bempower-u.com/v1/extract \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY" \
  -H "Content-Type: application/json"
Security: Never expose your API key client-side. Always call from your backend server.

POST /v1/extract

Extracts text and structured data from a document image using Gemini 1.5 Flash.

Request Body

FieldTypeRequiredDescription
image_base64stringrequiredBase64-encoded image of the document
mime_typestringoptionalMIME type of the image. Default: image/png
promptstringoptionalCustom extraction prompt. Uses smart default if omitted.

Example Request

curl -X POST https://api.2bempower-u.com/v1/extract \
  -H "Authorization: Bearer sk_live_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "image_base64": "iVBORw0KGgoAAAANSUhEUgAA...",
    "mime_type": "image/png"
  }'

Example Response

{
  "success": true,
  "data": {
    "text": "Invoice #1042\nDate: 2025-01-15\nBill To: Acme Corp\n...",
    "usage": {
      "input_tokens": 987,
      "output_tokens": 261,
      "total_tokens": 1248
    }
  }
}

Error Codes

StatusMeaning
401Invalid or missing API key
400Malformed request body or missing required field
502Upstream AI model error — retry with exponential backoff
500Internal server error

Quick-start (Node.js)

import fs from "fs";

const image = fs.readFileSync("invoice.png");
const base64 = image.toString("base64");

const res = await fetch("https://api.2bempower-u.com/v1/extract", {
  method: "POST",
  headers: {
    "Authorization": "Bearer sk_live_YOUR_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({ image_base64: base64, mime_type: "image/png" }),
});

const data = await res.json();
console.log(data.data.text);