Skip to main content

Generic Prediction

The generic prediction endpoint allows you to send a raw request body to the model. This is useful when you want to interact with a model using its base endpoint without a specific method path.

Endpoint​

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


Headers​

NameTypeDescription
KnowledgatorAPI-KeyStringYour API key
Content-TypeStringapplication/json

Request Parameters​

ParameterTypeRequiredDescription
model_idstringYesThe unique identifier of the model (passed in the URL).
bodyobjectYesThe model-specific request body.

Response​

The response format depends on the specific model.


Error Codes​

Status CodeDescription
200OK – Request successful.
400Bad Request – Invalid or incomplete input.
401Unauthorized – Invalid API key.
404Not Found – Invalid model ID.
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');

// Send a generic prediction request
const response = await model.predict({
input: 'text to process'
});

Python​

from knowledgator import Knowledgator

kg = Knowledgator(api_key="YOUR_API_KEY")
model = kg.model("your-model-id")

# Send a generic prediction request
response = model.predict({
"input": "text to process"
})

Python​

import requests

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

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

cURL​

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

Additional Information​

  • Model Specificity: The request body and response format are entirely dependent on the specific model being called.
  • Use Cases:
    • Standard model inference
    • Interacting with custom models
    • Testing model connectivity