Python example
Python Example: Calling the /ask Endpoint
import requests
# Replace this with your actual API key
API_KEY = "your-api-key-here"
# Base URL of the LawyerGPT API
BASE_URL = "https://api.lawyergptai.cc/v1"
# Example payload for the /ask endpoint
payload = {
"question": "Can I terminate a lease early in California without penalty?",
"language": "en"
}
# Set headers including the API key
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json"
}
# Make the POST request
response = requests.post(f"{BASE_URL}/ask", json=payload, headers=headers)
# Handle the response
if response.status_code == 200:
data = response.json()
print("π¬ Answer:", data.get("answer"))
print("π Source:", data.get("source"))
else:
print("β Error:", response.status_code, response.text)
Requirements
Output Example
Last updated