JavaScript
// Text Generation - Multiple Model Providers
// Supported providers: openai, anthropic, google, xai, perplexity
// GPT-4o (OpenAI)
const gpt_response = await fetch('https://api.ireadcustomer.com/v1/generate', {
method: 'POST',
headers: {
'Authorization': 'Bearer irc_live_xxxxx',
'Content-Type': 'application/json'
},
body: JSON.stringify({
prompt: 'Write a product description for a smart home device',
model: { provider: 'openai', name: 'gpt-4o' },
options: { temperature: 0.7 }
})
});
// Claude Sonnet (Anthropic)
const claude_response = await fetch('https://api.ireadcustomer.com/v1/generate', {
body: JSON.stringify({
prompt: 'Analyze this business strategy',
model: { provider: 'anthropic', name: 'claude-sonnet-4-20250514' }
})
// ... headers same as above
});
// Gemini (Google)
const gemini_response = await fetch('https://api.ireadcustomer.com/v1/generate', {
body: JSON.stringify({
prompt: 'Explain quantum computing',
model: { provider: 'google', name: 'gemini-2.0-flash' }
})
});
// Grok (xAI)
const grok_response = await fetch('https://api.ireadcustomer.com/v1/generate', {
body: JSON.stringify({
prompt: 'Latest tech trends',
model: { provider: 'xai', name: 'grok-3' }
})
});
JavaScript
// Vector Search - Semantic similarity search
const response = await fetch('https://api.ireadcustomer.com/v1/search', {
method: 'POST',
headers: {
'Authorization': 'Bearer irc_live_xxxxx',
'Content-Type': 'application/json'
},
body: JSON.stringify({
query: 'How to integrate payment systems?',
collection: 'documentation',
top_k: 5,
filters: {
category: 'payments'
}
})
});
const data = await response.json();
// Returns ranked results with similarity scores
data.data.results.forEach(doc => {
console.log(`Score: ${doc.score}`);
console.log(`Content: ${doc.content}`);
});
JavaScript
// Invoke AI Agent with RAG, Tools & Memory
const response = await fetch('https://api.ireadcustomer.com/v1/agents/invoke', {
method: 'POST',
headers: {
'Authorization': 'Bearer irc_live_xxxxx',
'Content-Type': 'application/json'
},
body: JSON.stringify({
agent: 'my_sales_agent', // Custom or built-in agent
message: 'What products do we have in stock?',
context: {
project_id: 'proj_123',
session_id: 'sess_abc', // Enables conversation memory
variables: { language: 'thai' }
}
})
});
const data = await response.json();
console.log(data.data.response);
// RAG sources: data.data.rag?.sources
// Tool calls: data.data.tool_calls
// Memory: data.data.memory?.message_count
JavaScript
// Register Agent with Plug-and-Play Tools
// Connect your own APIs via webhooks - no code changes needed!
await fetch('https://api.ireadcustomer.com/v1/agents/register', {
method: 'POST',
headers: {
'Authorization': 'Bearer irc_live_xxxxx',
'Content-Type': 'application/json'
},
body: JSON.stringify({
type: 'inventory_assistant',
name: 'Inventory AI',
prompt: { system_prompt: 'You help check product inventory.' },
features: {
tools: {
custom: {
// Webhook Tool - calls YOUR API
check_stock: {
description: 'Check product stock levels',
parameters: {
product_id: { type: 'string', required: true },
warehouse: { type: 'string', enum: ['BKK', 'CNX'] }
},
handler: {
type: 'webhook',
webhook_url: 'https://your-api.com/stock',
webhook_auth: 'Bearer your_secret_key',
timeout_ms: 10000
}
},
// Built-in Tool - uses our services
calculate: {
description: 'Calculate expressions',
parameters: { expression: { type: 'string', required: true } },
handler: { type: 'builtin', builtin_name: 'calculate' }
}
}
}
}
})
});
// When AI calls check_stock, we POST to your webhook:
// { tool_name: 'check_stock', arguments: { product_id: 'SKU123' } }