from meetkai_mka1 import SDK
with SDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as sdk:
res = sdk.llm.extract.extract_with_schema(schema_id="schema_invoice_123", model="meetkai:functionary-urdu-mini-pak", file={
"file_name": "example.file",
"content": open("example.file", "rb"),
}, prompt="Extract the structured invoice fields.")
# Handle response
print(res)import { SDK } from "@meetkai/mka1";
import { openAsBlob } from "node:fs";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.llm.extract.extractWithSchema({
schemaId: "schema_invoice_123",
requestBody: {
model: "meetkai:functionary-urdu-mini-pak",
file: await openAsBlob("example.file"),
prompt: "Extract the structured invoice fields.",
},
});
console.log(result);
}
run();using MeetKai.MKA1;
using MeetKai.MKA1.Types.Components;
using MeetKai.MKA1.Types.Requests;
var sdk = new SDK(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");
var res = await sdk.Llm.Extract.ExtractWithSchemaAsync(
schemaId: "schema_invoice_123",
body: new ExtractWithSchemaRequestBody() {
Model = "meetkai:functionary-urdu-mini-pak",
File = new ExtractWithSchemaFile() {
FileName = "example.file",
Content = System.IO.File.ReadAllBytes("example.file"),
},
Prompt = "Extract the structured invoice fields.",
}
);
// handle responsecurl --request POST \
--url https://apigw.mka1.com/api/v1/llm/extract/schema/{schema_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form model=meetkai:functionary-urdu-mini-pak \
--form 'prompt=Extract the structured invoice fields.' \
--form file='@example-file'const form = new FormData();
form.append('model', 'meetkai:functionary-urdu-mini-pak');
form.append('prompt', 'Extract the structured invoice fields.');
form.append('file', '(binary)');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://apigw.mka1.com/api/v1/llm/extract/schema/{schema_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apigw.mka1.com/api/v1/llm/extract/schema/{schema_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nmeetkai:functionary-urdu-mini-pak\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nExtract the structured invoice fields.\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n(binary)\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://apigw.mka1.com/api/v1/llm/extract/schema/{schema_id}"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nmeetkai:functionary-urdu-mini-pak\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nExtract the structured invoice fields.\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n(binary)\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://apigw.mka1.com/api/v1/llm/extract/schema/{schema_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nmeetkai:functionary-urdu-mini-pak\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nExtract the structured invoice fields.\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n(binary)\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://apigw.mka1.com/api/v1/llm/extract/schema/{schema_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nmeetkai:functionary-urdu-mini-pak\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nExtract the structured invoice fields.\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n(binary)\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"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",
"schemaId": "schema_invoice_123",
"schemaName": "Invoice Extraction"
}
}Extraer datos utilizando plantilla de esquema guardada
Extrae datos estructurados de archivos utilizando una plantilla de esquema de extracción guardada previamente.
from meetkai_mka1 import SDK
with SDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as sdk:
res = sdk.llm.extract.extract_with_schema(schema_id="schema_invoice_123", model="meetkai:functionary-urdu-mini-pak", file={
"file_name": "example.file",
"content": open("example.file", "rb"),
}, prompt="Extract the structured invoice fields.")
# Handle response
print(res)import { SDK } from "@meetkai/mka1";
import { openAsBlob } from "node:fs";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.llm.extract.extractWithSchema({
schemaId: "schema_invoice_123",
requestBody: {
model: "meetkai:functionary-urdu-mini-pak",
file: await openAsBlob("example.file"),
prompt: "Extract the structured invoice fields.",
},
});
console.log(result);
}
run();using MeetKai.MKA1;
using MeetKai.MKA1.Types.Components;
using MeetKai.MKA1.Types.Requests;
var sdk = new SDK(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");
var res = await sdk.Llm.Extract.ExtractWithSchemaAsync(
schemaId: "schema_invoice_123",
body: new ExtractWithSchemaRequestBody() {
Model = "meetkai:functionary-urdu-mini-pak",
File = new ExtractWithSchemaFile() {
FileName = "example.file",
Content = System.IO.File.ReadAllBytes("example.file"),
},
Prompt = "Extract the structured invoice fields.",
}
);
// handle responsecurl --request POST \
--url https://apigw.mka1.com/api/v1/llm/extract/schema/{schema_id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form model=meetkai:functionary-urdu-mini-pak \
--form 'prompt=Extract the structured invoice fields.' \
--form file='@example-file'const form = new FormData();
form.append('model', 'meetkai:functionary-urdu-mini-pak');
form.append('prompt', 'Extract the structured invoice fields.');
form.append('file', '(binary)');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://apigw.mka1.com/api/v1/llm/extract/schema/{schema_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://apigw.mka1.com/api/v1/llm/extract/schema/{schema_id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nmeetkai:functionary-urdu-mini-pak\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nExtract the structured invoice fields.\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n(binary)\r\n-----011000010111000001101001--",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: multipart/form-data; boundary=---011000010111000001101001"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://apigw.mka1.com/api/v1/llm/extract/schema/{schema_id}"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nmeetkai:functionary-urdu-mini-pak\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nExtract the structured invoice fields.\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n(binary)\r\n-----011000010111000001101001--")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://apigw.mka1.com/api/v1/llm/extract/schema/{schema_id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "multipart/form-data; boundary=---011000010111000001101001")
.body("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nmeetkai:functionary-urdu-mini-pak\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nExtract the structured invoice fields.\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n(binary)\r\n-----011000010111000001101001--")
.asString();require 'uri'
require 'net/http'
url = URI("https://apigw.mka1.com/api/v1/llm/extract/schema/{schema_id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"model\"\r\n\r\nmeetkai:functionary-urdu-mini-pak\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nExtract the structured invoice fields.\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"; filename=\"example-file\"\r\nContent-Type: application/octet-stream\r\n\r\n(binary)\r\n-----011000010111000001101001--"
response = http.request(request)
puts response.read_body{
"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",
"schemaId": "schema_invoice_123",
"schemaName": "Invoice Extraction"
}
}Autorizaciones
Gateway auth: send Authorization: Bearer <mka1-api-key>. For multi-user server-side integrations, you can also send X-On-Behalf-Of: <external-user-id>.
Encabezados
Optional external end-user identifier forwarded by the API gateway.
Parámetros de ruta
El identificador único del esquema de extracción que se utilizará para esta extracción.
Cuerpo
Respuesta
Está bien
Respuesta del punto final de extracción que contiene los datos estructurados extraídos y los metadatos sobre el proceso de extracción.
Indica si la solicitud de extracción fue exitosa.
Metadatos sobre la solicitud de extracción y la ejecución
Show child attributes
Show child attributes
Los datos estructurados extraídos que cumplen con el esquema JSON proporcionado. Este es el resultado de analizar el archivo y extraer información de acuerdo con la definición del esquema.
¿Esta página le ayudó?