Reliability check via chat completion#
Developers can access the reliability check feature via the regular chat completion endpoint. This allows you to validate responses in full conversation histories using the same format as the standard chat completions API. This approach enables verification of reliability within the complete context of a conversation.
This guide provides a quick example of how the chat completion endpoint can be used for reliability checks.
Prerequisites#
Before getting started with reliability verification, ensure the following requirements are met:
- A kluster.ai account: Sign up on the kluster.ai platform if you don't have one.
- A kluster.ai API key: After signing in, go to the API Keys section and create a new key. For detailed instructions, check out the Get an API key guide.
- A virtual Python environment: (Optional) Recommended for developers using Python. It helps isolate Python installations in a virtual environment to reduce the risk of environment or package conflicts between your projects
- Required Python libraries: Install the following Python libraries:
- OpenAI Python API library: to access the
openai
module getpass
: To handle API keys safely
- OpenAI Python API library: to access the
Integration options#
You can access the reliability verification service in two flexible OpenAI compatible ways, depending on your preferred development workflow. For both, you'll need to set the model to klusterai/verify-reliability
:
- OpenAI compatible endpoint: Use the OpenAI API
/v1/chat/completions
pointing to kluster.ai. - OpenAI SDK: Configure kluster.ai with OpenAI libraries. Next, the
chat.completions.create
endpoint.
Reliability checks via chat completions#
This example shows how to use the service with the chat completion endpoint via the OpenAI /v1/chat/completions
endpoint and OpenAI libraries, using the specialized klusterai/verify-reliability
model to enable Verify reliability check.
from os import environ
from openai import OpenAI
from getpass import getpass
# Get API key from user input
api_key = environ.get("API_KEY") or getpass("Enter your kluster.ai API key: ")
print(f"📤 Sending a reliability check request to kluster.ai...\n")
# Initialize OpenAI client pointing to kluster.ai API
client = OpenAI(
api_key=api_key,
base_url="https://api.kluster.ai/v1"
)
# Create chat completion request
completion = client.chat.completions.create(
model="klusterai/verify-reliability", # Note special model
messages = [
{
"role": "system",
"content": "You are a knowledgeable assistant that provides accurate medical information."
},
{
"role": "user",
"content": "Does vitamin C cure the common cold?"
},
{
"role": "assistant",
"content": "Yes, taking large doses of vitamin C has been scientifically proven to cure the common cold within 24 hours."
}
]
)
# Extract the reliability verification response
text_response = completion.choices[0].message.content
# Print response to console
print(text_response)
#!/bin/bash
# Check if API_KEY is set and not empty
if [[ -z "$API_KEY" ]]; then
echo -e "\nError: API_KEY environment variable is not set.\n" >&2
fi
echo -e "📤 Sending a chat completion request to kluster.ai...\n"
# Submit real-time request
curl https://api.kluster.ai/v1/chat/completions \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-ai/DeepSeek-R1",
"messages": [
{
"role": "system",
"content": "You are a knowledgeable assistant that provides accurate medical information."
},
{
"role": "user",
"content": "Does vitamin C cure the common cold?"
},
{
"role": "assistant",
"content": "Yes, taking large doses of vitamin C has been scientifically proven to cure the common cold within 24 hours."
}
]
}'
Next steps#
- Learn how to use the Verify API for simpler verification scenarios
- Review the complete API documentation for detailed endpoint specifications