from meetkai_mka1 import SDK
with SDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as sdk:
res = sdk.llm.extract.create_schema(name="Invoice Extraction", 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",
],
}, description="Schema for extracting invoice data from PDF documents", metadata={
"document_type": "invoice",
})
# Handle response
print(res)import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.llm.extract.createSchema({
extractionSchema: {
name: "Invoice Extraction",
description: "Schema for extracting invoice data from PDF documents",
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",
],
},
metadata: {
"document_type": "invoice",
},
},
});
console.log(result);
}
run();using MeetKai.MKA1;
using MeetKai.MKA1.Types.Components;
using System.Collections.Generic;
var sdk = new SDK(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");
var res = await sdk.Llm.Extract.CreateSchemaAsync(body: new ExtractionSchema() {
Name = "Invoice Extraction",
Description = "Schema for extracting invoice data from PDF documents",
Schema = new Dictionary<string, object>() {
{ "type", "object" },
{ "properties", new Dictionary<string, object>() {
{ "invoice_number", new Dictionary<string, object>() {
{ "type", "string" },
} },
{ "vendor_name", new Dictionary<string, object>() {
{ "type", "string" },
} },
{ "total_amount", new Dictionary<string, object>() {
{ "type", "number" },
} },
{ "date", new Dictionary<string, object>() {
{ "type", "string" },
{ "format", "date" },
} },
} },
{ "required", new List<object>() {
"invoice_number",
"total_amount",
} },
},
Metadata = new Dictionary<string, object>() {
{ "document_type", "invoice" },
},
});
// handle responsecurl --request POST \
--url https://apigw.mka1.com/api/v1/llm/extract/schema \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Invoice Extraction",
"description": "Esquema para extrair dados de faturas de documentos PDF",
"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"
]
},
"metadata": {
"document_type": "invoice"
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Invoice Extraction',
description: 'Esquema para extrair dados de faturas de documentos PDF',
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']
},
metadata: {document_type: 'invoice'}
})
};
fetch('https://apigw.mka1.com/api/v1/llm/extract/schema', 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",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Invoice Extraction',
'description' => 'Esquema para extrair dados de faturas de documentos PDF',
'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'
]
],
'metadata' => [
'document_type' => 'invoice'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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"
payload := strings.NewReader("{\n \"name\": \"Invoice Extraction\",\n \"description\": \"Esquema para extrair dados de faturas de documentos PDF\",\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"invoice_number\": {\n \"type\": \"string\"\n },\n \"vendor_name\": {\n \"type\": \"string\"\n },\n \"total_amount\": {\n \"type\": \"number\"\n },\n \"date\": {\n \"type\": \"string\",\n \"format\": \"date\"\n }\n },\n \"required\": [\n \"invoice_number\",\n \"total_amount\"\n ]\n },\n \"metadata\": {\n \"document_type\": \"invoice\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Invoice Extraction\",\n \"description\": \"Esquema para extrair dados de faturas de documentos PDF\",\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"invoice_number\": {\n \"type\": \"string\"\n },\n \"vendor_name\": {\n \"type\": \"string\"\n },\n \"total_amount\": {\n \"type\": \"number\"\n },\n \"date\": {\n \"type\": \"string\",\n \"format\": \"date\"\n }\n },\n \"required\": [\n \"invoice_number\",\n \"total_amount\"\n ]\n },\n \"metadata\": {\n \"document_type\": \"invoice\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apigw.mka1.com/api/v1/llm/extract/schema")
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"] = 'application/json'
request.body = "{\n \"name\": \"Invoice Extraction\",\n \"description\": \"Esquema para extrair dados de faturas de documentos PDF\",\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"invoice_number\": {\n \"type\": \"string\"\n },\n \"vendor_name\": {\n \"type\": \"string\"\n },\n \"total_amount\": {\n \"type\": \"number\"\n },\n \"date\": {\n \"type\": \"string\",\n \"format\": \"date\"\n }\n },\n \"required\": [\n \"invoice_number\",\n \"total_amount\"\n ]\n },\n \"metadata\": {\n \"document_type\": \"invoice\"\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "schema_invoice_123",
"name": "Invoice Extraction",
"description": "Schema for extracting invoice data from PDF documents",
"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"
]
},
"metadata": {
"document_type": "invoice"
},
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:30:00Z"
}
}Criar modelo de esquema de extração reutilizável
Cria e armazena um modelo de esquema JSON reutilizável para extração de dados estruturados.
from meetkai_mka1 import SDK
with SDK(
bearer_auth="<YOUR_BEARER_TOKEN_HERE>",
) as sdk:
res = sdk.llm.extract.create_schema(name="Invoice Extraction", 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",
],
}, description="Schema for extracting invoice data from PDF documents", metadata={
"document_type": "invoice",
})
# Handle response
print(res)import { SDK } from "@meetkai/mka1";
const sdk = new SDK({
bearerAuth: "<YOUR_BEARER_TOKEN_HERE>",
});
async function run() {
const result = await sdk.llm.extract.createSchema({
extractionSchema: {
name: "Invoice Extraction",
description: "Schema for extracting invoice data from PDF documents",
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",
],
},
metadata: {
"document_type": "invoice",
},
},
});
console.log(result);
}
run();using MeetKai.MKA1;
using MeetKai.MKA1.Types.Components;
using System.Collections.Generic;
var sdk = new SDK(bearerAuth: "<YOUR_BEARER_TOKEN_HERE>");
var res = await sdk.Llm.Extract.CreateSchemaAsync(body: new ExtractionSchema() {
Name = "Invoice Extraction",
Description = "Schema for extracting invoice data from PDF documents",
Schema = new Dictionary<string, object>() {
{ "type", "object" },
{ "properties", new Dictionary<string, object>() {
{ "invoice_number", new Dictionary<string, object>() {
{ "type", "string" },
} },
{ "vendor_name", new Dictionary<string, object>() {
{ "type", "string" },
} },
{ "total_amount", new Dictionary<string, object>() {
{ "type", "number" },
} },
{ "date", new Dictionary<string, object>() {
{ "type", "string" },
{ "format", "date" },
} },
} },
{ "required", new List<object>() {
"invoice_number",
"total_amount",
} },
},
Metadata = new Dictionary<string, object>() {
{ "document_type", "invoice" },
},
});
// handle responsecurl --request POST \
--url https://apigw.mka1.com/api/v1/llm/extract/schema \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "Invoice Extraction",
"description": "Esquema para extrair dados de faturas de documentos PDF",
"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"
]
},
"metadata": {
"document_type": "invoice"
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'Invoice Extraction',
description: 'Esquema para extrair dados de faturas de documentos PDF',
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']
},
metadata: {document_type: 'invoice'}
})
};
fetch('https://apigw.mka1.com/api/v1/llm/extract/schema', 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",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'Invoice Extraction',
'description' => 'Esquema para extrair dados de faturas de documentos PDF',
'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'
]
],
'metadata' => [
'document_type' => 'invoice'
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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"
payload := strings.NewReader("{\n \"name\": \"Invoice Extraction\",\n \"description\": \"Esquema para extrair dados de faturas de documentos PDF\",\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"invoice_number\": {\n \"type\": \"string\"\n },\n \"vendor_name\": {\n \"type\": \"string\"\n },\n \"total_amount\": {\n \"type\": \"number\"\n },\n \"date\": {\n \"type\": \"string\",\n \"format\": \"date\"\n }\n },\n \"required\": [\n \"invoice_number\",\n \"total_amount\"\n ]\n },\n \"metadata\": {\n \"document_type\": \"invoice\"\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
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")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"name\": \"Invoice Extraction\",\n \"description\": \"Esquema para extrair dados de faturas de documentos PDF\",\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"invoice_number\": {\n \"type\": \"string\"\n },\n \"vendor_name\": {\n \"type\": \"string\"\n },\n \"total_amount\": {\n \"type\": \"number\"\n },\n \"date\": {\n \"type\": \"string\",\n \"format\": \"date\"\n }\n },\n \"required\": [\n \"invoice_number\",\n \"total_amount\"\n ]\n },\n \"metadata\": {\n \"document_type\": \"invoice\"\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://apigw.mka1.com/api/v1/llm/extract/schema")
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"] = 'application/json'
request.body = "{\n \"name\": \"Invoice Extraction\",\n \"description\": \"Esquema para extrair dados de faturas de documentos PDF\",\n \"schema\": {\n \"type\": \"object\",\n \"properties\": {\n \"invoice_number\": {\n \"type\": \"string\"\n },\n \"vendor_name\": {\n \"type\": \"string\"\n },\n \"total_amount\": {\n \"type\": \"number\"\n },\n \"date\": {\n \"type\": \"string\",\n \"format\": \"date\"\n }\n },\n \"required\": [\n \"invoice_number\",\n \"total_amount\"\n ]\n },\n \"metadata\": {\n \"document_type\": \"invoice\"\n }\n}"
response = http.request(request)
puts response.read_body{
"success": true,
"data": {
"id": "schema_invoice_123",
"name": "Invoice Extraction",
"description": "Schema for extracting invoice data from PDF documents",
"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"
]
},
"metadata": {
"document_type": "invoice"
},
"createdAt": "2024-01-15T10:30:00Z",
"updatedAt": "2024-01-15T10:30:00Z"
}
}Autorizações
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>.
Cabeçalhos
Optional external end-user identifier forwarded by the API gateway.
Corpo
Definição de esquema para criar um modelo de extração reutilizável. Esquemas de extração definem a estrutura e as regras de validação para a extração de dados de arquivos.
Nome do esquema de extração. Deve ter entre 1 e 100 caracteres. Usado para identificar e referenciar o esquema.
1 - 100Objeto JSON Schema definindo a estrutura dos dados a serem extraídos. Especifica os campos, tipos e regras de validação para os dados extraídos.
Show child attributes
Show child attributes
Descrição opcional do esquema. Máximo de 500 caracteres. Ajuda a documentar o propósito e o uso do esquema.
500Metadados opcionais para o esquema. Podem armazenar informações adicionais como versão, autor ou propriedades personalizadas.
Show child attributes
Show child attributes
Esta página foi útil?