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
| Name | Type | Description |
|---|---|---|
KnowledgatorAPI-Key | String | Your API key |
Content-Type | String | application/json |
Request Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model_id | string | Yes | The unique identifier of the model. |
method | string | Yes | The method name to call (e.g., generate, summarize, classify). |
body | object | Yes | The method-specific request body. |
Response
The response format depends on the specific model and the method called.
Error Codes
| Status Code | Description |
|---|---|
| 200 | OK – Request successful. |
| 400 | Bad Request – Invalid or incomplete input. |
| 401 | Unauthorized – Invalid API key. |
| 404 | Not Found – Invalid model ID or method. |
| 500 | Internal 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