Extract
Extraer datos estructurados con esquema JSON en línea
Extrae datos estructurados de archivos utilizando un esquema JSON en línea personalizado.
POST
/
api
/
v1
/
llm
/
extract
CSharp (SDK)
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.ExtractAsync(body: new ExtractRequestBody() {
Model = "meetkai:functionary-urdu-mini-pak",
Schema = "[object Object]",
File = new ExtractFile() {
FileName = "example.file",
Content = System.IO.File.ReadAllBytes("example.file"),
},
Prompt = "Extract invoice number, vendor, total, and date from this invoice.",
});
// handle responsefrom meetkai_mka1 import SDK
with SDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as sdk:
res = sdk.llm.extract.extract(model="meetkai:functionary-urdu-mini-pak", schema="[object Object]", file={
"file_name": "example.file",
"content": open("example.file", "rb"),
}, prompt="Extract invoice number, vendor, total, and date from this invoice.")
# 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.extract({
requestBody: {
model: "meetkai:functionary-urdu-mini-pak",
schema: "[object Object]",
file: await openAsBlob("example.file"),
prompt: "Extract invoice number, vendor, total, and date from this invoice.",
},
});
console.log(result);
}
run();package main
import(
"context"
mka1 "github.com/MeetKai/mka1-sdks/go"
"os"
"github.com/MeetKai/mka1-sdks/go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := mka1.New(
mka1.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
example, fileErr := os.Open("example.file")
if fileErr != nil {
panic(fileErr)
}
res, err := s.Llm.Extract.Extract(ctx, operations.ExtractRequestBody{
Model: "meetkai:functionary-urdu-mini-pak",
Schema: "[object Object]",
File: operations.ExtractFile{
FileName: "example.file",
Content: example,
},
Prompt: mka1.Pointer("Extract invoice number, vendor, total, and date from this invoice."),
}, nil)
if err != nil {
log.Fatal(err)
}
if res.ExtractionResponse != nil {
// handle response
}
}curl --request POST \
--url https://apigw.mka1.com/api/v1/llm/extract \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form model=meetkai:functionary-urdu-mini-pak \
--form '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"
]
}' \
--form 'prompt=Extract invoice number, vendor, total, and date from this invoice.' \
--form file=@example-fileconst form = new FormData();
form.append('model', 'meetkai:functionary-urdu-mini-pak');
form.append('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"
]
}');
form.append('prompt', 'Extract invoice number, vendor, total, and date from this invoice.');
form.append('file', '(binary)');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://apigw.mka1.com/api/v1/llm/extract', 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",
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=\"schema\"\r\n\r\n{\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"invoice_number\": {\r\n \"type\": \"string\"\r\n },\r\n \"vendor_name\": {\r\n \"type\": \"string\"\r\n },\r\n \"total_amount\": {\r\n \"type\": \"number\"\r\n },\r\n \"date\": {\r\n \"type\": \"string\",\r\n \"format\": \"date\"\r\n }\r\n },\r\n \"required\": [\r\n \"invoice_number\",\r\n \"total_amount\"\r\n ]\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nExtract invoice number, vendor, total, and date from this invoice.\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;
}HttpResponse<String> response = Unirest.post("https://apigw.mka1.com/api/v1/llm/extract")
.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=\"schema\"\r\n\r\n{\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"invoice_number\": {\r\n \"type\": \"string\"\r\n },\r\n \"vendor_name\": {\r\n \"type\": \"string\"\r\n },\r\n \"total_amount\": {\r\n \"type\": \"number\"\r\n },\r\n \"date\": {\r\n \"type\": \"string\",\r\n \"format\": \"date\"\r\n }\r\n },\r\n \"required\": [\r\n \"invoice_number\",\r\n \"total_amount\"\r\n ]\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nExtract invoice number, vendor, total, and date from this invoice.\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")
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=\"schema\"\r\n\r\n{\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"invoice_number\": {\r\n \"type\": \"string\"\r\n },\r\n \"vendor_name\": {\r\n \"type\": \"string\"\r\n },\r\n \"total_amount\": {\r\n \"type\": \"number\"\r\n },\r\n \"date\": {\r\n \"type\": \"string\",\r\n \"format\": \"date\"\r\n }\r\n },\r\n \"required\": [\r\n \"invoice_number\",\r\n \"total_amount\"\r\n ]\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nExtract invoice number, vendor, total, and date from this invoice.\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",
"file_size": 125000,
"extracted_at": "2024-01-15T10:30:00Z"
}
}Autorizaciones
Cuerpo
multipart/form-data
Respuesta
200 - application/json
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.
¿Esta página le ayudó?
⌘I
CSharp (SDK)
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.ExtractAsync(body: new ExtractRequestBody() {
Model = "meetkai:functionary-urdu-mini-pak",
Schema = "[object Object]",
File = new ExtractFile() {
FileName = "example.file",
Content = System.IO.File.ReadAllBytes("example.file"),
},
Prompt = "Extract invoice number, vendor, total, and date from this invoice.",
});
// handle responsefrom meetkai_mka1 import SDK
with SDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as sdk:
res = sdk.llm.extract.extract(model="meetkai:functionary-urdu-mini-pak", schema="[object Object]", file={
"file_name": "example.file",
"content": open("example.file", "rb"),
}, prompt="Extract invoice number, vendor, total, and date from this invoice.")
# 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.extract({
requestBody: {
model: "meetkai:functionary-urdu-mini-pak",
schema: "[object Object]",
file: await openAsBlob("example.file"),
prompt: "Extract invoice number, vendor, total, and date from this invoice.",
},
});
console.log(result);
}
run();package main
import(
"context"
mka1 "github.com/MeetKai/mka1-sdks/go"
"os"
"github.com/MeetKai/mka1-sdks/go/models/operations"
"log"
)
func main() {
ctx := context.Background()
s := mka1.New(
mka1.WithSecurity("<YOUR_BEARER_TOKEN_HERE>"),
)
example, fileErr := os.Open("example.file")
if fileErr != nil {
panic(fileErr)
}
res, err := s.Llm.Extract.Extract(ctx, operations.ExtractRequestBody{
Model: "meetkai:functionary-urdu-mini-pak",
Schema: "[object Object]",
File: operations.ExtractFile{
FileName: "example.file",
Content: example,
},
Prompt: mka1.Pointer("Extract invoice number, vendor, total, and date from this invoice."),
}, nil)
if err != nil {
log.Fatal(err)
}
if res.ExtractionResponse != nil {
// handle response
}
}curl --request POST \
--url https://apigw.mka1.com/api/v1/llm/extract \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: multipart/form-data' \
--form model=meetkai:functionary-urdu-mini-pak \
--form '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"
]
}' \
--form 'prompt=Extract invoice number, vendor, total, and date from this invoice.' \
--form file=@example-fileconst form = new FormData();
form.append('model', 'meetkai:functionary-urdu-mini-pak');
form.append('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"
]
}');
form.append('prompt', 'Extract invoice number, vendor, total, and date from this invoice.');
form.append('file', '(binary)');
const options = {method: 'POST', headers: {Authorization: 'Bearer <token>'}};
options.body = form;
fetch('https://apigw.mka1.com/api/v1/llm/extract', 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",
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=\"schema\"\r\n\r\n{\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"invoice_number\": {\r\n \"type\": \"string\"\r\n },\r\n \"vendor_name\": {\r\n \"type\": \"string\"\r\n },\r\n \"total_amount\": {\r\n \"type\": \"number\"\r\n },\r\n \"date\": {\r\n \"type\": \"string\",\r\n \"format\": \"date\"\r\n }\r\n },\r\n \"required\": [\r\n \"invoice_number\",\r\n \"total_amount\"\r\n ]\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nExtract invoice number, vendor, total, and date from this invoice.\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;
}HttpResponse<String> response = Unirest.post("https://apigw.mka1.com/api/v1/llm/extract")
.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=\"schema\"\r\n\r\n{\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"invoice_number\": {\r\n \"type\": \"string\"\r\n },\r\n \"vendor_name\": {\r\n \"type\": \"string\"\r\n },\r\n \"total_amount\": {\r\n \"type\": \"number\"\r\n },\r\n \"date\": {\r\n \"type\": \"string\",\r\n \"format\": \"date\"\r\n }\r\n },\r\n \"required\": [\r\n \"invoice_number\",\r\n \"total_amount\"\r\n ]\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nExtract invoice number, vendor, total, and date from this invoice.\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")
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=\"schema\"\r\n\r\n{\r\n \"type\": \"object\",\r\n \"properties\": {\r\n \"invoice_number\": {\r\n \"type\": \"string\"\r\n },\r\n \"vendor_name\": {\r\n \"type\": \"string\"\r\n },\r\n \"total_amount\": {\r\n \"type\": \"number\"\r\n },\r\n \"date\": {\r\n \"type\": \"string\",\r\n \"format\": \"date\"\r\n }\r\n },\r\n \"required\": [\r\n \"invoice_number\",\r\n \"total_amount\"\r\n ]\r\n}\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"prompt\"\r\n\r\nExtract invoice number, vendor, total, and date from this invoice.\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",
"file_size": 125000,
"extracted_at": "2024-01-15T10:30:00Z"
}
}