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": "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"
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
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'}
})
};
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' => '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'
]
]),
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\": \"Schema for extracting invoice data from PDF documents\",\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\": \"Schema for extracting invoice data from PDF documents\",\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\": \"Schema for extracting invoice data from PDF documents\",\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"
}
}Create reusable extraction schema template
Creates and stores a reusable JSON Schema template for structured data extraction.
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": "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"
}
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
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'}
})
};
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' => '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'
]
]),
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\": \"Schema for extracting invoice data from PDF documents\",\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\": \"Schema for extracting invoice data from PDF documents\",\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\": \"Schema for extracting invoice data from PDF documents\",\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"
}
}Authorizations
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>.
Headers
Optional external end-user identifier forwarded by the API gateway.
Body
Schema definition for creating a reusable extraction template. Extraction schemas define the structure and validation rules for data extraction from files.
Name of the extraction schema. Must be between 1 and 100 characters. Used to identify and reference the schema.
1 - 100JSON Schema object defining the structure of data to extract. Specifies the fields, types, and validation rules for the extracted data.
Show child attributes
Show child attributes
Optional description of the schema. Maximum 500 characters. Helps document the purpose and usage of the schema.
500Optional metadata for the schema. Can store additional information like version, author, or custom properties.
Show child attributes
Show child attributes
Was this page helpful?