/API Documentation

API Documentation

Complete reference for the iReadCustomer SDK API

Authentication

All API requests require a Bearer token in the Authorization header.

Authorization: Bearer irc_live_xxxxx

Rate Limiting

API requests are rate limited to ensure fair usage.

  • 60 requests per minute
  • 10,000 requests per day

Credit Usage

Each API call consumes credits from your organization pool.

generate~0.5 credits per 1K tokens
embed0.5 credits per request
search0.5 credits per request
index0.5 credits per document
agents1 credit per invocation
image3 credits per image

Endpoints

GET/v1/

Check API status and version information.

Request

curl https://api.ireadcustomer.com/v1/

Response

{
  "name": "iReadCustomer SDK API",
  "version": "1.0.0",
  "status": "healthy",
  "timestamp": "2026-01-04T12:00:00.000Z"
}
POST/v1/generate

Generate text or structured output using AI models.

Request

# 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 }
  }'

Response

{
  "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

Create vector embeddings for text content.

Request

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" }
  }'

Response

{
  "success": true,
  "data": {
    "embeddings": [[0.123, -0.456, ...], [0.789, -0.012, ...]],
    "dimensions": 1536,
    "credits_used": 0.5
  }
}
POST/v1/index

Index documents into the vector store.

Request

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"
      }
    ]
  }'

Response

{
  "success": true,
  "data": {
    "collection": "documentation",
    "documents_indexed": 1,
    "chunks_created": 3,
    "document_ids": ["doc_001"],
    "credits_used": 0.5
  }
}
POST/v1/agents/invoke

Invoke agents with RAG context, custom tools (webhook/builtin), and persistent memory.

Request

# 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" }
    }
  }'

Response

{
  "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

Register custom agents with RAG, webhook tools, memory, and configurable features.

Request

# 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 }
    }
  }'

Response

{
  "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 including built-in and custom agents.

Request

# List all available agents (builtin + custom)
curl https://api.ireadcustomer.com/v1/agents \
  -H "Authorization: Bearer irc_live_xxxxx"

Response

{
  "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 that can be used in custom agents.

Request

# List available built-in tools
curl https://api.ireadcustomer.com/v1/agents/tools \
  -H "Authorization: Bearer irc_live_xxxxx"

Response

{
  "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

Execute multi-step AI workflows.

Request

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"
    }
  }'

Response

{
  "success": true,
  "data": {
    "workflow_id": "content_pipeline",
    "status": "completed",
    "outputs": { ... },
    "credits_used": 2.5
  }
}
POST/v1/image

Generate images using AI models.

Request

# 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" }
  }'

Response

{
  "success": true,
  "data": {
    "url": "https://...",
    "credits_used": 3.0
  }
}