BaseAI ​
Overview ​
BaseAI - Intelligent text generation, analysis, and processing capabilities. Transform your applications with content creation, sentiment analysis, categorization, entity extraction, translation, and vectorization.
Operations ​
An operation is an AI-powered action performed on text. All operations require the op property to specify which operation to perform.
| Operation | Description |
|---|---|
baseai.write | Generate new content from prompts |
baseai.summarize | Create concise summaries |
baseai.translate | Translate between languages |
baseai.categorize | Classify content into categories |
baseai.extract_entities | Extract entities and information |
baseai.analyze_sentiment | Analyze emotional tone |
baseai.vectorize_content | Convert document to vector embeddings |
Create Content ​
baseai.write ​
Generate new content based on prompts with customizable style and length.
Basic generation:
json
{
"op": "baseai.write",
"prompt": "Write a blog post about cloud computing benefits for small businesses",
"content_length": 800,
"content_style": "professional"
}With custom instructions:
json
{
"op": "baseai.write",
"prompt": "Create social media posts for a fitness app launch",
"content_length": 500,
"content_style": "engaging",
"custom_instructions": "Create 5 posts for Instagram and Twitter. Include hashtags and call-to-action."
}Parameters:
- prompt (required) - Text or instruction for generation
- content_length (optional) - Target word count
- content_style (optional) - Writing style:
formal,casual,professional,technical,narrative - custom_instructions (optional) - Specific requirements
Response:
json
{
"data": "# Cloud Computing: A Game-Changer for Small Businesses\n\nIn today's competitive landscape, small businesses need every advantage...",
"meta": {
"content_length": 847,
"generation_time_ms": 2340,
"style_applied": "professional"
}
}Summarize Content ​
baseai.summarize ​
Create concise summaries of long-form content.
json
{
"op": "baseai.summarize",
"content": "Artificial intelligence has been transforming industries across the globe at an unprecedented pace. From healthcare to finance, manufacturing to retail, AI technologies are revolutionizing how businesses operate...",
"content_length": 150,
"content_style": "executive"
}Parameters:
- content (required) - Text to summarize
- content_length (optional) - Target summary length
- content_style (optional) - Summary style:
executive,bullet-points,academic,news-brief - custom_instructions (optional) - Focus areas
Response:
json
{
"data": "AI is revolutionizing industries globally through real-time data processing. Key applications include personalized medicine and fraud detection, demonstrating transformative impact across healthcare and finance.",
"meta": {
"original_length": 2847,
"summary_length": 147,
"compression_ratio": 0.052
}
}Categorize Content ​
baseai.categorize ​
Classify content into categories with confidence scoring.
json
{
"op": "baseai.categorize",
"content": "I'm disappointed with my purchase. The product arrived damaged and customer service was unhelpful. I'm considering switching to a competitor.",
"classification_categories": "positive, negative, neutral, urgent, complaint, inquiry",
"confidence_level": "high"
}Parameters:
- content (required) - Text to classify
- classification_categories (optional) - Comma-separated list of categories
- confidence_level (optional) - Minimum confidence:
low,medium,high
Response:
json
{
"data": {
"primary_classification": "complaint",
"secondary_classifications": ["negative", "urgent"],
"confidence_scores": {
"complaint": 0.92,
"negative": 0.89,
"urgent": 0.76,
"neutral": 0.08,
"positive": 0.03
},
"reasoning": "Content expresses dissatisfaction with product and service, indicating urgent complaint."
},
"meta": {
"classification_method": "multi-label",
"confidence_threshold": 0.7
}
}Common use cases:
- Customer support ticket routing
- Content moderation
- Document organization
- Email filtering
Analyze Sentiment ​
baseai.analyze_sentiment ​
Analyze emotional tone and sentiment of text.
json
{
"op": "baseai.analyze_sentiment",
"content": "The new product launch exceeded expectations! While there were supply chain challenges, we overcame them. Customer feedback has been overwhelmingly positive.",
"analysis_depth": "detailed",
"specific_aspects": "product quality, team performance, customer satisfaction"
}Parameters:
- content (required) - Text to analyze
- analysis_depth (optional) - Detail level:
brief,standard,detailed - specific_aspects (optional) - Comma-separated aspects to focus on
Response:
json
{
"data": {
"overall_sentiment": "positive",
"sentiment_score": 0.78,
"emotional_indicators": {
"excitement": 0.85,
"satisfaction": 0.82,
"concern": 0.23,
"confidence": 0.76
},
"aspect_sentiments": {
"product quality": {
"sentiment": "very positive",
"score": 0.91
},
"team performance": {
"sentiment": "positive",
"score": 0.87
},
"customer satisfaction": {
"sentiment": "positive",
"score": 0.83
}
},
"key_phrases": ["exceeded expectations", "overwhelmingly positive"],
"tone_analysis": "optimistic and professional with acknowledgment of improvements"
},
"meta": {
"analysis_confidence": 0.94
}
}Common use cases:
- Product review analysis
- Social media monitoring
- Employee feedback analysis
- Customer support quality
Extract Entities ​
baseai.extract_entities ​
Extract specific entities and structured information from text.
json
{
"op": "baseai.extract_entities",
"content": "John Smith, CEO of TechCorp Inc., announced the company will open a new headquarters in San Francisco. The $50 million facility will create 500 jobs by December 2024. Contact: john.smith@techcorp.com, (555) 123-4567.",
"entity_types": "people, organizations, locations, dates, contact_info, financial_amounts"
}Parameters:
- content (required) - Text to analyze
- entity_types (optional) - Comma-separated entity types to extract
Response:
json
{
"data": {
"people": [
{
"name": "John Smith",
"title": "CEO",
"organization": "TechCorp Inc."
}
],
"organizations": [
{
"name": "TechCorp Inc.",
"type": "company"
}
],
"locations": [
{
"city": "San Francisco",
"type": "headquarters_location"
}
],
"dates": [
{
"date": "December 2024",
"context": "job creation deadline"
}
],
"contact_info": [
{
"email": "john.smith@techcorp.com",
"phone": "(555) 123-4567"
}
],
"financial_amounts": [
{
"amount": "$50 million",
"context": "facility cost"
}
]
},
"meta": {
"entities_found": 6,
"extraction_confidence": 0.96
}
}Common entity types:
people- Names, titles, rolesorganizations- Companies, institutionslocations- Cities, countries, addressesdates- Dates, times, deadlinescontact_info- Emails, phonesfinancial_amounts- Money, pricesskills- Technical skills, expertiseevents- Meetings, conferences
Common use cases:
- Contract analysis
- Resume parsing
- News analysis
- Invoice processing
Translate Content ​
baseai.translate ​
Translate text between languages with style preservation.
json
{
"op": "baseai.translate",
"content": "We are excited to announce the launch of our new product line. For more information, visit our website.",
"anguage": "Spanish",
"translation_style": "business-formal"
}Parameters:
- content (required) - Text to translate
- language (required) - Target language
- translation_style (optional) - Style:
formal,casual,technical,marketing
Response:
json
{
"data": "Nos complace anunciar el lanzamiento de nuestra nueva lĂnea de productos. Para obtener más informaciĂłn, visite nuestro sitio web.",
"meta": {
"language": "Spanish",
"translation_confidence": 0.98,
"style_applied": "business-formal"
}
}Supported languages: English, Spanish, French, German, Japanese, Chinese, Portuguese, Italian, Russian, Korean, Arabic, Dutch, Polish
Vectorize Content ​
baseai.vectorize_content ​
Convert text to vector embeddings for semantic search and similarity analysis.
json
{
"op": "baseai.vectorize_content",
"content": "Machine learning algorithms identify patterns in data and make predictions."
}Parameters:
- content (required) - Text to convert to vectors
Response:
json
{
"data": {
"vector": [0.0234, -0.1567, 0.2891, 0.0945, -0.3421, ...],
"dimensions": 1536,
"model_version": "text-embedding-v2.0"
},
"meta": {
"content_length": 119,
"vector_norm": 1.0
}
}Common use cases:
- Semantic search
- Content recommendation
- Similarity detection
- Document clustering
Complete Example ​
javascript
// 1. Generate content
const createResponse = await fetch('https://cloud.singlebaseapis.com/api/<ENDPOINT_KEY>', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-KEY': 'your_api_key',
'Authorization': 'Bearer your_jwt_token'
},
body: JSON.stringify({
op: 'baseai.write',
prompt: 'Write a product description for wireless headphones',
content_length: 200,
content_style: 'marketing'
})
});
const content = await createResponse.json();
console.log('Generated:', content.data);
// 2. Analyze sentiment
const sentimentResponse = await fetch('https://cloud.singlebaseapis.com/api/<ENDPOINT_KEY>', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-KEY': 'your_api_key',
'Authorization': 'Bearer your_jwt_token'
},
body: JSON.stringify({
op: 'baseai.analyze_sentiment',
content: 'The product quality is excellent but delivery was slow.',
analysis_depth: 'detailed',
specific_aspects: 'product quality, delivery'
})
});
const sentiment = await sentimentResponse.json();
console.log('Overall:', sentiment.data.output.overall_sentiment);
console.log('Aspects:', sentiment.data.output.aspect_sentiments);
// 3. Categorize content
const categorizeResponse = await fetch('https://cloud.singlebaseapis.com/api/<ENDPOINT_KEY>', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-KEY': 'your_api_key',
'Authorization': 'Bearer your_jwt_token'
},
body: JSON.stringify({
op: 'baseai.categorize',
content: 'How do I reset my password?',
classification_categories: 'technical, billing, account, general'
})
});
const category = await categorizeResponse.json();
console.log('Category:', category.data.output.primary_classification);
// 4. Extract entities
const extractResponse = await fetch('https://cloud.singlebaseapis.com/api/<ENDPOINT_KEY>', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-KEY': 'your_api_key',
'Authorization': 'Bearer your_jwt_token'
},
body: JSON.stringify({
op: 'baseai.extract_entities',
content: 'Contact Jane Doe at jane@example.com or call (555) 123-4567.',
entity_types: 'people, contact_info'
})
});
const entities = await extractResponse.json();
console.log('People:', entities.data.output.people);
console.log('Contacts:', entities.data.output.contact_info);Common Workflows ​
Customer Support Automation ​
javascript
// Categorize and route support ticket
const ticket = "I can't login to my account";
const category = await fetch('https://cloud.singlebaseapis.com/api/<ENDPOINT_KEY>', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-API-KEY': 'your_api_key',
'Authorization': 'Bearer your_jwt_token'
},
body: JSON.stringify({
op: 'baseai.categorize',
content: ticket,
classification_categories: 'technical, billing, account, general'
})
});
// Route based on category
const result = await category.json();
routeToTeam(result.data.primary_classification);Content Analysis Pipeline ​
javascript
async function analyzeContent(text) {
// Summarize
const summary = await summarize(text);
// Analyze sentiment
const sentiment = await analyzeSentiment(text);
// Categorize
const category = await categorize(text);
return {
summary: summary.data,
sentiment: sentiment.data.overall_sentiment,
category: category.data.primary_classification
};
}Error Handling ​
json
{
"error": {
"code": "ERROR_CODE",
"message": "Human-readable error description"
}
}Common error codes:
CONTENT_TOO_LONG- Content exceeds max length (50,000 chars)CONTENT_EMPTY- No content providedINVALID_LANGUAGE- Unsupported languagePROCESSING_FAILED- AI processing error (retry recommended)QUOTA_EXCEEDED- API usage limit reachedINVALID_OPTIONS- Malformed parameters