Tool Calling
DEVUP AI supports OpenAI-compatible tool calling for models that expose this capability. By defining external tools (like APIs or database queries), you can allow the model to intelligently choose when and how to call them. Tool-call quality, feature support, and parameter compliance may vary by model.
Tool-calling flow
User request
Send messages and available tool definitions.
Model requests tool
Receive the requested tool name and generated arguments.
Validate & execute
Validate the tool name and arguments, then run the application-owned function.
Return tool result
Append a role: "tool" message using the matching tool_call_id.
Final answer
Send the updated conversation and receive the model’s final response.
Setup
Define a local function
First, define the function in your application that the model can call. This is a local demonstration function that returns static data. The application fully owns this logic.
Send tools to the model
Provide the tool definition in the request using JSON Schema. The model will determine if it needs to call the tool based on the user's message.
Execute and return results
After validating the tool name and parsing the JSON arguments, execute your local function. Append the assistant's message, followed by the tool result containing the matching tool_call_id.
The current temperature in San Francisco, CA is 60 degrees Fahrenheit.
Tool execution safety
Security Best Practices
- Treat model-generated arguments as untrusted user input.
- Strictly allowlist executable tool names.
- Validate arguments rigorously against the JSON schema.
- Never execute arbitrary code or shell commands.
- Apply strict timeouts to prevent hanging executions.
- Handle tool failures gracefully and safely.
- Never expose secrets or credentials in the tool results.
- Limit result size to prevent context overflow.
Best Practices
Write clear and specific tool names and descriptions. The model's decision to invoke a tool depends heavily on them.
Use strict, minimal JSON schemas. Always validate all arguments on your application side before running any logic.
Keep the list of provided tools focused. Providing too many unrelated tools can degrade model reasoning.
Check the selected model's robust capabilities. Use deterministic settings like a lower temperature when appropriate.
Supported capabilities
tool_choice: "auto"tool_choice: "none"