Skip to main content

Get Answer

Get an AI-generated response to user inputs with support for multi-modal content including text, images, and files.

Endpoint

PUT /api/v1/assistant/get-answer

Authentication

Requires valid session authentication via middleware.

Request Format

The request must be sent as multipart/form-data to support file uploads.

Parameters

ParameterTypeRequiredDescription
inputsArrayYesArray of conversation inputs
toolKitSettingsObjectYesAI model configuration
filesFile[]NoUploaded files (images, documents)

Input Object Structure

{
"role": "user", // "user" | "assistant" | "system"
"value": "Your question or message",
"imageUrls": ["url1", "url2"], // Optional image URLs
"files": [
{
"name": "document.pdf",
"id": "file-id",
"type": "application/pdf"
}
]
}

ToolKit Settings

{
"model": "gpt-4o", // AI model to use
"temperature": 0.7, // 0.0 - 1.0, creativity level
"chatLang": "english", // "english" | "hebrew" | "none"
"isMultiple": false, // Multiple responses
"isLongAnswer": false, // Extended response format
"isTypingEffect": true, // Typing animation
"question_choice": ["Vectors"], // ["Vectors", "Q&A"]
"embeddingModel": "text-embedding-ada-002" // For document search
}

Example Request

const formData = new FormData();

// Add conversation inputs
formData.append(
'inputs',
JSON.stringify([
{
role: 'user',
value: 'Explain quantum computing in simple terms',
},
])
);

// Add toolkit settings
formData.append(
'toolKitSettings',
JSON.stringify({
model: 'gpt-4o',
temperature: 0.7,
chatLang: 'english',
isMultiple: false,
isLongAnswer: false,
isTypingEffect: true,
})
);

// Add files if any
formData.append('files', fileInput.files[0]);

const response = await fetch('/api/v1/assistant/get-answer', {
method: 'PUT',
body: formData,
});

Response

Success Response (200)

{
"QuestionInEnglish": "Explain quantum computing in simple terms",
"AnsFromAi": "Quantum computing is a revolutionary approach to computation that...",
"categoryText": "",
"sentimentText": ""
}

Response Fields

FieldTypeDescription
QuestionInEnglishstringThe user's question translated to English
AnsFromAistringThe AI-generated response
categoryTextstringCategory classification (optional)
sentimentTextstringSentiment analysis (optional)

Error Responses

400 Bad Request

{
"error": "Invalid payload structure"
}

429 Too Many Requests

{
"error": "Input is too long for requested model."
}

500 Internal Server Error

{
"error": "AI service temporarily unavailable"
}

Supported Models

  • OpenAI: gpt-4, gpt-4o, gpt-4o-mini
  • Anthropic: claude-3-opus, claude-3-sonnet, claude-3-haiku
  • Google: gemini-1.5-pro, gemini-1.5-flash, gemini-2.0-flash
  • Other: jamba-large, mistral-large-latest

File Support

Supported file types:

  • Images: PNG, JPEG, GIF, WebP
  • Documents: PDF, DOCX, TXT, MD
  • Data: CSV, JSON, XML

Maximum file size: 50MB per request

Notes

  • The endpoint automatically handles language detection and translation
  • Image processing requires models that support vision capabilities
  • Large files are processed asynchronously in the background
  • Session context is maintained for conversation continuity