Fetching Prompts
In this guide we'll cover how to fetch your GenAI Lens prompts and prompt folders using the API. These are the building blocks for AI Visibility analytics: every analytics request is scoped to one or more prompts (or to the folders that contain them).
For an introduction to the concepts referenced here, see the AI Visibility overview.
Before you start
To run through this guide you will need:
- Your Meltwater API token
- Access to GenAI Lens on your account
AI Visibility endpoints are available if your account is entitled to GenAI Lens. If you receive a 401 or an empty prompt list, check that GenAI Lens is enabled for the company you are querying.
Fetching prompts
Use the GET /account/llm/prompts endpoint to fetch a flat, paginated list of the prompts on your account:
curl --request GET \
--url "https://api.meltwater.com/v4/account/llm/prompts" \
--header "Accept: application/json" \
--header "apikey: **********"
A successful request returns a paginated list of prompts:
{
"count": 39,
"page": 1,
"page_size": 10,
"data": [
{
"id": "69f26ff5ffe10bbbaccc0cc3",
"name": "Claude Enterprise",
"prompt_text": "Is Claude safer for enterprise than ChatGPT Enterprise?",
"folder": {
"id": "69f26fe6441e30b76db5a78c",
"name": "Anthropic Safety vs OpenAI Enterprise Security"
}
},
{
"id": "69f26ff25ac999d02590b35e",
"name": "Codex vs Claude speed",
"prompt_text": "OpenAI Codex vs Claude Code, which is faster for big projects?",
"folder": {
"id": "69f26fe52e166c14939981ae",
"name": "Claude Code vs OpenAI Codex"
}
}
]
}
You'll use the id of each prompt in your analytics requests. See Analyzing Prompts for how to use these IDs.
The folder object is omitted for uncategorised prompts.
Paginating
The list is paginated. Use the following query parameters to page through your prompts:
page- the page number to return (1-indexed, default1, max100)page_size- the number of prompts per page (default10, max100)
The count field in the response is the total number of prompts matching your request across all pages, so you can use it to determine how many pages to fetch.
curl --request GET \
--url "https://api.meltwater.com/v4/account/llm/prompts?page=2&page_size=50" \
--header "Accept: application/json" \
--header "apikey: **********"
Filtering prompts by folder
To fetch only the prompts within a single folder, pass the folder's id as the folder_id query parameter:
curl --request GET \
--url "https://api.meltwater.com/v4/account/llm/prompts?folder_id=69f26fe6441e30b76db5a78c" \
--header "Accept: application/json" \
--header "apikey: **********"
Omit folder_id to return prompts across all folders.
Fetching prompt folders
Use the GET /account/llm/prompts/folders endpoint to fetch a list of your prompt folders:
curl --request GET \
--url "https://api.meltwater.com/v4/account/llm/prompts/folders" \
--header "Accept: application/json" \
--header "apikey: **********"
A successful request returns a paginated list of folders:
{
"count": 3,
"page": 1,
"page_size": 10,
"data": [
{
"id": "69f26fecea1a1f91361e8827",
"name": "Agentic Workflows and Autonomy",
"prompt_count": 8
},
{
"id": "69f26fe6441e30b76db5a78c",
"name": "Anthropic Safety vs OpenAI Enterprise Security",
"prompt_count": 2
},
{
"id": "694614f81c25d692d8a6d8b7",
"name": "Frontier Labs Perception",
"prompt_count": 3
}
]
}
A folder id can be used in two ways:
- As the
folder_idfilter on the prompts endpoint (above) - In the
query.prompt_foldersfield of an analytics request, to analyse every prompt in a folder at once - see Analyzing Prompts
This endpoint is paginated using the same page and page_size parameters as the prompts endpoint.
Next steps
Now that you can fetch your prompts and folders, head to Analyzing Prompts to fetch metrics, trends and top terms for them.