If you’re using Gloo’s Completions V2 API, you can enhance your LLM interactions by defining tools. Tools allow the language model to optionally or explicitly invoke external functions, enabling it to perform specific tasks, retrieve data, or execute actions as part of the conversation flow.
Completions V1 is Deprecated: This guide covers tool use with the V2 API only. If you’re still using V1 (/ai/v1/chat/completions), please migrate to V2 first.View V2 Guide | Migration Steps
All examples in this guide use the Completions V2 endpoint: /ai/v2/chat/completions
Adding Tools to the Completions API allows you to grow your experience with Gloo AI, adding capabilities that are human flourishing.
Extended Capabilities Beyond Text Generation
All models are excellent at language generation, but they can’t access real-time data or perform calculations natively. Tools allow the model to:
- Fetch up-to-date information (e.g., weather, stock prices, calendars).
- Execute code or math (e.g., calculate complex equations, generate charts).
- Interact with databases, APIs, or internal systems (e.g., CRM updates, file searches, emails).
This turns the AI into a universal interface for diverse tasks.
Automation of Multi-Step Workflows
By using tools, Gloo AI models can:
- Chain together steps in a workflow (e.g., “Analyze this document, then email a summary”).
- Act like a coordinator between systems (e.g., Slack + GitHub + Notion integration).
- Enable interactive applications where the AI can take actions and report back results.
This is vital for real-world applications where AI becomes a true assistant rather than just a chatbot.
Improved Accuracy and Reliability
Rather than “hallucinating” answers, the model can use tools to ground its outputs in real data. By delegating precision tasks like date parsing, data lookup, or logic execution to deterministic systems, you reduce the chance of errors and make the AI trustworthy in mission-critical scenarios.
Gloo provides several models with tooling support. For a complete and up-to-date list of all available models and their specific capabilities, please see our Supported Models Guide.
Tool calling works seamlessly with all Completions V2 routing mechanisms:
- AI Core (auto_routing: true): Gloo automatically selects the best model for your tools based on query complexity
- AI Core Select (model_family): Tools work with your preferred provider family (OpenAI, Anthropic, Google, Open Source)
- AI Select (model): Direct model selection with explicit tool support
For details on routing mechanisms, see the Completions V2 Guide.
Gloo V2 provides multiple models with tool calling support across different providers:
| Model Family | Example Models | Tool Use | Streaming |
|---|
| OpenAI | gloo-openai-gpt-5-pro, gloo-openai-gpt-5-mini | Yes | Yes |
| Anthropic | gloo-anthropic-claude-sonnet-4.5, gloo-anthropic-claude-haiku-4.5 | Yes | Yes |
| Google | gloo-google-gemini-2.5-pro, gloo-google-gemini-2.5-flash | Yes | Yes |
| Open Source | gloo-deepseek-v3.2, gloo-openai-gpt-oss-120b | Yes | Varies |
Using cURL
curl https://platform.ai.gloo.com/ai/v2/chat/completions \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer CLIENT_ACCESS_TOKEN" \
-d '{
"model": "gloo-anthropic-claude-sonnet-4.5",
"auto_routing": false,
"messages": [
{
"role": "user",
"content": "What is the weather like in Shanghai today?"
}
],
"stream": false,
"tools": [
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": { "type": "string" },
"unit": { "type": "string", "enum": ["celsius", "fahrenheit"] }
},
"required": ["location"]
}
}
}
],
"tool_choice": "required"
}'
Using the OpenAI SDK (Python)
# Setup
from openai import OpenAI
client = OpenAI(
api_key='CLIENT_ACCESS_TOKEN', # Your Gloo API access token
base_url='https://platform.ai.gloo.com/ai/v2' # Gloo V2 base URL
)
# Chat Completions call with tooling
response = client.chat.completions.create(
model="gloo-anthropic-claude-sonnet-4.5",
messages=[
{
"role": "user",
"content": "What is the weather like in Shanghai today?"
}
],
stream=False,
tools=[
{
"type": "function",
"function": {
"name": "get_current_weather",
"description": "Get the current weather in a given location",
"parameters": {
"type": "object",
"properties": {
"location": {"type": "string"},
"unit": {
"type": "string",
"enum": ["celsius", "fahrenheit"]
}
},
"required": ["location"]
}
}
}
],
tool_choice="required",
extra_body={"auto_routing": False}
)
print(response)
Using Inngest’s AgentKit SDK (TypeScript)
import {
createAgent,
createTool,
openai,
} from "@inngest/agent-kit";
import { z } from "zod";
const weatherTool = createTool({
name: "check_weather",
description:
"Returns a string of the weather conditions in a city. Call this to know the weather of a certain city.",
parameters: z.object({
location: z.string(),
unit: z.enum(["celcius", "fahrenheit"]),
}),
handler: async ({ location, unit }) => {
return `The weather in ${location} is sunny with a temperature of 81 ${unit}.`;
},
});
const agent = createAgent({
name: 'Weather Agent',
description: 'An agent that describes the weather in various cities.',
system: 'You are an expert at telling the weather of various cities.',
model: openai({
baseURL: 'https://platform.ai.gloo.com/ai/v2', // Gloo V2 base URL
apiKey: 'CLIENT_ACCESS_TOKEN', // Your Gloo API access token
model: 'gloo-anthropic-claude-sonnet-4.5',
}),
tools: [weatherTool],
});
const response = await agent.run("What is the weather like in Shanghai today?")
console.log(JSON.stringify(response));
Example Response
{
"id": "chatcmpl-f11e1872",
"choices": [
{
"finish_reason": "tool_calls",
"index": 0,
"logprobs": null,
"message": {
"content": null,
"refusal": null,
"role": "assistant",
"annotations": null,
"audio": null,
"function_call": null,
"tool_calls": [
{
"id": "tooluse_cabMjx5dQG20v3iUwg0LSQ",
"function": {
"arguments": "{\"unit\": \"celsius\", \"location\": \"Shanghai\"}",
"name": "get_current_weather"
},
"type": "function"
}
]
}
}
],
"created": 1746053578,
"model": "us.anthropic.claude-3-5-sonnet-20241022-v2:0",
"object": "chat.completion",
"service_tier": null,
"system_fingerprint": "fp",
"usage": {
"completion_tokens": 38,
"prompt_tokens": 1196,
"total_tokens": 1234,
"completion_tokens_details": null,
"prompt_tokens_details": null
}
}