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
| 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 (passed in the URL). |
body | object | Yes | The model-specific request body. |
Response
The response format depends on the specific model.
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. |
| 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');
// 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