Purpose
This tutorial explains how to retrieve the client secret used by the Giotto Python client from Keycloak, and how to use it in a simple Python script.
By the end of this tutorial, you will have:
- opened the Keycloak admin interface
- selected the correct realm
- opened the
python-clientclient configuration - copied the client secret
- used it in a working Python client example
Overview
The Giotto Python client authenticates using a Keycloak client configuration.
To use the client, you need:
- the Giotto API base URL
- the Keycloak base URL
- the realm
- the client ID
- the client secret
In this tutorial, the client ID is:
python-clientand the client secret is retrieved from the Credentials section in Keycloak.
Important: this tutorial assumes that the target model is already deployed. Retrieving the client secret only enables authentication; it does not deploy the model for you.
Before you begin
Make sure you have:
- access to the Giotto homepage
- admin credentials for Keycloak
- a deployed model or deployed agentic system to query afterward
Step 1 — Open Keycloak from the homepage
From the Giotto homepage, click the Keycloak button.
This opens the Keycloak administration interface.
Step 2 — Log in with admin credentials
Once the Keycloak login page opens, log in using the admin credentials.
This gives you access to the Keycloak admin console where realms, clients, and credentials are managed.
Step 3 — Select the correct realm
After logging in:
- go to the Realms section
- select the giotto realm
This is the realm where the Python client is configured.
If your environment uses a different realm name, use the one configured for your deployment. In the example client below, the application realm used by the client is
giotto, so make sure the realm and your environment are aligned.
Step 4 — Go to Clients and select python-client
Inside the selected realm:
- go to the Clients section
- find and open the client named:
python-clientThis is the client configuration used by the Giotto Python library.
Step 5 — Open the Credentials tab
Once inside the python-client client configuration:
- open the Credentials tab
This is where the client secret is stored.
Step 6 — Copy the client secret
In the Credentials section, copy the client secret.
This secret is the value you will use as:
client_secret="..."in your Python script.
Important: treat this secret as sensitive. Do not commit it to source control, share it in screenshots, or expose it in public documentation.
Step 7 — Use the secret in your Python client
Once you have the client secret, you can initialize the Giotto Python client and send a request.
Here is a minimal example, assuming the model is already deployed:
from g_client import GiottoClient
client = GiottoClient(
base_url = f"{BASE_URL}/api",
keycloak_base_url = f"{BASE_URL}/keycloak",
realm = "giotto",
client_id = "python-client",
client_secret = "<your-client-secret>",
)
response = client.responses.create(
model="giotto-model",
input="Write a one-sentence bedtime story about a unicorn.",
)
print(response.output_text)What this does
This script:
- authenticates to Giotto through Keycloak
- sends a request to the deployed model
- waits for the orchestrated response
- prints the final output text
If everything is configured correctly and the model is already deployed, you should receive a normal response.
Expected result
A valid response may look like:
The little unicorn curled up in the soft clover field, dreaming of silver stars as the gentle moon watched over him.Security note
The client secret is effectively a credential for the Python client.
Follow these practices:
- do not hard-code it in production code
- prefer environment variables or a secret manager
- rotate it if it was ever exposed
- limit who can access it in Keycloak
A better production pattern is:
import os
from g_client import GiottoClient
client = GiottoClient(
base_url = f"{BASE_URL}/api",
keycloak_base_url = f"{BASE_URL}/keycloak",
realm = "giotto",
client_id = "python-client",
client_secret=os.environ["GIOTTO_CLIENT_SECRET"],
)Troubleshooting tips
I cannot log into Keycloak
Check that:
- you are using the correct admin credentials
- the Keycloak service is reachable
- you opened the correct Keycloak instance from the homepage
I cannot find the python-client
Make sure you selected the correct realm before looking under Clients.
The client secret does not work
Check:
- that you copied the full value correctly
- that you are using the correct
client_id - that
base_url,keycloak_base_url, andrealmmatch your environment
The Python script authenticates, but the request fails
This usually means the target model is not yet deployed, or the model name is incorrect.
Best practices
Keep the secret out of source code
Use environment variables or a secrets manager whenever possible.
Verify the deployed model name
Authentication alone is not enough — the model you call must already exist and be deployed.
Limit access to the client credentials
Only administrators or trusted operators should retrieve client secrets from Keycloak.
Rotate secrets if exposed
If a client secret ever appears in shared documentation, logs, or screenshots, replace it.
Comments
0 comments
Article is closed for comments.