Stop Training
Stop a running training job. The training will be halted and marked as stopped.
Endpoint
POST https://api.platform.knowledgator.com/trainings/{training_id}/stop/
Headers
| Name | Type | Description |
|---|---|---|
KnowledgatorAPI-Key | String | Your API key |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
training_id | String | Yes | Unique training job identifier (2-64 chars, alphanumeric with hyphens) |
Response
Returns HTTP 204 No Content on success (no response body).
Error Codes
| Status Code | Description |
|---|---|
| 204 | No Content – Training stopped successfully. |
| 400 | Bad Request – Invalid input or training doesn't exist. |
| 401 | Unauthorized – Invalid API key or email verification required. |
| 403 | Forbidden – Invalid CSRF token. |
| 500 | Internal Server Error – Server-side issue. |
| 503 | Service Unavailable – Service temporarily unavailable. |
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');
// Stop a running training job
await kg.finetuning.stopTraining('78d379da228a4985ba19100f53245b79');
console.log('Training stopped successfully');
// Verify the training status
const training = await kg.finetuning.getTraining('78d379da228a4985ba19100f53245b79');
console.log(`Status: ${training.status}`); // Should be 'stopped'
Python
from knowledgator import Knowledgator
kg = Knowledgator(api_key="YOUR_API_KEY")
# Stop a running training job
kg.finetuning.stop_training("78d379da228a4985ba19100f53245b79")
print("Training stopped successfully")
# Verify the training status
training = kg.finetuning.get_training("78d379da228a4985ba19100f53245b79")
print(f"Status: {training.status}") # Should be 'stopped'
Expected SDK Output
Training stopped successfully
Status: stopped
Python
import requests
url = "https://api.platform.knowledgator.com/trainings/78d379da228a4985ba19100f53245b79/stop/"
headers = {
"KnowledgatorAPI-Key": "YOUR_API_KEY",
}
response = requests.post(url, headers=headers)
if response.status_code == 204:
print("Training stopped successfully")
cURL
curl -i -X POST "https://api.platform.knowledgator.com/trainings/78d379da228a4985ba19100f53245b79/stop/" \
-H "KnowledgatorAPI-Key: YOUR_API_KEY"
Expected Response (cURL)
HTTP/1.1 204 No Content
Additional Information
- Training State: After stopping, the training status will be updated to 'stopped'
- Partial Results: Stopped trainings may have partial results depending on when they were stopped
- Use Cases:
- Stop long-running trainings that are not converging
- Cancel trainings with incorrect hyperparameters
- Free up resources for other training jobs
Note: Stopping a training job cannot be undone. You will need to start a new training job if you want to continue training.