What is Tool Calling?
Tool calling (previously known as function calling) is a powerful feature that allows Language Models (LLMs) to return structured data and invoke predefined functions with JSON arguments. This capability enables more complex interactions and structured outputs from LLMs. Key benefits of tool calling include:- Structured Outputs: Tool arguments are always in JSON format, enforced by JSONSchema at the API level. See our Structured Outputs documentation for more details.
- Efficient Communication: Tool calling is a concept built into the model, reducing token usage and improving understanding.
- Model Routing: Facilitates setting up modular prompts with specific responsibilities.
- Prompt Injection Protection: Strict schema definitions at the model level make it harder to “jailbreak” the model.
Creating Custom Tools
Creating Visually
Tools can be defined, called, and set up visually through the Prompt Registry.Publishing Programmatically
To publish a prompt template with tools programmatically, you can add the argumentstools and tool_choice to your prompt_template object. This is similar to how you would publish a regular prompt template.
Tool Variables
Tool variables allow you to dynamically inject tools at runtime through input variables, rather than defining them statically in your prompt template. This is useful when:- Different customers or tenants need different sets of tools
- Your available tools change based on runtime context (e.g., user permissions, feature flags)
- You want to manage tool definitions outside of your prompt template
Adding a Tool Variable
- Open the Tool & Output Editor in the Prompt Registry
- Click the dropdown arrow on the Add Tool button and select Tool Variable
- Enter a variable name (e.g.,
dynamic_tools) and click Add - The variable will appear in your Input Variable Sets alongside other template variables
get_weather tool alongside a customer_tools variable that injects customer-specific tools at runtime.
Passing Tools at Runtime
When running a prompt with tool variables, pass the tool definitions as an array in yourinput_variables:
name, description, and parameters (using JSON Schema format). Anthropic-style input_schema is also accepted as an alternative to parameters.
Tool variables are expanded before the prompt is sent to the LLM provider. The model sees them as regular tool definitions, so they work with any provider that supports tool calling.
Built-in Tools
PromptLayer supports provider-native built-in tools across multiple LLM providers. These pre-built tools enable your prompts to access real-time information, execute code, search through files, and more—all without writing custom function definitions. Built-in tools are available for the following providers:How to Add Built-in Tools
- Open your prompt in the Prompt Registry and navigate to the prompt editor
- Select your LLM provider in the provider settings at the bottom of the editor
- Open the Function & Output Schema Editor by clicking the Functions & Output button
- Click the Built-in tools button (on the right side) to browse available tools for your selected provider
- Click Add Tool for the tool you want to use — it will appear in your function definitions list
- Configure tool_choice (optional) — set to auto to let the model decide when to use the tool
- Save and run your prompt — the model will use the built-in tools when appropriate
For OpenAI and Azure OpenAI, built-in tools require the Responses API. Switch from Chat Completions API to Responses API in the API dropdown before adding built-in tools.
OpenAI and Azure OpenAI (Responses API)
OpenAI’s Responses API includes powerful pre-built tools that work seamlessly with PromptLayer. These tools are available for both the OpenAI and Azure OpenAI providers.Available Tools
Using File Search with Vector Stores
OpenAI’s File Search tool enables semantic search over your documents using Vector Stores. This powerful feature allows your prompts to automatically retrieve relevant information from uploaded files during inference, making it perfect for building RAG (Retrieval-Augmented Generation) systems, knowledge bases, and documentation assistants.Setting Up File Search
For the File Search tool, you’ll need to create and attach Vector Stores containing your documents:- Enable File Search by following the steps above to add it as a built-in tool
-
Create and configure a Vector Store:
- Click Manage Vector Stores in the File Search configuration
- Click Create to make a new vector store with a custom name
- Upload files via drag-and-drop or file selection (single or multiple files)
- View storage usage, file counts, and manage attached files
-
Attach Vector Stores to your prompt:
- Select one or more vector stores using checkboxes
- Click Save Selection to attach them
- The vector store IDs are added to your tool configuration
-
Run your prompt:
- The LLM will automatically search vector stores when relevant
- Retrieved context is used to generate informed responses
- Sources can be traced back to specific documents
Using Code Interpreter
OpenAI’s Code Interpreter tool enables your prompts to write and execute Python code within a secure, sandboxed environment. This powerful feature allows for dynamic problem-solving, data analysis, visualization generation, and file processing—all without writing custom function definitions. To enable Code Interpreter, follow the steps above to add it as a built-in tool. The tool uses container type"auto" by default, which automatically manages the execution environment. The LLM will automatically use Code Interpreter when it needs to perform calculations, analyze data, create visualizations, or process files.
For detailed information about Code Interpreter’s capabilities, file handling, and configuration options, see the OpenAI Code Interpreter Guide.
Using Image Generation
OpenAI’s Image Generation tool enables the model to generate or edit images using a text prompt directly within a conversation. When the model determines that an image should be created, it invokes theimage_generation tool with an optimized prompt and returns the generated image in the response.
To enable Image Generation, follow the steps above to add it as a built-in tool. Once enabled, the model will automatically generate images when the conversation calls for it.
Generated images appear inline in the response with:
- A collapsible revised prompt showing the optimized text the model used for generation
- Generation parameters such as size, quality, background, and output format
- The generated image displayed in a rich card format
Learn More
- Image Generation Guide
- OpenAI Web Search Guide
- OpenAI File Search Guide
- OpenAI Code Interpreter Guide
- OpenAI Image Generation Guide
- OpenAI Responses API Announcement
- Deep Research API Cookbook
Anthropic
Anthropic provides native built-in tools for Claude models that enable code execution, web search, and system-level interactions directly within conversations.Available Tools
Learn More
Google (Gemini)
Google provides native built-in tools for Gemini models that enable web grounding, location data, code execution, URL analysis, and file search capabilities.Available Tools
Using File Search with Google
Google’s File Search tool uses file search stores for document indexing and retrieval:- Add the File Search tool from the built-in tools menu
- Configure a file search store — specify the store name(s) that contain your indexed documents
- Run your prompt — Gemini will automatically search through indexed documents when relevant context is needed
Learn More
Vertex AI
Vertex AI supports built-in tools from both Google and Anthropic, depending on the model family you are using. PromptLayer automatically shows the correct set of tools based on your selected model.For Gemini Models on Vertex AI
When using Gemini models (e.g.,gemini-3.1-pro-preview), the following Google-native tools are available:
For Claude Models on Vertex AI
When using Claude models (e.g.,claude-sonnet-4-20250514) through Vertex AI, the following Anthropic-native tools are available:

