Skip to main content

Method-based Inference

Method-based inference allows you to call a specific method or capability of a model. This is reflected in the URL path as /inference/{model_id}/{method}/.

Endpoint​

POST https://api.platform.knowledgator.com/inference/{model_id}/{method}/


Headers​

NameTypeDescription
KnowledgatorAPI-KeyStringYour API key
Content-TypeStringapplication/json

Request Parameters​

ParameterTypeRequiredDescription
model_idstringYesThe unique identifier of the model.
methodstringYesThe method name to call (e.g., generate, summarize, classify).
bodyobjectYesThe method-specific request body.

Response​

The response format depends on the specific model and the method called.


Error Codes​

Status CodeDescription
200OK – Request successful.
400Bad Request – Invalid or incomplete input.
401Unauthorized – Invalid API key.
404Not Found – Invalid model ID or method.
500Internal Server Error – Server-side issue.

Example Usage​

SDK Usage​

💡 Dedicated SDK Guides: See Python SDK | TypeScript SDK

TypeScript/JavaScript​

import { createClient } from '@knowledgator/typescript-sdk';

const kg = createClient('YOUR_API_KEY');

const model = kg.model('your-model-id');
const result = await model.call('summarize', {
text: '...'
});

Python​

from knowledgator import Knowledgator

kg = Knowledgator(api_key="YOUR_API_KEY")

model = kg.model("your-model-id")
result = model.call("summarize", {
"text": "..."
})

Python​

import requests

model_id = "your-model-id"
method = "summarize"
url = f"https://api.platform.knowledgator.com/inference/{model_id}/{method}/"
headers = {
"Content-Type": "application/json",
"KnowledgatorAPI-Key": "YOUR_API_KEY"
}
payload = {
"text": "..."
}

response = requests.post(url, json=payload, headers=headers)
print(response.json())

cURL​

curl -X POST https://api.platform.knowledgator.com/inference/your-model-id/summarize/ \
-H "Content-Type: application/json" \
-H "KnowledgatorAPI-Key: YOUR_API_KEY" \
-d '{
"text": "..."
}'

Additional Information​

  • Method Flexibility: Models can expose multiple specialized methods for different tasks.
  • Use Cases:
    • Calling specific model features (generation, summarization)
    • Interacting with structured model interfaces