Skip to content

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

  1. Login to app.inspirahub.net
  2. Navigate to Settings → API Keys
  3. Click "Generate New Key"
  4. 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

bash
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

json
{
  "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:

bash
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:

json
{
  "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:

ServiceCredits per RequestNotes
Inspira EduFi Tutoring10Variable based on message length
Image Generation4-7Depends on model and size
Video Generation10Per video created
Book Grading2Per grading request

Internal Web App Pricing

For users accessing through app.inspirahub.net:

ServiceCredits per RequestNotes
EduFi Tutoring10All curriculum types
Image Generation4-7Same as API
Video Generation10Same as API
Book Grading2Same 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

PlanRequests/MinuteRequests/HourConcurrent
Free101001
Pro6010005
Ultra120500010
EnterpriseCustomCustomCustom

Error Handling

The API uses standard HTTP status codes:

CodeMeaning
200Success
400Bad Request - Invalid parameters
401Unauthorized - Invalid API key
402Payment Required - Insufficient credits
429Too Many Requests - Rate limit exceeded
500Internal Server Error

Error Response Format

json
{
  "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

bash
npm install @inspirahub/sdk
javascript
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

bash
pip install inspira-sdk
python
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:

  1. Set webhook URL in dashboard
  2. Choose events to monitor
  3. Receive POST requests for events

Webhook Events

  • generation.completed - When AI generation finishes
  • credits.low - When credits fall below threshold
  • subscription.renewed - When subscription renews
  • api_key.used - When API key is used (security)

Best Practices

1. Implement Retry Logic

javascript
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?


Rate Limit Headers

Every API response includes rate limit information:

  • X-RateLimit-Limit: Maximum requests allowed
  • X-RateLimit-Remaining: Requests remaining
  • X-RateLimit-Reset: Time when limit resets (Unix timestamp)

Revolutionizing Education with AI and Web3