tools
Bases: BaseTools
Source code in airia/client/tools/async_tools.py
create_tool(name, description, purpose, api_endpoint, method_type, body, tool_credentials, headers=[], parameters=[], request_timeout=100, body_type='Json', category='Airia', tool_type='Custom', provider='Custom', route_through_acc=False, should_redirect=True, acc_group=None, documentation=None, project_id=None, tags=None, tool_metadata=None, correlation_id=None)
async
Create a new tool in the Airia platform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the tool. |
required |
description
|
str
|
Brief description of what the tool does. Example: "Use this tool to get the current weather in a given location." |
required |
api_endpoint
|
str
|
Web API endpoint where the tool sends its requests to perform its task. |
required |
method_type
|
str
|
HTTP method type. Valid values: "Get", "Post", "Put", "Delete". |
required |
purpose
|
str
|
When and why to use this tool. Example: "When a user asks about the weather, including current conditions, forecasts, or specific weather events." |
required |
body_type
|
str
|
Type of the request body. Valid values: "Json", "XFormUrlEncoded", "None". |
'Json'
|
category
|
str
|
Category of the tool. Valid values: "Action", "Airia", "Mcp". |
'Airia'
|
provider
|
str
|
Provider of the tool. |
'Custom'
|
tool_type
|
str
|
Type of the tool. Valid values: "Custom", "Calculator", "MCP", "LoadMemory", "StoreMemory", etc. |
'Custom'
|
body
|
str
|
Body of the request that the tool sends to the API. |
required |
headers
|
list[dict]
|
List of headers required when making the API request. Each header should be a dictionary with "key" and "value" fields. Example: [{"key": "Content-Type", "value": "application/json"}] |
[]
|
parameters
|
list[dict]
|
Collection of parameters required by the tool to execute its function. |
[]
|
request_timeout
|
int
|
Request timeout in seconds for tool execution. |
100
|
route_through_acc
|
bool
|
Flag indicating whether the tool should route through the ACC. |
False
|
should_redirect
|
bool
|
Flag indicating whether the tool should redirect with authorization header attached. |
True
|
tool_credentials
|
dict
|
Tool credentials model. |
required |
acc_group
|
str
|
ACC specific group name. If provided, the tool will route through this ACC group. |
None
|
documentation
|
str
|
Documentation for the tool. |
None
|
project_id
|
str
|
Unique identifier of the project to which the tool is associated. |
None
|
tags
|
list[str]
|
List of tags for the tool. |
None
|
tool_metadata
|
list[dict]
|
User provided metadata for the tool definition. |
None
|
correlation_id
|
str
|
A unique identifier for request tracing and logging. If not provided, one will be automatically generated. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
CreateToolResponse |
CreateToolResponse
|
A response object containing the created tool details including its ID, creation timestamp, configuration, credentials, parameters, and all provided metadata. |
Raises:
| Type | Description |
|---|---|
AiriaAPIError
|
If the API request fails, including cases where: - Invalid parameters are provided (400) - Authentication fails (401) - Access is forbidden (403) - Server errors (5xx) |
Example
from airia import AiriaAsyncClient
import asyncio
async def main():
client = AiriaAsyncClient(api_key="your_api_key")
# Create a weather tool with all required parameters
tool = await client.tools.create_tool(
name="get_weather",
description="Use this tool to get the current weather in a given location.",
api_endpoint="https://api.weather.com/v1/current",
method_type="Get",
purpose="When a user asks about the weather, including current conditions.",
body_type="None",
category="Action",
provider="WeatherAPI",
tool_type="Custom",
body="",
headers=[],
parameters=[],
request_timeout=100,
route_through_acc=False,
should_redirect=False,
tool_credentials={}
)
print(f"Created tool: {tool.id}")
# Create an email tool with headers and optional parameters
tool = await client.tools.create_tool(
name="send_email",
description="Send an email to a recipient.",
api_endpoint="https://api.email-service.com/v1/send",
method_type="Post",
purpose="When a user wants to send an email message.",
body_type="Json",
category="Action",
provider="EmailService",
tool_type="Custom",
body='{"to": "{{recipient}}", "subject": "{{subject}}", "body": "{{message}}"}',
headers=[
{"key": "Content-Type", "value": "application/json"},
{"key": "Authorization", "value": "Bearer {{api_key}}"}
],
parameters=[
{"name": "recipient", "type": "string", "required": True},
{"name": "subject", "type": "string", "required": True},
{"name": "message", "type": "string", "required": True}
],
request_timeout=120,
route_through_acc=False,
should_redirect=False,
tool_credentials={},
documentation="This tool sends emails using the Email Service API.",
tags=["email", "communication"]
)
print(f"Created email tool: {tool.id}")
await client.close()
asyncio.run(main())
Note
- Required parameters: name, description, api_endpoint, method_type, purpose, body_type, category, provider, tool_type, body, headers, parameters, request_timeout, route_through_acc, should_redirect, and tool_credentials.
- Optional parameters: acc_group, documentation, project_id, tags, and tool_metadata.
- The method_type must be one of: "Get", "Post", "Put", "Delete"
- The body_type must be one of: "Json", "XFormUrlEncoded", "None"
- The category must be one of: "Action", "Airia", "Mcp"
- The tool_type must be one of: "Custom", "Calculator", "MCP", "LoadMemory", "StoreMemory", etc.
Source code in airia/client/tools/async_tools.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
delete_tool(tool_id, correlation_id=None)
async
Delete a tool by its ID.
This method permanently removes a tool from the Airia platform. This action cannot be undone.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tool_id
|
str
|
The unique identifier of the tool to delete. |
required |
correlation_id
|
str
|
A unique identifier for request tracing and logging. If not provided, one will be automatically generated. |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
None |
None
|
This method returns nothing upon successful deletion. |
Raises:
| Type | Description |
|---|---|
AiriaAPIError
|
If the API request fails, including cases where: - The tool_id doesn't exist (404) - Authentication fails (401) - Access is forbidden (403) - Server errors (5xx) |
Example
from airia import AiriaAsyncClient
import asyncio
async def main():
client = AiriaAsyncClient(api_key="your_api_key")
# Delete a tool
await client.tools.delete_tool(tool_id="tool_123")
print("Tool deleted successfully")
# Handle deletion errors
from airia.exceptions import AiriaAPIError
try:
await client.tools.delete_tool(tool_id="nonexistent_id")
except AiriaAPIError as e:
if e.status_code == 404:
print("Tool not found")
else:
print(f"Error deleting tool: {e.message}")
await client.close()
asyncio.run(main())
Note
This operation is permanent and cannot be undone. Make sure you have the correct tool_id before calling this method.