Get started with Gloo AI Studio by following these steps. You’ll create an account and make your first API call.
Developers don’t need to be part of an organization to get started. However, some features—like data ingestion and analytics—are only available to members of an organization.

Step 1: Create Your Account

First, sign up for a Gloo AI account. You can do this by visiting the Gloo AI Studio website and clicking on the “Sign Up” link. The first time you log in, you may be prompted to accept an organization invitation. This unlocks additional features within Gloo AI Studio.

Step 2: Create Your API Credentials

First, click API Credentials from the left-hand navigation menu. From the drop-down menu, select Personal Credentials to create a credential that is associated with your account. Next, click Create New Key then enter a name for your key and click Create. A new credential that consists of a Client ID and Client Secret will be generated.

Step 3: Generate an Access Token

Once you have a Client ID and Client Secret, you can generate an access token using one of the following methods:
import base64
import requests

def get_access_token(client_id: str, client_secret: str) -> dict:
    auth = base64.b64encode(f"{client_id}:{client_secret}".encode()).decode()

    response = requests.post(
        "https://platform.ai.gloo.com/oauth2/token",
        headers={
            "Content-Type": "application/x-www-form-urlencoded",
            "Authorization": f"Basic {auth}"
        },
        data={
            "grant_type": "client_credentials",
            "scope": "api/access"
        }
    )

    return response.json()

# Check token expiration
from jwt import decode
token_data = get_access_token(client_id, client_secret)
decoded = decode(token_data["access_token"], verify=False)
expiration = decoded["exp"]
The response will include an access token that you can use to authenticate your API calls. It should look like this:
{
  "access_token":"eyJraWQiOiJ...jwvh2t..cumG9g",
  "expires_in":3600,
  "token_type":"Bearer"
}
Access tokens expire after one hour. Monitor the token’s expiration by checking the ‘exp’ claim in the JWT payload. Since refresh tokens are not provided with client credentials, you will need to request a new access token when the current one expires.

Step 4: Make an API Call

You can test out the access token by making a call to the Completions API provided by Gloo AI.
import requests

url = "https://platform.ai.gloo.com/ai/v1/chat/completions"
headers = {
    "Content-Type": "application/json",
    "Authorization": "Bearer CLIENT_ACCESS_TOKEN"  # Replace with your actual token
}
payload = {
    "model": "meta.llama3-70b-instruct-v1:0",
    "messages": [
        {
            "role": "system",
            "content": "You are a human-flourishing assistant."
        },
        {
            "role": "user",
            "content": "How do I discover my purpose?"
        }
    ]
}

response = requests.post(url, headers=headers, json=payload)

if response.status_code == 200:
    print(response.json())
else:
    print(f"Error {response.status_code}: {response.text}")
The response should look like this:
{
    "id": "chatcmpl-b4ad2c48",
    "choices": [
        {
            "finish_reason": "stop",
            "index": 0,
            "logprobs": null,
            "message": {
                "content": "\n\nWhat a profound and meaningful question!...",
                "refusal": null,
                "role": "assistant",
                "annotations": null,
                "audio": null,
                "function_call": null,
                "tool_calls": null
            }
        }
    ],
    "created": 1750793523,
    "model": "meta.llama3-70b-instruct-v1:0",
    "object": "chat.completion",
    "service_tier": null,
    "system_fingerprint": "fp",
    "usage": {
        "completion_tokens": 459,
        "prompt_tokens": 1115,
        "total_tokens": 1574,
        "completion_tokens_details": null,
        "prompt_tokens_details": null
    }
}
Congratulations. You’ve made your first API call!