Package installation and examples of Sherlock AI code on CloudFerro Cloud
Sherlock AI provides an OpenAI-compatible API, so you can use existing tools and libraries that already support the OpenAI API format. This article shows a minimal setup procedure and two basic request examples: one with curl and one with Python.
The examples use an API key created in the Sherlock AI control panel. Keep this key private and load it from an environment variable instead of writing it directly into scripts, repositories, notebooks, or frontend code.
Prerequisites
Before you start, make sure that:
You have access to a Sherlock AI project.
You have created and copied a Sherlock AI API key.
You have Python and pip installed if you want to run the Python example.
You have curl installed if you want to test the API directly from the command line.
Install the Python package
For Python examples, install the OpenAI client library. It can communicate with Sherlock AI because Sherlock AI uses an OpenAI-compatible API format.
pip install openai
If you work in a local development environment, it is recommended to install the package inside a virtual environment instead of installing it globally.
python3 -m venv .venv
source .venv/bin/activate
pip install openai
Configure the API key
Store the Sherlock AI API key in an environment variable. This keeps the key out of your command history, source code, and documentation examples.
On Linux or macOS, use:
export SHERLOCK_API_KEY="paste-your-api-key-here"
On Windows PowerShell, use:
$env:SHERLOCK_API_KEY="paste-your-api-key-here"
The variable is available only in the current terminal session. To use it later, set it again or add it to your usual shell or deployment configuration.
Send a request with curl
The following curl example sends a chat completion request to the Sherlock AI API. It reads the API key from the SHERLOCK_API_KEY environment variable and passes it as a bearer token.
curl https://api-sherlock.cloudferro.com/openai/v1/chat/completions \
-H "Authorization: Bearer $SHERLOCK_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "speakleash/Bielik-11B-v3.0-Instruct",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Explain what Sherlock AI is in one paragraph."
}
]
}'
A successful request returns a JSON response containing the generated answer and additional response metadata.
Send a request with Python
The Python example uses the OpenAI client library, but changes the base_url so that requests are sent to Sherlock AI instead of the default OpenAI endpoint.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["SHERLOCK_API_KEY"],
base_url="https://api-sherlock.cloudferro.com/openai/v1",
)
response = client.chat.completions.create(
model="speakleash/Bielik-11B-v3.0-Instruct",
messages=[
{
"role": "system",
"content": "You are a helpful assistant.",
},
{
"role": "user",
"content": "Explain what Sherlock AI is in one paragraph.",
},
],
)
print(response.choices[0].message.content)
This script sends one prompt to the selected model and prints the generated answer. In a production application, place this logic in your backend service and keep the API key in an environment variable or secrets manager.
Troubleshooting
If the request fails, first check that the SHERLOCK_API_KEY environment variable is set in the same terminal session where you run the command or script.
If authentication fails, verify that the key was copied correctly and that it belongs to the Sherlock AI project you want to use. If the model is rejected, check that the selected model is available for that project.
If Python cannot import the OpenAI library, make sure that pip install openai was run in the same environment in which you execute the script. On systems with multiple Python versions, use python3 -m pip install openai and run the script with the same python3 command.