Tutorial: Integrating LLM Council APIs into Your Application
A complete guide to integrating SPRAPP APIs into your applications for automated multi-model AI queries.
LLM council APIAPI integrationmulti-model AIcouncil of AIsdeveloper guide
API Integration Overview
SPRAPP provides RESTful APIs for integrating LLM council capabilities into your applications. This tutorial covers everything you need.
Authentication
Getting Your API Key
- Log into SPRAPP
- Navigate to Settings > API
- Generate a new API key
- Store securely (never commit to git)
Using the Key
curl -X POST https://api.sprapp.com/v1/council/query \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "Explain quantum computing"}'
Basic Query
Request Format
{
"query": "Your question here",
"council": "default",
"mode": "consensus",
"models": ["claude-3.5-sonnet", "gpt-4o", "gemini-1.5-pro"]
}
Response Format
{
"response": "The synthesized answer...",
"consensus": true,
"confidence": 0.94,
"model_responses": [...],
"latency_ms": 3420
}
Integration Examples
Python
import requests
def query_council(question):
response = requests.post(
"https://api.sprapp.com/v1/council/query",
headers={"Authorization": f"Bearer {API_KEY}"},
json={"query": question, "mode": "consensus"}
)
return response.json()
result = query_council("What is machine learning?")
print(result["response"])
JavaScript/Node.js
const response = await fetch('https://api.sprapp.com/v1/council/query', {
method: 'POST',
headers: {
'Authorization': `Bearer ${API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({ query: 'Your question', mode: 'consensus' })
});
const data = await response.json();
Error Handling
Rate Limits
- Free tier: 100 requests/day
- Lite tier: 1000 requests/day
- Pro tier: Unlimited
Handle 429 errors with exponential backoff.
Timeouts
Set reasonable timeouts:
- Minimum: 30 seconds
- Recommended: 60 seconds
- Long queries: 120 seconds
Best Practices
- Cache frequent queries
- Implement retry logic
- Log responses for debugging
- Monitor API usage
- Use streaming for long responses
Your application is now ready to leverage the power of LLM councils!