cygon
Initial deployment with Ollama support
d61feef
#!/bin/bash
API_URL="http://localhost:8000"
API_KEY="demo-key-1"
echo "=== AI API Service - Example Requests ==="
echo ""
echo "1. Health Check"
echo "==============="
curl -s "${API_URL}/health" | jq .
echo ""
echo ""
echo "2. Verify API Key"
echo "================="
curl -s -X POST "${API_URL}/auth/verify" \
-H "Authorization: Bearer ${API_KEY}" | jq .
echo ""
echo ""
echo "3. Simple Query"
echo "==============="
curl -s "${API_URL}/ai/query?q=What%20is%20machine%20learning%3F" \
-H "Authorization: Bearer ${API_KEY}" | jq .
echo ""
echo ""
echo "4. Chat Conversation"
echo "===================="
curl -s -X POST "${API_URL}/ai/chat" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"conversation": [
{
"role": "user",
"content": "Explain quantum computing in simple terms"
}
],
"options": {
"temperature": 0.7,
"max_tokens": 200
}
}' | jq .
echo ""
echo ""
echo "5. RAG Query (with retrieval)"
echo "============================="
curl -s -X POST "${API_URL}/rag/query" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"query": "What are the key features?",
"top_k": 5,
"use_retrieval": true
}' | jq .
echo ""
echo ""
echo "6. Image Generation"
echo "==================="
curl -s -X POST "${API_URL}/image/generate" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A serene mountain landscape at sunset",
"size": "1024x1024",
"n": 1
}' | jq .
echo ""
echo ""
echo "7. Voice Synthesis"
echo "=================="
curl -s -X POST "${API_URL}/voice/synthesize" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"text": "Hello, this is a test of the voice synthesis system.",
"voice": "alloy",
"format": "mp3"
}' | jq .
echo ""
echo ""
echo "8. Document Upload"
echo "=================="
CONTENT=$(echo "This is a sample document for testing." | base64)
curl -s -X POST "${API_URL}/upload" \
-H "Authorization: Bearer ${API_KEY}" \
-H "Content-Type: application/json" \
-d "{
\"filename\": \"sample.txt\",
\"content_base64\": \"${CONTENT}\",
\"metadata\": {
\"title\": \"Sample Document\",
\"category\": \"test\"
}
}" | jq .
echo ""
echo ""
echo "9. Get Metrics"
echo "=============="
curl -s "${API_URL}/metrics" \
-H "Authorization: Bearer ${API_KEY}" | jq .
echo ""
echo ""
echo "10. Get Available Models"
echo "======================="
curl -s "${API_URL}/rag/models" \
-H "Authorization: Bearer ${API_KEY}" | jq .
echo ""