Skip to main content
No-code applications are now called no-code agents. The Applications API, which you can use to programmatically interact with no-code agents, still uses the term application to minimize breaking changes.
You can use deployed no-code agents as tools in chat completions with Palmyra X4 and X5. This approach allows you to:
  • Use no-code agents alongside other tools
  • Chain multiple no-code agents together
  • Combine outputs with other API calls or business logic
If you don’t have a deployed no-code agent, build one with text generation or research capabilities in AI Studio and deploy it to get an application ID.
You need an API key to access the Writer API. Get an API key by following the steps in the API quickstart.We recommend setting the API key as an environment variable in a .env file with the name WRITER_API_KEY.

Tool structure

To use a no-code agent as a tool, define the tool in a tools array when making the request to the chat endpoint. The tools array contains an object with the following parameters:

function.parameters.properties

The function.parameters.properties object contains the tool’s parameter definitions as a JSON schema. The object’s keys should be the names of the parameters, and the values should be objects containing the parameter’s type and description. When the model decides you should use the tool to answer the user’s question, it will return the parameters that you should use when calling the function you’ve defined. Below is an example of a tool definition for a no-code agent that generates product descriptions.
To help the model understand when to use the tool, follow these best practices for the function.description parameter:
  • Indicate that the tool is a function that invokes a no-code agent
  • Specify the agent’s purpose and capabilities
  • Describe when the tool should be used
An example description for a tool that invokes an agent with text-generation:
“A function that invokes an AI agent for text-generation, specialized in generating product descriptions. Any user request asking for product descriptions should use this tool.”

Response format

When the model decides to use a custom tool, the response from the tool call is returned in the tool_calls object. The tool_calls object contains the following fields: Here is an example of a chat completion response that includes a tool call. In this example, the model decides to use the generate_product_description tool to answer the user’s question, and provides the arguments to pass to the function.
sample response[expandable]

Usage example

The following example demonstrates how to use a no-code agent that performs text generation tasks as a tool in a chat completion. The example uses a hypothetical product description agent, but you can use any no-code agent in this way.

Create a function that calls your deployed agent

First, create a function that calls your deployed agent. You will use this function if the LLM you’re chatting with decides to use the tool. The function below takes a product_name parameter, invokes the no-code agent with the agent’s required input fields, and returns the generated product description. If you are unfamiliar with how to invoke a no-code agent with the SDK, see the no-code agent guide.

Define your agent as a tool

Next, define your agent as a tool so the LLM knows when to use it. See the tool structure section for more details on the tool object.

Use your agent as a tool in a chat completion

Add the tools array to the chat endpoint call along with your array of messages. Setting tool_choice to auto allows the model to choose when to use the no-code agent tool, based on the user’s question and the description of the tool. When the model decides to use the tool you’ve defined, it will indicate that in the tool_calls object of the response. This example uses a non-streaming response. For a streaming implementation, and to learn more about processing custom tool call responses, see the tool calling guide.
Here is the full code example:

Next steps

Now that you’ve defined a custom tool, explore other ways to extend your applications: