การยืนยันตัวตน
คำขอ API ทั้งหมดต้องมี Bearer token ใน Authorization header
Authorization: Bearer irc_live_xxxxxRate Limiting
คำขอ API มีการจำกัดอัตราเพื่อให้การใช้งานเป็นธรรม
- 60 คำขอต่อนาที
- 10,000 คำขอต่อวัน
การใช้เครดิต
การเรียก API แต่ละครั้งจะใช้เครดิตจากพูลขององค์กรของคุณ
generate~0.5 เครดิตต่อ 1K tokens
embed0.5 เครดิตต่อคำขอ
search0.5 เครดิตต่อคำขอ
index0.5 เครดิตต่อเอกสาร
agents1 เครดิตต่อการเรียกใช้
image3 เครดิตต่อรูปภาพ
Endpoints
GET
/v1/ตรวจสอบสถานะ API และข้อมูลเวอร์ชัน
คำขอ
curl https://api.ireadcustomer.com/v1/การตอบกลับ
{
"name": "iReadCustomer SDK API",
"version": "1.0.0",
"status": "healthy",
"timestamp": "2026-01-04T12:00:00.000Z"
}POST
/v1/generateสร้างข้อความหรือเอาต์พุตแบบมีโครงสร้างด้วยโมเดล AI
คำขอ
# Supported Providers: openai, anthropic, google, xai, perplexity
# Model Examples:
# - openai: gpt-4o, gpt-4o-mini, o1, o1-mini
# - anthropic: claude-sonnet-4-20250514, claude-opus-4-20250514
# - google: gemini-2.0-flash, gemini-1.5-pro
# - xai: grok-3, grok-3-mini
# - perplexity: llama-3.1-sonar-large
curl -X POST https://api.ireadcustomer.com/v1/generate \
-H "Authorization: Bearer irc_live_xxxxx" \
-H "Content-Type: application/json" \
-d '{
"prompt": "Summarize the key benefits of AI",
"model": { "provider": "openai", "name": "gpt-4o" },
"options": { "temperature": 0.7, "max_tokens": 500 }
}'การตอบกลับ
{
"success": true,
"data": {
"type": "text",
"text": "AI offers several key benefits...",
"usage": {
"prompt_tokens": 12,
"completion_tokens": 150,
"total_tokens": 162
},
"credits_used": 0.08
}
}POST
/v1/embedสร้าง vector embeddings สำหรับเนื้อหาข้อความ
คำขอ
curl -X POST https://api.ireadcustomer.com/v1/embed \
-H "Authorization: Bearer irc_live_xxxxx" \
-H "Content-Type: application/json" \
-d '{
"texts": ["Hello world", "How are you?"],
"model": { "provider": "openai" }
}'การตอบกลับ
{
"success": true,
"data": {
"embeddings": [[0.123, -0.456, ...], [0.789, -0.012, ...]],
"dimensions": 1536,
"credits_used": 0.5
}
}POST
/v1/searchค้นหาเอกสารโดยใช้ความคล้ายคลึงเชิงความหมาย
คำขอ
curl -X POST https://api.ireadcustomer.com/v1/search \
-H "Authorization: Bearer irc_live_xxxxx" \
-H "Content-Type: application/json" \
-d '{
"query": "How to integrate payment?",
"collection": "documentation",
"top_k": 5
}'การตอบกลับ
{
"success": true,
"data": {
"results": [
{
"id": "doc_123",
"content": "To integrate payments...",
"score": 0.92,
"metadata": { "title": "Payment Guide" }
}
],
"credits_used": 0.5
}
}POST
/v1/indexจัดทำดัชนีเอกสารลงใน vector store
คำขอ
curl -X POST https://api.ireadcustomer.com/v1/index \
-H "Authorization: Bearer irc_live_xxxxx" \
-H "Content-Type: application/json" \
-d '{
"collection": "documentation",
"documents": [
{
"id": "doc_001",
"content": "This is the document content...",
"title": "Getting Started"
}
]
}'การตอบกลับ
{
"success": true,
"data": {
"collection": "documentation",
"documents_indexed": 1,
"chunks_created": 3,
"document_ids": ["doc_001"],
"credits_used": 0.5
}
}POST
/v1/agents/invokeเรียกใช้เอเจนต์พร้อม RAG context, เครื่องมือแบบกำหนดเอง (webhook/builtin) และหน่วยความจำถาวร
คำขอ
# Invoke agent with optional memory session and context
curl -X POST https://api.ireadcustomer.com/v1/agents/invoke \
-H "Authorization: Bearer irc_live_xxxxx" \
-H "Content-Type: application/json" \
-d '{
"agent": "my_custom_agent",
"message": "Summarize our Q3 sales performance",
"context": {
"project_id": "proj_123",
"session_id": "sess_abc",
"variables": { "output_language": "thai" }
}
}'การตอบกลับ
{
"success": true,
"data": {
"agent": "my_custom_agent",
"source": "custom",
"response": "Based on the knowledge base...",
"usage": { "prompt_tokens": 850, "completion_tokens": 420, "total_tokens": 1270 },
"rag": { "used": true, "sources": [{ "id": "doc_123", "title": "Q3 Report", "score": 0.92 }] },
"tool_calls": [{ "name": "calculate", "arguments": { "expression": "150000 * 1.15" }, "result": { "result": 172500 } }],
"memory": { "session_id": "sess_abc", "message_count": 4 },
"credits_used": 1.0,
"execution_time_ms": 2340
}
}POST
/v1/agents/registerลงทะเบียนเอเจนต์แบบกำหนดเองพร้อม RAG, webhook tools, หน่วยความจำ และคุณสมบัติที่กำหนดค่าได้
คำขอ
# Register custom agent with RAG, tools, and memory
curl -X POST https://api.ireadcustomer.com/v1/agents/register \
-H "Authorization: Bearer irc_live_xxxxx" \
-H "Content-Type: application/json" \
-d '{
"type": "sales_assistant",
"name": "Sales Assistant AI",
"description": "AI assistant for sales team with product knowledge",
"model": {
"provider": "google",
"model": "gemini-2.0-flash",
"fallback_models": ["gemini-1.5-pro"]
},
"prompt": {
"system_prompt": "You are a sales assistant. Language: {{language}}. Use the knowledge base to answer product questions accurately.",
"variables": { "language": "Thai" }
},
"features": {
"rag": {
"enabled": true,
"knowledge_base_id": "kb_products",
"top_k": 5,
"min_score": 0.7,
"include_citations": true
},
"tools": {
"custom": {
"check_inventory": {
"description": "Check product inventory levels",
"parameters": {
"product_id": { "type": "string", "required": true },
"warehouse": { "type": "string", "enum": ["BKK", "CNX", "HKT"] }
},
"handler": {
"type": "webhook",
"webhook_url": "https://api.yourcompany.com/inventory",
"webhook_auth": "Bearer your_api_key",
"timeout_ms": 10000
}
},
"calculate": {
"description": "Calculate math expressions",
"parameters": { "expression": { "type": "string", "required": true } },
"handler": { "type": "builtin", "builtin_name": "calculate" }
}
},
"max_tool_calls": 5
},
"memory": {
"enabled": true,
"max_context_messages": 20,
"session_ttl_seconds": 3600
},
"response": { "temperature": 0.7, "max_tokens": 2000 }
}
}'การตอบกลับ
{
"success": true,
"data": {
"message": "Agent registered successfully",
"agent": {
"id": "67890abcdef",
"type": "sales_assistant",
"name": "Sales Assistant AI",
"version": "1.0.0",
"is_active": true,
"created_at": "2026-01-04T12:00:00.000Z"
}
}
}GET
/v1/agentsแสดงรายการเอเจนต์ทั้งหมดรวมถึงเอเจนต์ในตัวและแบบกำหนดเอง
คำขอ
# List all available agents (builtin + custom)
curl https://api.ireadcustomer.com/v1/agents \
-H "Authorization: Bearer irc_live_xxxxx"การตอบกลับ
{
"success": true,
"data": {
"agents": [
{ "type": "content_creator", "name": "Content Creator", "source": "builtin", "features": { "rag": false } },
{ "type": "sales_assistant", "name": "Sales Assistant AI", "source": "custom", "features": { "rag": true, "memory": true } }
],
"builtin_count": 5,
"custom_count": 2,
"total": 7
}
}GET
/v1/agents/toolsแสดงรายการเครื่องมือในตัวที่สามารถใช้ในเอเจนต์แบบกำหนดเอง
คำขอ
# List available built-in tools
curl https://api.ireadcustomer.com/v1/agents/tools \
-H "Authorization: Bearer irc_live_xxxxx"การตอบกลับ
{
"success": true,
"data": {
"tools": [
{ "name": "web_search", "description": "Search the web using Perplexity AI", "parameters": { "query": { "type": "string", "required": true } } },
{ "name": "get_current_time", "description": "Get current date and time", "parameters": {} },
{ "name": "calculate", "description": "Evaluate mathematical expression", "parameters": { "expression": { "type": "string", "required": true } } }
],
"count": 3
}
}POST
/v1/workflowsรัน AI workflows หลายขั้นตอน
คำขอ
curl -X POST https://api.ireadcustomer.com/v1/workflows \
-H "Authorization: Bearer irc_live_xxxxx" \
-H "Content-Type: application/json" \
-d '{
"workflow_id": "content_pipeline",
"inputs": {
"topic": "Sustainable technology",
"format": "article"
}
}'การตอบกลับ
{
"success": true,
"data": {
"workflow_id": "content_pipeline",
"status": "completed",
"outputs": { ... },
"credits_used": 2.5
}
}POST
/v1/imageสร้างรูปภาพโดยใช้โมเดล AI
คำขอ
# Supported Providers: openai, stability
# Model Examples:
# - openai: dall-e-3, dall-e-2, gpt-image-1
# - stability: stable-diffusion-xl, stable-diffusion-3.5
curl -X POST https://api.ireadcustomer.com/v1/image \
-H "Authorization: Bearer irc_live_xxxxx" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A futuristic cityscape at sunset",
"model": { "provider": "openai", "name": "dall-e-3" },
"options": { "size": "1024x1024", "quality": "hd" }
}'การตอบกลับ
{
"success": true,
"data": {
"url": "https://...",
"credits_used": 3.0
}
}