Create Prompts
This guide shows you how to set up the Agenta SDK for managing prompts programmatically.
Creating a new application
Prompts are applications in Agenta. To create a new prompt, you need to specify the slug, and the type of the application.
The type of the application can be SERVICE:completion, SERVICE:chat, or CUSTOM:
SERVICE:completionis for single-turn prompts.SERVICE:chatis for multi-turn prompts.CUSTOMis for custom prompts.
- Python SDK
- JS/TS
- API
# Creates an empty application
app = ag.AppManager.create(
app_slug="my-app-slug",
template_key="SERVICE:completion", # we define here the app type
# template_key="SERVICE:chat" # chat prompts
# template_key="CUSTOM" # custom configuration (schema-less, however unless you provide a URI, you can only use the registry but not the playground)
)
const response = await fetch('https://cloud.agenta.ai/api/simple/applications/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'ApiKey YOUR_API_KEY'
},
body: JSON.stringify({
application: {
slug: 'my-app-slug',
name: 'my-app-slug',
flags: { is_chat: false } // set is_chat: true for multi-turn prompts
}
})
});
const result = await response.json();
console.log(result);
curl -X POST "https://cloud.agenta.ai/api/simple/applications/" \
-H "Content-Type: application/json" \
-H "Authorization: ApiKey YOUR_API_KEY" \
-d '{
"application": {
"slug": "my-app-slug",
"name": "my-app-slug",
"flags": { "is_chat": false }
}
}'
The REST endpoint creates the application artifact. Selecting a prompt template (SERVICE:completion, SERVICE:chat, CUSTOM) is performed through the flags object and, for custom workflows, by committing an initial revision. For the full multi-step flow, see Create and Commit. The Python SDK's ag.AppManager.create(template_key=...) handles this in one call.
The app created until now is empty. You cannot use it from the UI yet. You need to create a variant and commit changes to it to be able to use it (next section).
