Tools API Reference¶
The Tools API is a core component of Kubiya SDK, enabling you to create, configure, and manage Docker-based tools for your workflows.
Overview¶
Kubiya tools are built on top of Docker images, allowing you to leverage the vast ecosystem of existing Docker containers. The Tools API provides several ways to create and manage tools:
- Tool Decorator: The
@kubiya.tool()decorator is the simplest way to create tools from Python functions - Tool Configuration: Configure your tools with environment variables, secrets, and file mounts
- Image Profiles: Use pre-configured image profiles for common scenarios
- Dynamic Configuration: Manage runtime configuration values for tools
- Tool Models: The underlying data models that define tool structure
Key Components¶
| Component | Description |
|---|---|
| Tool Decorator | The primary way to create tools from Python functions |
| Tool Configuration | Configure Docker image, environment variables, secrets, etc. |
| Image Profiles | Pre-configured images for specific use cases |
| Dynamic Config | Runtime configuration for tools |
| Tool Models | Data models defining tool structure |
Example: Creating a Tool¶
Python
from kubiya_sdk import kubiya
@kubiya.tool(name="text-processor",
image="python:3.12-slim",
description="Process text with various operations")
def process_text(text: str, operation: str = "uppercase") -> str:
"""
Process text with various operations
Args:
text: The input text to process
operation: The operation to perform (uppercase, lowercase, capitalize)
Returns:
The processed text
"""
if operation == "uppercase":
return text.upper()
elif operation == "lowercase":
return text.lower()
elif operation == "capitalize":
return text.capitalize()
else:
return text
# Use the tool
result = process_text("Hello, World!", "uppercase")
# Returns: "HELLO, WORLD!"
Tool Registry¶
All tools in Kubiya are registered in a central registry, which enables:
- Discovery of tools across your application
- Configuration management
- Runtime instrumentation
- Integration with LLM function calling
The registry is accessed via tool_registry from kubiya_sdk.tools.registry.