Skip to main content
POST
/
api
/
v1
/
llm
/
extract
Typescript (SDK)
import { SDK } from "@meetkai/mka1";

const sdk = new SDK({
  bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});

async function run() {
  const result = await sdk.llm.extract.extract({
    directExtractionRequest: {
      model: "meetkai:functionary-urdu-mini-pak",
      schema: {
        "type": "object",
        "properties": {
          "invoice_number": {
            "type": "string",
          },
          "vendor_name": {
            "type": "string",
          },
          "total_amount": {
            "type": "number",
          },
          "date": {
            "type": "string",
            "format": "date",
          },
        },
        "required": [
          "invoice_number",
          "total_amount",
        ],
      },
      file: "(binary)",
      prompt: "Extract invoice number, vendor, total, and date from this invoice.",
    },
  });

  console.log(result);
}

run();
{
  "success": true,
  "data": {
    "invoice_number": "INV-2024-001",
    "vendor_name": "Acme Corporation",
    "total_amount": 1250,
    "date": "2024-01-15"
  },
  "metadata": {
    "model": "meetkai:functionary-urdu-mini-pak",
    "filename": "invoice.pdf",
    "fileSize": 125000,
    "extractedAt": "2024-01-15T10:30:00Z"
  }
}

Authorizations

Authorization
string
header
required

Authenticate with your MKA1 API key at the API gateway: Authorization: Bearer <mka1-api-key>. For multi-user server-side integrations, also send X-On-Behalf-Of to identify the end user making the request.

Headers

X-On-Behalf-Of
string

Optional external user identifier for multi-user server-side integrations. Use this when acting on behalf of one of your end users.

Body

application/json

Request parameters for direct extraction with an inline schema. Extracts structured data from a file according to the provided JSON Schema definition.

model
string
required

ID of the model to use for extraction. You can use provider:model format or just the model name with a default provider. Vision-capable models are recommended for processing images and PDFs.

Minimum string length: 1
schema
required

JSON Schema object defining the structure of data to extract from the file. Can be provided as a JSON object or a JSON string (for FormData submissions). The model will extract data matching this schema structure.

file
string
required

The file to extract structured data from. Supports various formats including images (PNG, JPG, etc.) and documents (PDF, etc.). The file content will be analyzed by the model.

metadata

Optional metadata providing additional context for the extraction. Can be a JSON object or JSON string. Use this to provide hints, domain knowledge, or additional instructions to improve extraction accuracy.

prompt
string

Optional custom system prompt to guide the extraction process. Use this to provide specific instructions about how to interpret the file or what to prioritize during extraction.

Response

200 - application/json

OK

Response from the extraction endpoint containing the extracted structured data and metadata about the extraction process.

success
boolean
required

Indicates whether the extraction request was successful

metadata
object
required

Metadata about the extraction request and execution

data
any

The extracted structured data conforming to the provided JSON Schema. This is the result of analyzing the file and extracting information according to the schema definition.