Built-in Tools
Tools that extend AI capabilities with search, code execution, and more.
What You'll Learn
- Overview - What tools are and when to use them
- Built-in Tools - Available built-in tools
- RAG Search - Search your documents
- Web Search - Search the internet
- Code Execution - Run code securely
- MCP Tools - Create custom tools
Overview
Tools let AI perform actions beyond text generation. Agents use tools to complete complex tasks.
How Tools Work
- Request - AI determines it needs to use a tool
- Execute - Tool runs with provided parameters
- Observe - AI receives tool results
- Continue - AI uses results to generate response
When to Use Tools
| Scenario | Recommended |
|---|---|
| Simple Q&A | No tool needed |
| Need current data | Web search |
| Need internal docs | RAG search |
| Need calculations | Code execution |
| Need custom actions | MCP tools |
Available Tools
| Tool | Description | Use Case |
|---|---|---|
| RAG Search | Search uploaded documents | Internal knowledge, documentation |
| Web Search | Search internet | Current events, real-time data |
| Code Execution | Run code in sandbox | Calculations, data analysis |
| MCP Tools | Custom integrations | APIs, 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
- Use agents for complex tasks - Let AI decide when to use tools
- Use direct calls for simple tasks - More control, less overhead
- Configure appropriately - Set timeouts and limits
- Monitor usage - Track tool usage and costs
- Handle errors - Implement retry logic for failed tool calls
Next Steps
- Built-in Tools - All available tools
- RAG Search - Search your documents
- Web Search - Search the internet
- Code Execution - Run code safely
- MCP Tools - Create custom tools