AskSage is a secure and extensible generative AI platform designed for government and commercial organizations, with a particular focus on the public sector and regulated industries. It provides a way for teams to leverage various large language models (LLMs) and other AI capabilities in a secure and compliant environment.

Key features of AskSage include:

  • Multi-model access: Support for various LLMs including GPT, Claude, Gemini, and specialized government-approved models
  • Enterprise security: SOC 2 compliance, data encryption, and air-gapped deployment options
  • Audit trails: Complete logging and monitoring for regulatory compliance
  • Custom integrations: API access for embedding AI capabilities into existing workflows
  • Content filtering: Built-in safety measures and content moderation

A comprehensive example is provided by AskSage here.

Step 0: Setting Up Your Development Environment

uv init asksage_test 
cd asksage_test
uv add asksageclient requests pip_system_certs pandas

Step 1: Creating Your API Credentials File

Save it in a secret place ~/.secrets/asksage_credential.json.

Note, one needs to add the user_base_url and server_base_url, which was provided during the creation of API key in the website.

{
  "credentials": {
    "api_key": "YOUR_API_KEY",
    "Ask_sage_user_info": {
      "username": "YOUR_EMAIL",
      "user_base_url": "https://api.civ.asksage.ai/user",
      "server_base_url": "https://api.civ.asksage.ai/server"
    }
  }
}

Step 2: Loading Credentials and Initializing the AskSage Client

import json  # Import the json module to work with JSON data
import requests  # Import the requests library to send HTTP requests
from pathlib import Path
import pandas as pd

# Import the AskSageClient class from the asksageclient module
from asksageclient import AskSageClient

# Function to load credentials from a JSON file


def load_credentials(filename):
    try:
        with open(filename) as file:
            return json.load(file)
    except FileNotFoundError:
        raise FileNotFoundError("The credentials file was not found.")
    except json.JSONDecodeError:
        raise ValueError("Failed to decode JSON from the credentials file.")


# Load the credentials
credentials = load_credentials(
    Path("~/.secrets/asksage_credential.json").expanduser().resolve()
)

# Extract the API key, and email from the credentials to be used in the API request
api_key = credentials["credentials"]["api_key"]
email = credentials["credentials"]["Ask_sage_user_info"]["username"]
user_base_url = credentials["credentials"]["Ask_sage_user_info"]["user_base_url"]
server_base_url = credentials["credentials"]["Ask_sage_user_info"]["server_base_url"]

"""  
class AskSageClient(
    email: email, # The email address of the user
    api_key: api_key, # The API key for the Ask Sage API, which can be obtained from the Ask Sage website
    user_base_url: str = 'https://api.asksage.ai/user', # The base URL for the user API
    server_base_url: str = 'https://api.asksage.ai/server' # The base URL for the server API
)
"""

# Create an instance of the Ask Sage Client class with the email and api_key
ask_sage_client = AskSageClient(email, api_key, user_base_url, server_base_url)

Step 3: Retrieving Available AI Models

# Fetch the list of models available for the user
response = ask_sage_client.get_models()

# Check if the response contains the expected 'response' key
if 'response' in response:
    models = response['response']
    
    # Convert the models list into a DataFrame for better visualization
    models_df = pd.DataFrame(models)
    print('Models available for the user on the respective Ask Sage Tenant/Account:')
    print('--------------------------------------------------')
    display(models_df)
    

It shows the following models.

Models available for the user on the respetive Ask Sage Tenant/Account:
--------------------------------------------------
                                   0
0   aws-bedrock-claude-35-sonnet-gov
1   aws-bedrock-claude-37-sonnet-gov
2          aws-bedrock-nova-lite-gov
3                  aws-bedrock-titan
4                              llma3
5                            gpt-gov
6                           gpt4-gov
7                         openai_gpt
8                               gpt4
9                          gpt35-16k
10                            gpt-4o
11                       gpt-4o-mini
12                          dall-e-3
13            google-gemini-20-flash
14                   google-imagen-3
15                   google-imagen-4
16             google-gemini-2.5-pro
17           google-gemini-2.5-flash
18            google-claude-4-sonnet
19              google-claude-4-opus
20                        gpt-4o-gov
21                   gpt-4o-mini-gov
22                            gpt-o1
23                       gpt-o1-mini
24                       gpt-o3-mini
25                            gpt-o3
26                       gpt-o4-mini
27                           gpt-4.1
28                      gpt-4.1-mini
29                      gpt-4.1-nano
30                             gpt-5
31                        gpt-5-mini
32                        gpt-5-nano

Step 4: Making Your First AI Query

replies = ask_sage_client.query(message="why sky is blue",
                                model="google-gemini-2.5-flash",
                                limit_references=0, system_prompt="",
                                tools=None) 
print(replies)

With output like this:

{‘added_obj’: None, ’embedding_down’: False, ‘message’: ‘\n\nThe sky appears blue primarily due to a phenomenon called Rayleigh scattering [1]. Here's a breakdown of why this happens:\n\n1. Sunlight Composition: Sunlight, which appears white to us, is actually composed of all the colors of the rainbow. Each color has a different wavelength, with violet and blue light having shorter wavelengths, and red and orange light having longer wavelengths.\n\n2. Atmospheric Particles: Earth's atmosphere is made up of various gases, primarily nitrogen (about 78%) and oxygen (about 21%), along with other trace gases and tiny particles. These gas molecules are much smaller than the wavelengths of visible light.\n\n3. Rayleigh Scattering: When sunlight enters the Earth's atmosphere, it collides with these tiny gas molecules. Rayleigh scattering describes how light is scattered by particles much smaller than its wavelength. This type of scattering is highly dependent on the wavelength of the light. Shorter wavelengths (like blue and violet light) are scattered much more efficiently and intensely than longer wavelengths (like red and yellow light) [1]. The scattering intensity is inversely proportional to the fourth power of the wavelength ($$ I \propto \frac{1}{\lambda^4} $$), meaning blue light (shorter wavelength) is scattered about 10 times more than red light (longer wavelength) [2].\n\n4. Why Blue, Not Violet? While violet light has an even shorter wavelength than blue and is scattered even more, the sky appears blue for two main reasons:\n * The sun emits slightly less violet light than blue light.\n * Our eyes are more sensitive to blue light than to violet light [1].\n\n5. The Result: As sunlight travels through the atmosphere, the blue and violet light are scattered in all directions by the tiny air molecules. This scattered blue light reaches our eyes from all parts of the sky, making it appear blue. The longer wavelength colors (red, orange, yellow) are scattered much less and tend to travel more directly through the atmosphere, which is why the sun itself appears yellowish-white when high in the sky.\n\nReferences:\n[1] National Oceanic and Atmospheric Administration (NOAA). “Why is the sky blue?”. Accessed September 6, 2025.\n[2] HyperPhysics. “Rayleigh Scattering”. Accessed September 6, 2025.’, ‘references’: ‘’, ‘response’: ‘OK’, ‘status’: 200, ’tool_calls’: None, ’tool_calls_unified’: [], ’tool_responses’: [], ’type’: ‘completion’, ‘usage’: None, ‘uuid’: ‘7f360454-0279-41e2-856f-ed03a1be9b91’, ‘vectors_down’: False}