Incept Python SDK
A Python client library for the Incept Question Generation API.
Installation
pip install incept-python-sdk
Quick Start
from incept import InceptClient
# Initialize the client
client = InceptClient(api_key="your-api-key-here")
# Generate questions
response = client.generate_questions(
grade=5,
instructions="Generate questions about fractions",
count=3,
difficulty="medium"
)
print(f"Generated {len(response.data)} questions")
for question in response.data:
print(f"Q: {question.question}")
print(f"A: {question.answer}")
Configuration
Initialize Client
from incept import InceptClient
# Basic configuration
client = InceptClient(api_key="your-api-key")
# Custom endpoint and timeout
client = InceptClient(
api_key="your-api-key",
base_url="https://your-custom-endpoint.com",
timeout=60 # seconds
)
API Methods
Generate Questions
Generate educational questions with comprehensive options:
response = client.generate_questions(
grade=7,
instructions="Create algebra problems",
count=5,
question_type="mcq",
language="english",
difficulty="medium",
subject="mathematics",
model="openai",
translate=False,
evaluate=True,
skill={
"id": "algebra_basics",
"title": "Linear Equations",
"unit_name": "Algebra",
"lesson_title": "Solving Equations"
},
topic="Linear Equations",
student_level="average"
)
# Access generated questions
for question in response.data:
print(f"Question: {question.question}")
print(f"Answer: {question.answer}")
print(f"Difficulty: {question.difficulty}")
if question.options:
print(f"Options: {question.options}")
if question.detailed_explanation:
for step in question.detailed_explanation.steps:
print(f"Step: {step.title} - {step.content}")
# Check evaluation results (if evaluate=True)
if response.evaluation:
print(f"Overall Score: {response.evaluation.overall_score}")
print(f"Recommendations: {response.evaluation.recommendations}")
Completions
Get text completions:
response = client.completions(
messages=[
{"role": "system", "content": "You are a helpful math tutor"},
{"role": "user", "content": "Explain the Pythagorean theorem"}
],
provider="openai",
max_tokens=1000,
language="english"
)
print(response.response)
Wolfram Alpha Integration
Solve math problems using Wolfram Alpha:
response = client.wolfram_solve(
question_text="What is the derivative of x^2 + 3x + 2?",
subject="calculus",
app_id="your-wolfram-app-id"
)
print(f"Solution: {response.solution}")
if response.steps:
for step in response.steps:
print(f"Step: {step}")
Health Check
Check API status:
health = client.health_check()
print(f"Status: {health['status']}")
API Documentation
Get API documentation:
docs = client.get_api_documentation()
print(docs)
Request Parameters
GenerateQuestionsRequest
| Parameter | Type | Default | Description |
|---|---|---|---|
grade |
int | required | Grade level (0-12) |
instructions |
str | required | Instructions for question generation |
count |
int | 5 | Number of questions (1-100) |
question_type |
str | "mcq" | Question type (currently only "mcq") |
language |
str | "english" | Content language |
difficulty |
str | "mixed" | Difficulty level: "easy", "medium", "hard", "expert", "mixed" |
subject |
str | None | Subject override |
model |
str | "openai" | AI model: "openai", "falcon" |
translate |
bool | False | Enable translation |
evaluate |
bool | False | Enable quality evaluation |
skill |
dict | None | Skill context information |
topic |
str | None | Topic specification |
subtopic |
str | None | Subtopic specification |
unit |
str | None | Unit specification |
student_level |
str | None | Student level: "struggling", "average", "advanced" |
previous_mistakes |
list | None | Previous student mistakes |
Response Models
GeneratedQuestion
{
"type": "mcq",
"question": "What is 2 + 2?",
"answer": "A",
"difficulty": "easy",
"explanation": "Addition of two numbers...",
"options": ["4", "3", "5", "6"],
"detailed_explanation": {
"steps": [...],
"personalized_academic_insights": [...]
},
"voiceover_script": {...},
"image_url": "https://...",
"di_formats_used": [...]
}
EvaluationInfo
{
"overall_score": 0.85,
"scores": {
"clarity": 0.9,
"difficulty": 0.8,
"relevance": 0.9
},
"recommendations": [
"Consider adding more visual aids",
"Simplify the language for grade level"
],
"report": "Overall excellent question quality..."
}
Error Handling
The SDK provides specific exception types for different error scenarios:
from incept import InceptClient
from incept.exceptions import (
AuthenticationError,
ValidationError,
RateLimitError,
ServerError,
NetworkError,
InceptAPIError
)
client = InceptClient(api_key="your-api-key")
try:
response = client.generate_questions(
grade=5,
instructions="Generate questions about fractions",
count=3
)
except AuthenticationError:
print("Invalid API key")
except ValidationError as e:
print(f"Validation error: {e}")
except RateLimitError:
print("Rate limit exceeded, please wait")
except ServerError as e:
print(f"Server error: {e}")
except NetworkError as e:
print(f"Network error: {e}")
except InceptAPIError as e:
print(f"API error: {e}")
Development
Install from source
git clone https://github.com/incept/incept-python-sdk
cd incept-python-sdk
pip install -e .
Install development dependencies
pip install -e ".[dev]"
Run tests
pytest
Format code
black incept/
Lint code
flake8 incept/
License
MIT License
Support
For support, please contact support@inceptapi.com or visit our documentation at https://docs.inceptapi.com.
Release files for incept-python-sdk 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| incept_python_sdk-0.1.2.tar.gz | 18.0 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| incept_python_sdk-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.3 kB
Release files / incept_python_sdk-0.1.2.tar.gz
| Download URL | incept_python_sdk-0.1.2.tar.gz |
|---|---|
| Size | 18.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a156076dae1c77444a7626fc578cedafc4328fa09d42637bbcacdd0269581b50
|
|
BLAKE2b-256 checksum How to use checksums |
65d862acb4b0f8217b1d27fb565b2b791fd1c211ef52196ec23aa58bb8a64d55
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|
Release files / incept_python_sdk-0.1.2-py3-none-any.whl
| Download URL | incept_python_sdk-0.1.2-py3-none-any.whl |
|---|---|
| Size | 14.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9a553c17d320d73f07160178f6f5e2fdc3e8633d3bb8681b023bca5f13edd0ac
|
|
BLAKE2b-256 checksum How to use checksums |
722d5d9d775b0bf5568e7c290f243535d4db2e9dc3ada6c8d998798e8aaa42ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.13
|