API Reference
Build powerful applications with Inspira's comprehensive API. Access all AI features programmatically with simple REST endpoints.
Overview
The Inspira API provides developers with:
- RESTful Endpoints: Simple HTTP-based API
- Authentication: Secure API key authentication
- Rate Limiting: Fair usage policies
- Credit-Based Billing: Same transparent pricing
- Multiple SDKs: JavaScript, Python, and more
Getting Started
1. Get Your API Key
- Login to app.inspirahub.net
- Navigate to Settings → API Keys
- Click "Generate New Key"
- Copy and secure your key
Security Notice
Never expose your API key in client-side code or public repositories. Keep it secure on your server.
2. Make Your First Request
curl -X POST https://app.inspirahub.net/api/rest/generate-image \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A beautiful sunset over mountains",
"style": "photorealistic",
"size": "1024x1024"
}'
3. Handle the Response
{
"success": true,
"data": {
"id": "img_123456",
"url": "https://cdn.inspirahub.net/images/img_123456.png",
"prompt": "A beautiful sunset over mountains",
"credits_used": 10,
"created_at": "2025-01-06T12:00:00Z"
},
"credits_remaining": 490
}
Available Endpoints
Image Generation
POST /v1/images/generate
Generate AI images from text prompts
Video Creation
POST /v1/videos/create
Create AI-powered video content
Chat Completion
POST /v1/chat/completions
Interact with AI chat assistant
Book Grading
POST /v1/education/grade-book
Analyze and grade educational content
Inspira EduFi Tutoring Services
Access AI-powered tutoring for global education curricula
United States Education System
POST /v1/edufi/us/ap-assistant
Inspira Advanced Placement (AP) Course Assistant
POST /v1/edufi/us/college-prep
Inspira US College Preparation Assistant
United Kingdom Education System
POST /v1/edufi/uk/gcse-assistant
Inspira GCSE (General Certificate of Secondary Education) Assistant
POST /v1/edufi/uk/a-level-assistant
Inspira A-Level Assistant
POST /v1/edufi/uk/college-prep
Inspira UK College Preparation Assistant
European Education System
POST /v1/edufi/europe/european-baccalaureate
Inspira European Baccalaureate Assistant
POST /v1/edufi/europe/national-exams
Inspira European National Exams Assistant
POST /v1/edufi/europe/university-prep
Inspira European University Preparation Assistant
Global Education Standards
POST /v1/edufi/global/international-baccalaureate
Inspira International Baccalaureate (IB) Assistant
POST /v1/edufi/global/language-prep
Inspira Global Language Preparation Assistant
Credit Management
GET /v1/credits/balance
GET /v1/credits/history
POST /v1/credits/purchase
Manage your credit balance and history
EduFi API Example
Here's how to use the Inspira AP Course Assistant:
curl -X POST https://app.inspirahub.net/api/rest/edufi-tools/tutor-agent \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"message": "Explain photosynthesis for AP Biology",
"conversationHistory": []
}'
Response:
{
"success": true,
"response": "Photosynthesis is the process where plants convert light energy into chemical energy. It occurs in chloroplasts and has two main stages: light-dependent reactions in thylakoids produce ATP and NADPH, while the Calvin cycle in the stroma uses these to convert CO2 into glucose. The overall equation is 6CO2 + 6H2O + light energy → C6H12O6 + 6O2 + 6H2O."
}
All EduFi Endpoints Use Same Format
All Inspira EduFi tutoring endpoints accept the same request format:
- message: The student's question or topic
- conversationHistory: Array of previous messages (optional)
Each endpoint is specialized for its specific curriculum (AP, GCSE, A-Level, IB, etc.) and provides contextually appropriate responses.
Pricing Structure
Developer API Pricing
For external developers using API keys:
Service | Credits per Request | Notes |
---|---|---|
Inspira EduFi Tutoring | 10 | Variable based on message length |
Image Generation | 4-7 | Depends on model and size |
Video Generation | 10 | Per video created |
Book Grading | 2 | Per grading request |
Internal Web App Pricing
For users accessing through app.inspirahub.net:
Service | Credits per Request | Notes |
---|---|---|
EduFi Tutoring | 10 | All curriculum types |
Image Generation | 4-7 | Same as API |
Video Generation | 10 | Same as API |
Book Grading | 2 | Same as API |
Pricing Difference
Developer API pricing is significantly lower to encourage integration and development. Web app pricing includes additional features like conversation history, session management, and enhanced UI interactions.
Authentication
All API requests must include your API key in the Authorization header:
Authorization: Bearer YOUR_API_KEY
Rate Limits
Plan | Requests/Minute | Requests/Hour | Concurrent |
---|---|---|---|
Free | 10 | 100 | 1 |
Pro | 60 | 1000 | 5 |
Ultra | 120 | 5000 | 10 |
Enterprise | Custom | Custom | Custom |
Error Handling
The API uses standard HTTP status codes:
Code | Meaning |
---|---|
200 | Success |
400 | Bad Request - Invalid parameters |
401 | Unauthorized - Invalid API key |
402 | Payment Required - Insufficient credits |
429 | Too Many Requests - Rate limit exceeded |
500 | Internal Server Error |
Error Response Format
{
"success": false,
"error": {
"code": "insufficient_credits",
"message": "You need at least 10 credits for this operation",
"credits_required": 10,
"credits_available": 5
}
}
SDKs and Libraries
JavaScript/TypeScript
npm install @inspirahub/sdk
import { InspiraClient } from '@inspirahub/sdk';
const client = new InspiraClient('YOUR_API_KEY');
// Generate an image
const image = await client.images.generate({
prompt: 'A futuristic city',
style: 'cyberpunk'
});
console.log(image.url);
// Use AP Course Assistant
const apResponse = await client.edufi.ap.ask({
message: 'Explain calculus derivatives',
conversationHistory: []
});
console.log(apResponse.response);
Python
pip install inspira-sdk
from inspira import InspiraClient
client = InspiraClient('YOUR_API_KEY')
# Generate an image
image = client.images.generate(
prompt="A futuristic city",
style="cyberpunk"
)
print(image.url)
# Use AP Course Assistant
ap_response = client.edufi.ap.ask(
message="Explain calculus derivatives",
conversation_history=[]
)
print(ap_response.response)
Webhooks
Configure webhooks to receive real-time notifications:
- Set webhook URL in dashboard
- Choose events to monitor
- Receive POST requests for events
Webhook Events
generation.completed
- When AI generation finishescredits.low
- When credits fall below thresholdsubscription.renewed
- When subscription renewsapi_key.used
- When API key is used (security)
Best Practices
1. Implement Retry Logic
async function generateWithRetry(prompt, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await client.images.generate({ prompt });
} catch (error) {
if (error.code === 'RATE_LIMIT' && i < maxRetries - 1) {
await sleep(Math.pow(2, i) * 1000); // Exponential backoff
continue;
}
throw error;
}
}
}
2. Cache Responses
- Cache generated content URLs
- Store metadata locally
- Reduce redundant API calls
3. Monitor Usage
- Track credit consumption
- Set up alerts for low balance
- Monitor rate limit headers
4. Handle Errors Gracefully
- Provide user-friendly error messages
- Log errors for debugging
- Implement fallback strategies
API Playground
Test API endpoints directly in your browser:
Support
Need help with the API?
- Documentation: You're here!
- API Status: status.inspirahub.net
- Developer Telegram: Join Community
- Email Support: api@inspirahub.net
Rate Limit Headers
Every API response includes rate limit information:
X-RateLimit-Limit
: Maximum requests allowedX-RateLimit-Remaining
: Requests remainingX-RateLimit-Reset
: Time when limit resets (Unix timestamp)