Integrating Kranium APIs
Welcome to the guide for using the API endpoint for models in Kranium AI. This guide will walk you through the steps to access API details, regenerate the secret key, and integrate the API with 3rd party applications. Using the API, you can leverage the power of your trained models in external systems and applications.
1. Accessing API Details
Steps:
- Navigate to the Models Section:
- From the main dashboard, click on the "Models" link to access the Models section.
- Select Your Model:
- In the Models listing screen, locate the model for which you want to access the API details and click on its name to open the model's details page.
- Open the API Tab:
- Within the model details page, find and click on the "API" tab. This tab contains the necessary information for accessing and using the model's API endpoint.
2. Viewing and Regenerating the Secret Key
Steps:
- Locate API Details:
- In the API tab, you will find the API endpoint URL, request format, and other relevant details required to use the API.
- View the Secret Key:
- The secret key required for authenticating API requests is displayed in the API tab. This key is essential for securing your API interactions.
- Regenerate the Secret Key:
- If you need to regenerate the secret key, click on the "Regenerate Key" button. A confirmation dialog will appear. Confirm the regeneration, and a new secret key will be generated. Note that after regeneration, the previous key will no longer be valid.
3. Integrating with 3rd Party Applications
Steps:
- Prepare API Request:
- Use the API endpoint URL and the secret key to prepare your API requests. Ensure that your requests include the necessary headers and payload as specified in the API documentation provided in the API tab.
Example API Request:
Here is an example of how to make a POST request to the API endpoint using Python and the requests library:
import requests
# API endpoint URL and secret key
api_url = "https://kranium-ai.com/api/v1/models/your-model-id/predict"
secret_key = "your-secret-key"
# Request headers
headers = {
"Authorization": f"Bearer {secret_key}",
"Content-Type": "application/json"
}
# Request payload
data = {
"feature1": value1,
"feature2": value2,
# Add other features as required
}
# Make the API request
response = requests.post(api_url, headers=headers, json=data)
# Check response status
if response.status_code == 200:
print("Prediction successful!")
prediction = response.json()
print(prediction)
else:
print("Error:", response.status_code, response.text)
Integrate with Your Application:
Use similar code in your preferred programming language or environment to integrate the model's API with your 3rd party application. Ensure that you handle the API responses appropriately and manage errors or exceptions as needed.
4. Securing Your API Integration
Steps:
- Keep the Secret Key Secure:
- Ensure that your secret key is kept secure and not exposed in public repositories or shared with unauthorized users. Use environment variables or secure vaults to store the key securely in your application.
- Regenerate Key Periodically:
- Periodically regenerate the secret key to enhance security, especially if you suspect any potential exposure or unauthorized access.
- Monitor API Usage:
- Regularly monitor the usage of your API endpoint through the Kranium AI platform to ensure that it is being accessed appropriately and within the expected limits.
Using the API endpoint for models in Kranium AI allows you to seamlessly integrate your trained models with 3rd party applications, enabling powerful AI-driven functionalities in external systems. By following this guide, you can access the API details, regenerate the secret key, and integrate the API with your applications securely and efficiently.
For any additional support or advanced configurations, refer to our support resources or contact the Kranium AI support team.