A simple Python client for interacting for Regolo.ai's LLM-based API.
Ensure you have the regolo module installed. If not, install it using:
  pip install regoloimport regoloTo avoid manually passing the API key and model in every request, you can set them globally:
regolo.default_key = "<EXAMPLE_KEY>"
regolo.default_chat_model = "Llama-3.3-70B-Instruct"This ensures that all RegoloClient instances and static functions will
use the specified API key and model.
Still, you can create run methods by inserting model and key directly.
print(regolo.static_completions(prompt="Tell me something about Rome."))print(regolo.static_chat_completions(messages=[{"role": "user", "content": "Tell me something about rome"}]))To simplify basic interactions with our LLMs, we offer you the possibility to perform request without writing code. To do that, you only need to install python and, if you want, create a venv with the commands:
pip install virtualenv # install virtualenv in python
cd <the directory that'll contain your venv> # choose the starting directory for your venv
python -m venv env # create the venv in the env subdirectory
To use your venv, you'll go to the env subdirectory and use the source command activate it:
source bin/activate
At this point, you can run a simple chat with:
regolo chat
The CLI will guide you through inserting your API key and desired model.
It is worth mentioning that our "regolo chat" command has support for some arguments.
- "--no-hide", used to see your API key while typing
 
regolo chat --no-hide
- "--disable-newlines", to use if you prefer your AI to output spaces instead of new lines, which could make the response text too large for your environment.
 
regolo chat --disable-newlines
- "--api-key", useful if the user prefers to insert the api key through arg instead of being prompted tot insert it.
 
regolo chat --api-key <api_key>
It is worth noting how the regolo cli will allow users to perform standard tasks such as:
- Getting the models that you can access through your API key via:
regolo get-available-models - Generating images with desired parameters via:
regolo create-image - Transcribing audio files via:
regolo transcribe-audio 
All of these commands will give you an overview of their available parameters if you call them the --help parameter.
if you want to interact with this client through environment variables, you can follow this reference:
- "API_KEY"
 
You can use this environment variable to insert the default_key. You can load it after importing regolo using regolo.key_load_from_env_if_exists(). Using it is equivalent to updating regolo.default_key when you import regolo.
- "LLM"
 
You can use this environment variable to insert the default_chat_model. You can load it after importing regolo using regolo.default_chat_model_load_from_env_if_exists(). This is equivalent to updating regolo.default_chat_model when you import regolo.
- "IMAGE_MODEL"
 
You can use this environment variable to insert the default_image_model. You can load it after importing regolo using regolo.default_image_load_from_env_if_exists(). This is equivalent to updating regolo.default_image_model when you import regolo.
- "EMBEDDER_MODEL"
 
You can use this environment variable to insert the default_embedder_model. You can load it after importing regolo using regolo.default_embedder_load_from_env_if_exists(). This is equivalent to updating regolo.default_embedder_model when you import regolo.
Tip
All "default" environment variables can be updated together through regolo.try_loading_from_env().
It does nothing but run all the load_from_env methods al once.
- "REGOLO_URL"
 
You can use this env variable to set the default base_url used by regolo client and its static methods.
- "COMPLETIONS_URL_PATH"
 
You can use this env variable to set the base_url used by regolo client and its static methods.
- "CHAT_COMPLETIONS_URL_PATH"
 
You can use this env variable to set the chat completions endpoint used by regolo client and its static methods.
- "IMAGE_GENERATION_URL_PATH"
 
You can use this env variable to set the image generation endpoint used by regolo client and its static methods.
- "EMBEDDINGS_URL_PATH"
 
You can use this env variable to set the embedding generation endpoint used by regolo client and its static methods.
Tip
The "endpoints" environment variables can be changed during execution. Since the client works directly with them.
However, you are likely not to want to change them, since they are tied to how we handle our endpoints.
With full output:
import regolo
regolo.default_key = "<EXAMPLE_KEY>"
regolo.default_chat_model = "Llama-3.3-70B-Instruct"
# Completions
client = regolo.RegoloClient()
response = client.completions("Tell me about Rome in a concise manner", full_output=True, stream=True)
while True:
    try:
        print(next(response))
    except StopIteration:
        break
# Chat completions
client = regolo.RegoloClient()
response = client.run_chat(user_prompt="Tell me about Rome in a concise manner", full_output=True, stream=True)
while True:
    try:
        print(next(response))
    except StopIteration:
        breakWithout full output:
import regolo
regolo.default_key = "<EXAMPLE_KEY>"
regolo.default_chat_model = "Llama-3.3-70B-Instruct"
# Completions
client = regolo.RegoloClient()
response = client.completions("Tell me about Rome in a concise manner", full_output=False, stream=True)
while True:
    try:
        print(next(response), end='', flush=True)
    except StopIteration:
        break
# Chat completions
client = regolo.RegoloClient()
response = client.run_chat(user_prompt="Tell me about Rome in a concise manner", full_output=False, stream=True)
while True:
    try:
        res = next(response)
        if res[0]:
            print(res[0] + ":")
        print(res[1], end="", flush=True)
    except StopIteration:
        breakimport regolo
regolo.default_key = "<EXAMPLE_KEY>"
regolo.default_chat_model = "Llama-3.3-70B-Instruct"
client = regolo.RegoloClient()
# Make a request
client.add_prompt_to_chat(role="user", prompt="Tell me about rome!")
print(client.run_chat())
# Continue the conversation
client.add_prompt_to_chat(role="user", prompt="Tell me something more about it!")
print(client.run_chat())
# You can print the whole conversation if needed
print(client.instance.get_conversation())It is to consider that using the user_prompt parameter in run_chat() is equivalent to adding a prompt with role=user through add_prompt_to_chat().
Without client:
from io import BytesIO
import regolo
from PIL import Image
regolo.default_image_generation_model = "Qwen-Image"
regolo.default_key = "<EXAMPLE_KEY>"
img_bytes = regolo.static_image_create(prompt="a cat")[0]
image = Image.open(BytesIO(img_bytes))
image.show()With client
from io import BytesIO
import regolo
from PIL import Image
client = regolo.RegoloClient(image_generation_model="Qwen-Image", api_key="<EXAMPLE_KEY>")
img_bytes = client.create_image(prompt="A cat in Rome")[0]
image = Image.open(BytesIO(img_bytes))
image.show()Without client:
import regolo
regolo.default_key = "<EXAMPLE_KEY>"
regolo.default_embedder_model = "gte-Qwen2"
embeddings = regolo.static_embeddings(input_text=["test", "test1"])
print(embeddings)With client:
import regolo
client = regolo.RegoloClient(api_key="<EXAMPLE_KEY>", embedder_model="gte-Qwen2")
embeddings = client.embeddings(input_text=["test", "test1"])
print(embeddings)Without client:
import regolo
regolo.default_key = "<EXAMPLE_KEY>"
regolo.default_audio_transcription_model = "faster-whisper-large-v3"
transcribed_text = regolo.static_audio_transcription(file="<example_path>/<example_file_name>.mp3", full_output=True)
print(transcribed_text)With client:
import regolo
client = regolo.RegoloClient(api_key="<EXAMPLE_KEY>", audio_transcription_model="faster-whisper-large-v3")
transcribed_text = client.audio_transcription(file="<example_path>/<example_file_name>.mp3", full_output=True)
print(transcribed_text)