Skip to main content

PromptsClient

adaline.prompts creates, reads, updates, and deletes prompts. Related prompt-scoped resources โ€” drafts, playgrounds, evaluators, and evaluations โ€” are exposed through nested sub-clients.

Access

import { Adaline } from '@adaline/client';

const adaline = new Adaline();
const prompts = adaline.prompts; // PromptsClient
The class is also exported directly:
import { PromptsClient } from '@adaline/client';

Sub-clients

PromptsClient exposes four nested namespaces โ€” evaluators and evaluations are here (not at the top level) because every URL is /prompts/{promptId}/...:
PropertyClientCovers
adaline.prompts.draftPromptDraftClientGet the current draft
adaline.prompts.playgroundsPromptPlaygroundsClientList / get playgrounds
adaline.prompts.evaluatorsPromptEvaluatorsClientCRUD for evaluators attached to the prompt
adaline.prompts.evaluationsPromptEvaluationsClientCreate / list / cancel evaluation runs (+ .results for per-row results)
Types used below come from @adaline/api:
import type {
  Prompt,
  CreatePromptRequest,
  PatchPromptRequest,
  ListPromptsResponse,
  SortOrder,
} from '@adaline/api';
Prompt embeds a PromptSnapshot with the latest config, PromptMessage[], ToolFunction[], and PromptVariable[].

list()

List all prompts in a project (paginated). Use fields to trim the response payload.
list(options: {
  projectId: string;
  limit?: number;
  cursor?: string;
  sort?: SortOrder;
  createdAfter?: number;
  createdBefore?: number;
  fields?: string;
}): Promise<ListPromptsResponse>

Parameters

NameTypeRequiredDescription
projectIdstringYesProject whose prompts should be returned.
limitnumberNoPage size (default 50, max 200).
cursorstringNoOpaque cursor from a previous responseโ€™s pagination.nextCursor.
sortSortOrderNo"createdAt:asc" or "createdAt:desc".
createdAfternumberNoUnix milliseconds.
createdBeforenumberNoUnix milliseconds.
fieldsstringNoComma-separated list of top-level fields to include (e.g. "id,title,createdAt").

Returns

Promise<ListPromptsResponse> with shape { data: Prompt[]; pagination: { limit, returned, hasMore, nextCursor } }.

Example

const { data, pagination } = await adaline.prompts.list({
  projectId: 'project_abc123',
  limit: 50,
  sort: 'createdAt:desc',
  fields: 'id,title,createdAt',
});

create()

Create a new prompt in a project. The optional draft seeds the promptโ€™s initial config, messages, and tools.
create(options: { prompt: CreatePromptRequest }): Promise<Prompt>

Parameters

NameTypeRequiredDescription
promptCreatePromptRequestYesPrompt definition.
CreatePromptRequest (abbreviated):
interface CreatePromptRequest {
  projectId: string;
  title: string;
  icon?: BaseEntityIcon;
  draft?: {
    config: PromptSnapshotConfig;
    messages: PromptMessage[];
    tools?: ToolFunction[];
  };
}

Returns

Promise<Prompt> โ€” the created prompt, including server-generated id and draft state.

Example

const prompt = await adaline.prompts.create({
  prompt: {
    projectId: 'project_abc123',
    title: 'Customer support triage',
    icon: { type: 'emoji', value: '๐ŸŽง' },
    draft: {
      config: {
        provider: 'openai',
        model: 'gpt-4o',
        settings: { temperature: 0.3 },
      },
      messages: [
        {
          role: 'system',
          content: [{ modality: 'text', value: 'You are a helpful triage assistant.' }],
        },
      ],
    },
  },
});

console.log(`Created prompt ${prompt.id}`);

get()

Retrieve a single prompt by ID. Use expand: 'playground' to include the default playground inline. Use fields to trim the response.
get(options: {
  promptId: string;
  expand?: 'playground';
  fields?: string;
}): Promise<Prompt>

Parameters

NameTypeRequiredDescription
promptIdstringYesPrompt identifier.
expand'playground'NoInclude the default playground in the response.
fieldsstringNoComma-separated list of top-level fields to include.

Returns

Promise<Prompt> โ€” full prompt with config, messages, tools, variables, and (if requested) playground data.

Example

const prompt = await adaline.prompts.get({
  promptId: 'prompt_abc123',
  expand: 'playground',
});

console.log(`Model: ${prompt.config.provider}/${prompt.config.model}`);
console.log(`Messages: ${prompt.messages.length}`);

update()

Partially update a prompt. You can update title, icon, config, messages, tools, or the default playground. Any field you omit is left untouched. Sent as PATCH under the hood.
update(options: {
  promptId: string;
  playgroundId?: string;
  prompt: PatchPromptRequest;
}): Promise<Prompt>

Parameters

NameTypeRequiredDescription
promptIdstringYesPrompt identifier.
playgroundIdstringNoWhen patching playground-scoped fields, identifies which playground to update.
promptPatchPromptRequestYesFields to update โ€” all top-level keys are optional.

Returns

Promise<Prompt> โ€” the full updated prompt.

Example

const updated = await adaline.prompts.update({
  promptId: 'prompt_abc123',
  prompt: {
    title: 'Renamed prompt',
    config: {
      provider: 'openai',
      model: 'gpt-4o-mini',
      settings: { temperature: 0.7 },
    },
  },
});

delete()

Permanently delete a prompt and all associated resources (drafts, playgrounds, deployments, evaluators, evaluations). Irreversible.
delete(options: { promptId: string }): Promise<void>

Example

await adaline.prompts.delete({ promptId: 'prompt_abc123' });

See Also