Skip to main content

Built-in Tools

Tools that extend AI capabilities with search, code execution, and more.

What You'll Learn​

Overview​

Tools let AI perform actions beyond text generation. Agents use tools to complete complex tasks.

How Tools Work​

  1. Request - AI determines it needs to use a tool
  2. Execute - Tool runs with provided parameters
  3. Observe - AI receives tool results
  4. Continue - AI uses results to generate response

When to Use Tools​

ScenarioRecommended
Simple Q&ANo tool needed
Need current dataWeb search
Need internal docsRAG search
Need calculationsCode execution
Need custom actionsMCP tools

Available Tools​

ToolDescriptionUse Case
RAG SearchSearch uploaded documentsInternal knowledge, documentation
Web SearchSearch internetCurrent events, real-time data
Code ExecutionRun code in sandboxCalculations, data analysis
MCP ToolsCustom integrationsAPIs, databases, services

Tool Usage Example​

import requests

# Create agent with tools
response = requests.post(
"http://localhost/api/v1/agent/configs",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"name": "research_agent",
"system_prompt": "You are a research assistant. Use tools to find information.",
"model": "gpt-4",
"builtin_tools": ["rag_search", "web_search"],
"tool_choice": "auto",
"max_iterations": 5
}
)

agent_id = response.json()["id"]

# Chat with agent
chat_response = requests.post(
"http://localhost/api/v1/agent/chat",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"agent_id": agent_id,
"message": "What are the latest AI developments and what do our docs say about them?"
}
)

result = chat_response.json()
print(f"Response: {result['response']}")
print(f"Tools used: {[t['tool_name'] for t in result.get('tool_calls', [])]}")

Tool Configuration​

# Configure tools for an agent
agent_config = {
"name": "full_stack_agent",
"system_prompt": "You are a helpful assistant with access to various tools.",
"model": "gpt-4",
"builtin_tools": ["rag_search", "web_search", "code_execution"],
"tool_config": {
"rag_search": {
"default_collection": "documentation",
"top_k": 5,
"similarity_threshold": 0.7
},
"web_search": {
"max_results": 10,
"time_range": "week"
},
"code_execution": {
"timeout": 60,
"allowed_libraries": ["pandas", "numpy", "matplotlib"]
}
},
"tool_choice": "auto",
"max_iterations": 10
}

Direct Tool Calling​

Use tools directly without agent orchestration:

# Call RAG search
curl -X POST http://localhost/api/v1/agent/tool-calling \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"tool_name": "rag_search",
"parameters": {
"query": "API configuration",
"collection": "docs",
"top_k": 5
}
}'

See Direct Tool Calling for more details.

Best Practices​

  1. Use agents for complex tasks - Let AI decide when to use tools
  2. Use direct calls for simple tasks - More control, less overhead
  3. Configure appropriately - Set timeouts and limits
  4. Monitor usage - Track tool usage and costs
  5. Handle errors - Implement retry logic for failed tool calls

Next Steps​