The Applications API allows you to turn deployed no-code applications into microservices, which can also be used as tools in tool calling. Business users can define inputs, prompts, and outputs, and developers can then add them to other applications, UIs, or services.

This guide shows how to use the /applications endpoint to generate content from no-code applications.

If you do not have a deployed no-code application, follow the guides to build a text generation app or build a research assistant app in AI Studio.

The /applications endpoint supports only text generation and research assistant applications. It does not support chat applications.

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.

Endpoint overview

URL: POST https://api.writer.com/v1/applications/{application_id}

Using the /applications endpoint will result in charges for model usage. See the pricing page for more information.

curl 'https://api.writer.com/v1/applications/<application-id>' \
-X POST \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $WRITER_API_KEY" \
--data-raw '{
  "inputs": [
    {
      "id": "Product description",
      "value": [
        "Terra running shoe"
      ]
    }
  ]
}'

Path parameters

ParameterTypeDescription
application_idstringThe ID of the deployed application. You can find this in the URL of the application in AI Studio: https://app.writer.com/aistudio/organization/<organization-id>/applications/<application-id>. You can also use the List applications endpoint to get the list of deployed applications and see the application ID.

Request body

Below are the required and commonly used optional parameters for the /applications endpoint.

ParameterTypeDescription
inputsarrayInput values matching the application’s defined input fields. The input structure depends on the application type.
inputs[].idstringThe name of the input field. If this is a research assistant application, the input id is always query.
inputs[].valuearray[string]An array containing values of the input field. You can pass multiple values for a single input field. If the input field is a file, the value should be the file_id from an uploaded file, such as ["1234-abcd-1234"]. Learn more about how to upload files with the Files API.
{
  "inputs": [
    {
      "id": "string",
      "value": ["string"]
    }
  ]
}

See the applications endpoint reference for more information on the request body and the additional parameters you can use to control the application.

Response format

The response format depends on the application type and whether you set the stream parameter to true or false. Only research assistant applications support streaming responses at this time.

Non-streaming response

If you set the stream parameter to false, the response is delivered as a JSON object with the following parameters:

ParameterTypeDescription
titlestringThe name of the output field, as defined in the application.
suggestionstringThe output of the application call.
{
  "title": null,
  "suggestion": "The Terra running shoe combines lightweight materials with advanced cushioning technology to deliver exceptional comfort and performance for every stride."
}

Streaming response

If you set the stream parameter to true, the response is delivered as server-sent events. The event contains several parameters. The content of the chunk is in the delta field. You can also use the stages field to get the stages of the research assistant application call, such as “Planning the research” or “Researching and organizing findings.”

Below are the important parameters for extracting the output of the application call.

ParameterTypeDescription
deltaobjectThe content of the chunk.
delta.contentstringThe output of the application call.
delta.stagesarrayThe stage of the research assistant application call.
delta.stages.contentstringThe content of the stage.
data: {'delta': {'title': None,
  'content': None,
  'stages': [{'id': 'a5d81590-0120-4404-948b-8075e3610f51',
    'content': 'Initiating a research assistant: 🚗 Automotive assistant',
    'sources': None}]}}

Example: Text generation application

Text generation applications generate content based on the inputs provided to a specific no-code application created in AI Studio. This is a great way to enable business users to control prompts and outputs while still allowing developers to add them to other applications, UIs, or services.

To invoke a text generation application, you need to provide the application ID and the required inputs to the application. Inputs are defined in the application within AI Studio.

Get the application inputs

To see the required inputs for the application, you can view the application in AI Studio, or you can use the Get application endpoint to get the application details, including the inputs.

The example below shows how to use the Get application endpoint to get the list of required inputs with their name and types.

curl --location --request GET https://api.writer.com/v1/applications/<application-id> \
 --header "Authorization: Bearer $WRITER_API_KEY"

Format the request body with the application inputs

The inputs parameter is an array of objects, each containing an id and value field. The id field is the name of the input field, and the value field is the value of the input field.

{
  "inputs": [
    {
      "id": "Text input name",
      "value": ["Input value 1"]
    },
    {
      "id": "File input name",
      "value": ["1234-fileid-1234"]
    }
  ]
}

If the input field is a file, the value should be the file_id from an uploaded file.

Your request body should be formatted as a JSON object with values for each input.

Generate content from the application

Once you’ve formatted the request body with the application inputs, you can invoke the application using the Generate content endpoint.

The examples below demonstrate calling a text generation application that takes two text inputs: Product description and Target audience.

curl --location --request POST 'https://api.writer.com/v1/applications/{application_id}' \
--header "Authorization: Bearer $WRITER_API_KEY" \
--data-raw '{
  "inputs": [
    {
      "id": "Product description",
      "value": ["Terra running shoe"]
    },
    {
      "id": "Target audience",
      "value": ["Runners"]
    }
  ]
}'

Example: Research assistant application

Research assistant applications output a final report after performing research in stages. Because of this, they support streaming responses.

Research assistant applications take an array of inputs that contain a single item, formatted as a JSON object with id and value parameters. It also takes a stream parameter that is set to false by default.

ParameterTypeDescription
inputsarrayAn array of objects, each containing an id and value field.
inputs[].idstringThe name of the input field. For research assistant applications, the input id is always query.
inputs[].valuearray[string]An array containing the research query.
streamBooleanWhether to stream the response. Defaults to false.

The examples below demonstrate calling a research assistant application to research hotels in San Francisco. The application streams the output as it is generated.

curl --location --request POST 'https://api.writer.com/v1/applications/{application_id}' \
--header "Authorization: Bearer $WRITER_API_KEY" \
--data-raw '{
  "inputs": [
    {
      "id": "query", 
      "value": ["Provide a list of three hotels in San Francisco near Union Square within the price range of $100 to $200 per night"]
    }
  ],
  "stream": true
}'

Next steps

Now that you’ve invoked a no-code application via the API, learn other ways you can use no-code applications via the API: