Skip to content
Sign up

Create template (Cloud-only)

client.templates.create(TemplateCreateParamsbody, RequestOptionsoptions?): TemplateCreateResponse { id, latest_version, name, 5 more }
post/v1/templates

Creates a new template from an existing agent or agent file

ParametersExpand Collapse
TemplateCreateParams = Variant0 | Variant1
TemplateCreateParamsBase { agent_id, type, name }
agent_id: string

The ID of the agent to use as a template, can be from any project

type: "agent"
name?: string

Optional custom name for the template. If not provided, a random name will be generated.

Variant0 extends TemplateCreateParamsBase { agent_id, type, name }
Variant1 extends TemplateCreateParamsBase { agent_id, type, name }
ReturnsExpand Collapse
TemplateCreateResponse { id, latest_version, name, 5 more }
id: string
latest_version: string

The latest version of the template

name: string

The exact name of the template

project_id: string
project_slug: string
template_deployment_slug: string

The full name of the template, including version and project slug

updated_at: string

When the template was last updated

description?: string
Create template (Cloud-only)
import Letta from '@letta-ai/letta-client';

const client = new Letta({
  apiKey: process.env['LETTA_API_KEY'], // This is the default and can be omitted
});

const template = await client.templates.create({ agent_id: 'agent_id', type: 'agent' });

console.log(template.id);
{
  "id": "id",
  "latest_version": "latest_version",
  "name": "name",
  "project_id": "project_id",
  "project_slug": "project_slug",
  "template_deployment_slug": "template_deployment_slug",
  "updated_at": "updated_at",
  "description": "description"
}
Returns Examples
{
  "id": "id",
  "latest_version": "latest_version",
  "name": "name",
  "project_id": "project_id",
  "project_slug": "project_slug",
  "template_deployment_slug": "template_deployment_slug",
  "updated_at": "updated_at",
  "description": "description"
}