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"
}
}Extracts structured data from files using a custom inline JSON schema.
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"
}
}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.
Optional external user identifier for multi-user server-side integrations. Use this when acting on behalf of one of your end users.
Request parameters for direct extraction with an inline schema. Extracts structured data from a file according to the provided JSON Schema definition.
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.
1JSON 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.
Show child attributes
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.
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.
Show child attributes
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.
OK
Response from the extraction endpoint containing the extracted structured data and metadata about the extraction process.
Indicates whether the extraction request was successful
Metadata about the extraction request and execution
Show child attributes
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.
Was this page helpful?