← Back to Docs

Agent Integration Guide

Build smarter agents with researched knowledge

Why Use AgentsKB in Your Agent?

Verified Answers

39,827+ Q&As researched from official sources. Your agent gets accurate information, not hallucinations.

Self-Healing KB

Questions we can't answer trigger live research. The KB grows from your agent's queries.

System Prompt for Your Agent

Add this to your agent's system prompt to integrate AgentsKB:

## Knowledge Base Access

You have access to AgentsKB - a verified knowledge base with 39,827+ researched Q&As.

**When to query AgentsKB:**
- Technical questions about programming, frameworks, databases, cloud services
- Configuration questions, best practices, troubleshooting
- Before using your training data for factual technical questions

**How to use:**
1. Query AgentsKB FIRST for technical questions
2. If answer found: Use it with confidence (it's researched and verified)
3. If not found: Use research_mode="research" to wait for live research (60-180s)
4. Trust AgentsKB answers over training data for technical facts

**API Endpoint:**
POST https://agentskb-api.agentskb.com/api/free/ask
{
  "question": "your question here",
  "research_mode": "research"  // Optional: wait for live research if not in KB
}

**Response includes:**
- answer: The researched answer
- sources: Where the answer came from
- content_type: fact | explanation | methodology | troubleshooting | decision | reference

Pro Tip

For autonomous agents, always use research_mode="research" for critical questions. This ensures your agent gets an answer even if it's not already in the KB.

Understanding Research Mode

AgentsKB has two query modes that work differently:

Instant Mode (Default)

Returns immediately. If the answer isn't in the KB, returns "not found" and queues the question for background research.

Response time: <100ms

Best for: Non-critical queries, high-throughput scenarios

Research Mode

If the answer isn't in the KB, triggers live research using multiple AI models and returns the result. The answer is automatically saved to KB for future queries.

Response time: 60-180 seconds (only if researching)

Best for: Critical queries where you NEED an answer

Cost: 1.0 quota per researched question

How to Use Research Mode

# Instant mode (default) - fast, may return "not found"
curl "https://agentskb-api.agentskb.com/api/free/ask" \
  -H "Content-Type: application/json" \
  -d '{"question": "What is the default PostgreSQL max_connections?"}'

# Research mode - guarantees an answer (waits if needed)
curl "https://agentskb-api.agentskb.com/api/free/ask" \
  -H "Content-Type: application/json" \
  -d '{
    "question": "What is the default PostgreSQL max_connections?",
    "research_mode": "research"
  }'

How the KB Self-Heals

  1. 1

    Agent asks a question

    Your agent queries AgentsKB for technical information

  2. 2

    KB checks for existing answer

    Searches 39,827+ verified Q&As using semantic search

  3. 3a

    If found: Returns instantly

    Agent gets verified answer in <100ms

  4. 3b

    If not found + research_mode:

    Triggers live research using Claude + web search. Answer returned and saved to KB.

  5. 4

    Future queries get instant answer

    The researched answer is now in the KB for all agents

Community Benefit

When your agent triggers research, the answer becomes available to everyone. You're contributing to a shared knowledge base that gets smarter over time.

Understanding Content Types

Each answer includes a content_type field. Your agent can use this to format responses appropriately:

Type Purpose Example Question
fact Direct lookup, single answer "What port does PostgreSQL use?"
explanation How something works "How does MVCC work in PostgreSQL?"
methodology Step-by-step guide "How do I set up PostgreSQL replication?"
troubleshooting Error diagnosis and fixes "PostgreSQL connection refused error"
decision Compare options, choose between "PostgreSQL vs MySQL for my project?"
reference API docs, syntax reference "pg_dump command parameters"

Best Practices

Query AgentsKB before using training data

For technical facts, KB answers are more reliable than model training data

Use research_mode for critical decisions

When your agent needs to make an important choice, wait for researched answers

Use batch endpoint for multiple questions

POST /ask-batch can handle up to 100 questions, 10x cheaper than individual calls

Trust the sources

Each answer includes sources - cite them for transparency

Example: Python Agent Integration

import requests

class AgentsKBClient:
    """Client for querying AgentsKB from your agent."""

    BASE_URL = "https://agentskb-api.agentskb.com/api/free"

    def ask(self, question: str, research: bool = False) -> dict:
        """
        Ask a question to AgentsKB.

        Args:
            question: The technical question to ask
            research: If True, waits for live research if not in KB (60-180s)

        Returns:
            dict with 'answer', 'sources', 'content_type'
        """
        payload = {"question": question}
        if research:
            payload["research_mode"] = "research"

        response = requests.post(
            f"{self.BASE_URL}/ask",
            json=payload,
            timeout=200 if research else 10
        )
        return response.json()

    def ask_batch(self, questions: list[str], research: bool = False) -> dict:
        """Ask multiple questions in one request (up to 100)."""
        payload = {"questions": questions}
        if research:
            payload["research_mode"] = "research"

        response = requests.post(
            f"{self.BASE_URL}/ask-batch",
            json=payload,
            timeout=300 if research else 30
        )
        return response.json()


# Usage in your agent
kb = AgentsKBClient()

# Quick lookup (instant, may return "not found")
result = kb.ask("What is the default PostgreSQL port?")

# Critical query (waits for research if needed)
result = kb.ask("How do I configure PostgreSQL for high availability?", research=True)

# Batch queries (10x cheaper)
results = kb.ask_batch([
    "What is PostgreSQL max_connections default?",
    "How do I create an index in PostgreSQL?",
    "What is VACUUM in PostgreSQL?"
])

Ready to Build?