Spark: Electrical Engineering Assistant
Spark: Electrical Engineering Assistant · Acciones GPT
Enhanced Engineer AI API
Electrical Engineering AI with deterministic calculations, voltage drop analysis, AI verification, PDF redaction, chatbot, OCR, and professional reporting with user preferences
GET /Get API status and available featuresGET /healthHealth checkGET /debugGet detailed system status and capabilitiesPOST /runRun electrical engineering calculation with AI model preferencePOST /chatConversational AI for electrical engineering assistancePOST /chat/preferencesUpdate user preferences for chat sessionGET /chat/sessionsList active chat sessionsGET /chat/sessions/{session_id}Get chat session historyDELETE /chat/sessions/{session_id}Delete chat sessionPOST /pdf/redactRedact sensitive information from engineering drawings with user controlPOST /pdf/redact-base64Redact PDF from base64 input (GPT Actions friendly)POST /pdf/extract-base64Extract technical content from base64 PDF (GPT Actions friendly)POST /pdf/extractExtract technical content from engineering drawingsPOST /report/pdf/base64Generate PDF report as base64 JSONPOST /reportGenerate PDF report (legacy endpoint)POST /buildReportBuild PDF report (legacy endpoint)GET /nec/conductor-ampacity/{conductor_size}Get conductor ampacity with derating factorsGET /nec/ocpd/{current}Get next standard OCPD ratingPOST /ocr/nameplateExtract electrical data from nameplate photosPOST /ocr/technical-drawingExtract data from technical drawings and schematicsPOST /ocr/create-taskCreate calculation task from nameplate data
Esquema original API
{
"openapi": "3.1.0",
"info": {
"title": "Enhanced Engineer AI API",
"version": "0.3.0",
"description": "Electrical Engineering AI with deterministic calculations, voltage drop analysis, AI verification, PDF redaction, chatbot, OCR, and professional reporting with user preferences"
},
"servers": [
{
"url": "https://gpt-deepseek-production.up.railway.app"
}
],
"paths": {
"/": {
"get": {
"operationId": "root",
"summary": "Get API status and available features",
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"status": {
"type": "string"
},
"version": {
"type": "string"
},
"features": {
"type": "array",
"items": {
"type": "string"
}
},
"ai_models": {
"type": "object",
"properties": {
"available": {
"type": "array",
"items": {
"type": "string"
}
},
"preferences": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
}
},
"/health": {
"get": {
"operationId": "health",
"summary": "Health check",
"responses": {
"200": {
"description": "OK"
}
}
}
},
"/debug": {
"get": {
"operationId": "debug",
"summary": "Get detailed system status and capabilities",
"responses": {
"200": {
"description": "System debug information"
}
}
}
},
"/run": {
"post": {
"operationId": "run_endpoint",
"summary": "Run electrical engineering calculation with AI model preference",
"security": [
{
"ApiKeyAuth": []
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"prompt"
],
"properties": {
"prompt": {
"type": "string",
"description": "Electrical engineering question or task"
},
"opts": {
"type": "object",
"properties": {
"mode": {
"type": "string",
"enum": [
"calc_only",
"ai_only",
"hybrid_validate",
"ai_verify",
"comprehensive"
],
"default": "hybrid_validate",
"description": "Calculation mode"
},
"task": {
"type": "string",
"enum": [
"voltage_drop",
"feeder_sizing",
"transformer_sizing",
"fault_current",
"gec_sizing",
"derating",
"load_calc",
"conduit_fill",
"short_circuit"
],
"description": "Specific calculation task"
},
"ai_preference": {
"type": "string",
"enum": [
"auto",
"gpt_only",
"deepseek_only"
],
"default": "auto",
"description": "AI model preference for calculations and verification"
},
"verification_type": {
"type": "string",
"enum": [
"quick",
"standard",
"comprehensive"
],
"default": "standard",
"description": "Level of AI verification to perform"
},
"load_kw": {
"type": "number",
"description": "Load in kilowatts"
},
"voltage": {
"type": "number",
"description": "System voltage"
},
"phases": {
"type": "integer",
"enum": [
0,
1,
3
],
"description": "Number of phases (0 for DC)"
},
"distance_ft": {
"type": "number",
"description": "Distance in feet"
},
"current_amps": {
"type": "number",
"description": "Current in amperes"
},
"conductor_size": {
"type": "string",
"description": "Conductor size (AWG or kcmil)"
},
"ambient_temp_c": {
"type": "number",
"default": 30,
"description": "Ambient temperature in Celsius"
},
"power_factor": {
"type": "number",
"default": 0.9,
"description": "Power factor"
}
}
},
"data": {
"type": "object",
"description": "Additional calculation data"
}
}
}
}
}
},
"responses": {
"200": {
"description": "Calculation completed successfully",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/EnhancedRunResponse"
}
}
}
}
}
}
},
"/chat": {
"post": {
"operationId": "chat_endpoint",
"summary": "Conversational AI for electrical engineering assistance",
"security": [
{
"ApiKeyAuth": []
}
],
"parameters": [
{
"name": "session_id",
"in": "query",
"required": false,
"schema": {
"type": "string"
},
"description": "Session ID for conversation continuity"
},
{
"name": "user_id",
"in": "query",
"required": false,
"schema": {
"type": "string"
},
"description": "User identifier"
},
{
"name": "ai_preference",
"in": "query",
"required": false,
"schema": {
"type": "string",
"enum": [
"auto",
"gpt_only",
"deepseek_only"
],
"default": "auto"
},
"description": "AI model preference"
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"message"
],
"properties": {
"message": {
"type": "string",
"description": "User message or question"
}
}
}
}
}
},
"responses": {
"200": {
"description": "Chat response generated",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"response": {
"type": "string"
},
"session_id": {
"type": "string"
},
"conversation_length": {
"type": "integer"
},
"metadata": {
"type": "object"
},
"suggested_action": {
"type": "object"
},
"calculation_intent": {
"type": "object"
},
"ai_preference_used": {
"type": "string"
},
"timestamp": {
"type": "string"
}
}
}
}
}
}
}
}
},
"/chat/preferences": {
"post": {
"operationId": "update_chat_preferences",
"summary": "Update user preferences for chat session",
"security": [
{
"ApiKeyAuth": []
}
],
"parameters": [
{
"name": "session_id",
"in": "query",
"required": true,
"schema": {
"type": "string"
},
"description": "Session ID to update"
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"ai_model": {
"type": "string",
"enum": [
"auto",
"gpt_only",
"deepseek_only"
],
"description": "Preferred AI model"
},
"redaction_enabled": {
"type": "boolean",
"description": "Enable PDF redaction by default"
},
"current_project": {
"type": "string",
"description": "Current project name"
}
}
}
}
}
},
"responses": {
"200": {
"description": "Preferences updated"
}
}
}
},
"/chat/sessions": {
"get": {
"operationId": "list_chat_sessions",
"summary": "List active chat sessions",
"security": [
{
"ApiKeyAuth": []
}
],
"parameters": [
{
"name": "user_id",
"in": "query",
"required": false,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "List of sessions"
}
}
}
},
"/chat/sessions/{session_id}": {
"get": {
"operationId": "get_chat_session",
"summary": "Get chat session history",
"security": [
{
"ApiKeyAuth": []
}
],
"parameters": [
{
"name": "session_id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Session data"
}
}
},
"delete": {
"operationId": "delete_chat_session",
"summary": "Delete chat session",
"security": [
{
"ApiKeyAuth": []
}
],
"parameters": [
{
"name": "session_id",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "Session deleted"
}
}
}
},
"/pdf/redact": {
"post": {
"operationId": "redact_pdf",
"summary": "Redact sensitive information from engineering drawings with user control",
"security": [
{
"ApiKeyAuth": []
}
],
"requestBody": {
"required": true,
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"required": [
"file"
],
"properties": {
"file": {
"type": "string",
"format": "binary",
"description": "PDF file to process"
},
"enable_redaction": {
"type": "boolean",
"default": true,
"description": "Enable or disable redaction (returns original if false)"
},
"company_terms": {
"type": "string",
"description": "Comma-separated additional company terms to redact"
},
"nuke_whole_title_block": {
"type": "boolean",
"default": false,
"description": "Redact entire title block"
}
}
}
}
}
},
"responses": {
"200": {
"description": "PDF processed successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"redacted_pdf_base64": {
"type": "string",
"description": "Base64 encoded PDF"
},
"redaction_enabled": {
"type": "boolean"
},
"company_terms_used": {
"type": "array",
"items": {
"type": "string"
}
},
"title_block_nuked": {
"type": "boolean"
},
"original_size_bytes": {
"type": "integer"
},
"redacted_size_bytes": {
"type": "integer"
},
"instructions": {
"type": "string"
}
}
}
}
}
}
}
}
},
"/pdf/redact-base64": {
"post": {
"operationId": "redact_pdf_base64",
"summary": "Redact PDF from base64 input (GPT Actions friendly)",
"security": [
{
"ApiKeyAuth": []
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"pdf_base64"
],
"properties": {
"pdf_base64": {
"type": "string",
"description": "Base64 encoded PDF file"
},
"enable_redaction": {
"type": "boolean",
"default": true,
"description": "Enable or disable redaction"
},
"company_terms": {
"type": "string",
"description": "Comma-separated additional company terms"
},
"nuke_whole_title_block": {
"type": "boolean",
"default": false,
"description": "Redact entire title block"
}
}
}
}
}
},
"responses": {
"200": {
"description": "PDF processed successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"redacted_pdf_base64": {
"type": "string",
"description": "Base64 encoded redacted PDF"
},
"redaction_enabled": {
"type": "boolean"
},
"company_terms_used": {
"type": "array",
"items": {
"type": "string"
}
},
"title_block_nuked": {
"type": "boolean"
},
"original_size_bytes": {
"type": "integer"
},
"redacted_size_bytes": {
"type": "integer"
},
"message": {
"type": "string"
}
}
}
}
}
}
}
}
},
"/pdf/extract-base64": {
"post": {
"operationId": "extract_pdf_content_base64",
"summary": "Extract technical content from base64 PDF (GPT Actions friendly)",
"security": [
{
"ApiKeyAuth": []
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"pdf_base64"
],
"properties": {
"pdf_base64": {
"type": "string",
"description": "Base64 encoded PDF file"
},
"max_pages": {
"type": "integer",
"minimum": 1,
"maximum": 10,
"default": 3,
"description": "Maximum pages to process"
},
"limit": {
"type": "integer",
"minimum": 100,
"maximum": 10000,
"default": 3000,
"description": "Character limit for output"
}
}
}
}
}
},
"responses": {
"200": {
"description": "Text extracted successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"extracted_text": {
"type": "string"
},
"pages_processed": {
"type": "integer"
},
"character_limit": {
"type": "integer"
},
"original_size_bytes": {
"type": "integer"
}
}
}
}
}
}
}
}
},
"/pdf/extract": {
"post": {
"operationId": "extract_pdf_content",
"summary": "Extract technical content from engineering drawings",
"security": [
{
"ApiKeyAuth": []
}
],
"parameters": [
{
"name": "max_pages",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"minimum": 1,
"maximum": 10,
"default": 3
}
},
{
"name": "limit",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"minimum": 100,
"maximum": 10000,
"default": 3000
}
}
],
"requestBody": {
"required": true,
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"required": [
"file"
],
"properties": {
"file": {
"type": "string",
"format": "binary",
"description": "PDF file to extract text from"
}
}
}
}
}
},
"responses": {
"200": {
"description": "Text extracted successfully",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"extracted_text": {
"type": "string"
},
"pages_processed": {
"type": "integer"
},
"character_limit": {
"type": "integer"
},
"original_size_bytes": {
"type": "integer"
}
}
}
}
}
}
}
}
},
"/report/pdf/base64": {
"post": {
"operationId": "generatePdfReportBase64",
"summary": "Generate PDF report as base64 JSON",
"security": [
{
"ApiKeyAuth": []
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"structured": {
"type": "object",
"description": "Structured calculation data"
},
"metadata": {
"type": "object",
"description": "Report metadata"
},
"calc_results": {
"type": "array",
"items": {
"type": "object"
},
"description": "Calculation results"
},
"citations": {
"type": "array",
"items": {
"type": "object"
},
"description": "NEC code citations"
},
"project_title": {
"type": "string",
"default": "Electrical Engineering Report",
"description": "Report title"
},
"client_name": {
"type": "string",
"description": "Client name"
}
}
}
}
}
},
"responses": {
"200": {
"description": "PDF generated as base64",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"pdf_base64": {
"type": "string"
},
"filename": {
"type": "string"
},
"size_bytes": {
"type": "integer"
},
"instructions": {
"type": "string"
}
}
}
}
}
}
}
}
},
"/report": {
"post": {
"operationId": "generateReport",
"summary": "Generate PDF report (legacy endpoint)",
"security": [
{
"ApiKeyAuth": []
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"structured": {
"type": "object"
},
"metadata": {
"type": "object"
},
"project_title": {
"type": "string"
}
}
}
}
}
},
"responses": {
"200": {
"description": "PDF generated as base64"
}
}
}
},
"/buildReport": {
"post": {
"operationId": "buildReport",
"summary": "Build PDF report (legacy endpoint)",
"security": [
{
"ApiKeyAuth": []
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"structured": {
"type": "object"
},
"metadata": {
"type": "object"
},
"project_title": {
"type": "string"
}
}
}
}
}
},
"responses": {
"200": {
"description": "PDF generated as base64"
}
}
}
},
"/nec/conductor-ampacity/{conductor_size}": {
"get": {
"operationId": "get_conductor_ampacity_endpoint",
"summary": "Get conductor ampacity with derating factors",
"security": [
{
"ApiKeyAuth": []
}
],
"parameters": [
{
"name": "conductor_size",
"in": "path",
"required": true,
"schema": {
"type": "string"
},
"description": "Conductor size (AWG or kcmil)"
},
{
"name": "temp_c",
"in": "query",
"required": false,
"schema": {
"type": "number",
"default": 30
},
"description": "Ambient temperature in Celsius"
},
{
"name": "bundling_count",
"in": "query",
"required": false,
"schema": {
"type": "integer",
"default": 3
},
"description": "Number of conductors bundled together"
}
],
"responses": {
"200": {
"description": "Conductor ampacity information"
}
}
}
},
"/nec/ocpd/{current}": {
"get": {
"operationId": "get_standard_ocpd_endpoint",
"summary": "Get next standard OCPD rating",
"security": [
{
"ApiKeyAuth": []
}
],
"parameters": [
{
"name": "current",
"in": "path",
"required": true,
"schema": {
"type": "number"
},
"description": "Calculated current in amperes"
}
],
"responses": {
"200": {
"description": "Standard OCPD rating"
}
}
}
},
"/ocr/nameplate": {
"post": {
"operationId": "extract_nameplate_data",
"summary": "Extract electrical data from nameplate photos",
"security": [
{
"ApiKeyAuth": []
}
],
"requestBody": {
"required": true,
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"required": [
"file"
],
"properties": {
"file": {
"type": "string",
"format": "binary",
"description": "Image file of electrical nameplate"
}
}
}
}
}
},
"responses": {
"200": {
"description": "Nameplate data extracted",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"extracted_data": {
"type": "object"
},
"metadata": {
"type": "object"
}
}
}
}
}
}
}
}
},
"/ocr/technical-drawing": {
"post": {
"operationId": "extract_technical_drawing_data",
"summary": "Extract data from technical drawings and schematics",
"security": [
{
"ApiKeyAuth": []
}
],
"requestBody": {
"required": true,
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"required": [
"file"
],
"properties": {
"file": {
"type": "string",
"format": "binary",
"description": "Image file of technical drawing"
}
}
}
}
}
},
"responses": {
"200": {
"description": "Technical drawing data extracted",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"extracted_data": {
"type": "object"
},
"metadata": {
"type": "object"
}
}
}
}
}
}
}
}
},
"/ocr/create-task": {
"post": {
"operationId": "create_task_from_nameplate_endpoint",
"summary": "Create calculation task from nameplate data",
"security": [
{
"ApiKeyAuth": []
}
],
"requestBody": {
"required": true,
"content": {
"multipart/form-data": {
"schema": {
"type": "object",
"required": [
"file"
],
"properties": {
"file": {
"type": "string",
"format": "binary",
"description": "Image file of electrical nameplate"
}
}
}
}
}
},
"responses": {
"200": {
"description": "Calculation task created from nameplate",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"task_data": {
"type": "object"
},
"suggested_calculations": {
"type": "array",
"items": {
"type": "string"
}
}
}
}
}
}
}
}
}
}
},
"components": {
"securitySchemes": {
"ApiKeyAuth": {
"type": "apiKey",
"in": "header",
"name": "X-Api-Key"
}
},
"schemas": {
"EnhancedRunResponse": {
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"content": {
"type": "string",
"description": "Human-readable calculation results"
},
"structured": {
"type": "object",
"description": "Structured calculation data"
},
"citations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"nec_section": {
"type": "string"
},
"title": {
"type": "string"
}
}
},
"description": "NEC code references"
},
"calc_results": {
"type": "array",
"items": {
"type": "object"
},
"description": "Detailed calculation results"
},
"metrics": {
"type": "object",
"description": "Performance and usage metrics"
},
"ai_verification": {
"type": "object",
"properties": {
"model": {
"type": "string"
},
"verification": {
"type": "string"
},
"confidence_score": {
"type": "number"
},
"issues_found": {
"type": "array",
"items": {
"type": "string"
}
},
"recommendations": {
"type": "array",
"items": {
"type": "string"
}
},
"cost_estimate": {
"type": "string"
}
},
"description": "AI verification results (when requested)"
},
"metadata": {
"type": "object",
"properties": {
"source": {
"type": "string"
},
"model": {
"type": "string"
},
"timestamp": {
"type": "string"
},
"request_id": {
"type": "string"
},
"processing_time_ms": {
"type": "integer"
}
},
"description": "Response metadata"
}
}
}
}
}
}