cURL
cURL Examples
Use Quiet Stack directly from the command line - perfect for testing, scripts, and automation
Zero Installation Required!
cURL comes pre-installed on macOS, Linux, and Windows 10+. Just copy, paste, and run these commands. Install jq for pretty JSON formatting: brew install jq or apt-get install jq
Basic Request
Simple cURL command to get started with Quiet Stack
# Step 1: Make AI request to OpenAI
curl -X POST https://api.openai.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_OPENAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-3.5-turbo",
"messages": [{"role": "user", "content": "What is the capital of France?"}]
}'
# Step 2: Log context to Quiet Stack blockchain
curl -X POST https://api.quietstack.ai/api/v1/audit/log \
-H "Authorization: Bearer qs_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"context": {
"request_id": "req-123",
"model_provider": "openai",
"model_name": "gpt-3.5-turbo",
"prompt": "What is the capital of France?",
"response": "The capital of France is Paris.",
"token_usage": {"total_tokens": 20},
"timestamp": "2025-11-24T00:00:00Z"
}
}'Pretty Printed Response
Using jq to format JSON output for better readability
curl -X POST https://api.quietstack.ai/v1/proxy \
-H "Authorization: Bearer qs_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"provider": "openai",
"model": "gpt-4",
"messages": [{
"role": "user",
"content": "Explain quantum computing in simple terms"
}]
}' | jq .Bash Script Helper
Reusable bash script for Quiet Stack API calls
#!/bin/bash
# Quiet Stack API helper script
API_KEY="qs_live_YOUR_API_KEY"
BASE_URL="https://api.quietstack.ai"
# Function to call Quiet Stack API
ask_ai() {
local prompt="$1"
local provider="${2:-openai}"
local model="${3:-gpt-3.5-turbo}"
curl -s -X POST "$BASE_URL" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d "{
"provider": "$provider",
"model": "$model",
"messages": [{
"role": "user",
"content": "$prompt"
}]
}"
}
# Usage examples
echo "Basic usage:"
ask_ai "What are the benefits of blockchain verification?"
echo -e "\n\nWith different provider:"
ask_ai "Explain AI safety" "anthropic" "claude-3-haiku"
echo -e "\n\nPretty print with jq:"
ask_ai "Tell me about Python" | jq '{response: .response, cost: .usage.cost, verified: .verification.hash}'Testing & Debugging
Commands for testing API connectivity and debugging issues
# Test basic connectivity
curl -I https://api.quietstack.ai/v1/proxy
# Test with invalid API key (should return 401)
curl -X POST https://api.quietstack.ai/v1/proxy \
-H "Authorization: Bearer invalid_key" \
-H "Content-Type: application/json" \
-d '{"provider": "openai", "model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "test"}]}'
# Test with missing required fields
curl -X POST https://api.quietstack.ai/v1/proxy \
-H "Authorization: Bearer qs_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"provider": "openai"}'
# Test successful request with timing
time curl -X POST https://api.quietstack.ai/v1/proxy \
-H "Authorization: Bearer qs_live_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"provider": "openai",
"model": "gpt-3.5-turbo",
"messages": [{
"role": "user",
"content": "Hello, world!"
}]
}'Response Structure
Understanding the JSON response from Quiet Stack API
# Example response from /api/v1/audit/log
{
"audit_id": "f25bdb80-1bb0-4552-a1ba-0fb59d3c1aaf",
"transaction_hash": "0x070cfd79fcfd7fdd6f934253496e7a0094e4ce746d88dbdcda991fb6fca43cf4",
"status": "logged",
"timestamp": "2025-11-24T03:18:21.877Z",
"context_hash": "393ec5ad771d97174462f63e632d55c2c272fc7a8e4c8d9e0f1a2b3c4d5e6f7890"
}
# View transaction on Polygonscan:
# https://polygonscan.com/tx/0x070cfd79fcfd7fdd6f934253496e7a0094e4ce746d88dbdcda991fb6fca43cf4Environment Setup
Secure your API key using environment variables
1. Set environment variable:
export QUIETSTACK_API_KEY=qs_live_your_actual_api_key_here2. Use in cURL commands:
curl -X POST https://api.quietstack.ai/v1/proxy \
-H "Authorization: Bearer $QUIETSTACK_API_KEY" \
-H "Content-Type: application/json" \
-d '{"provider": "openai", "model": "gpt-3.5-turbo", "messages": [{"role": "user", "content": "Hello!"}]}'Ready to try it out?
Get your API key and start making blockchain-verified AI requests from the command line