Auth: Use an Admin API key or a Workspace API key with prompt permissions. Send
x-portkey-api-key on every request.When to use this
- Migrate dozens of prompts to a new default model after a provider or catalog change
- Keep originals untouched by creating named replicas (for example append
-replica) - Automate what would otherwise be repeated copy-paste in Prompt Studio
How it works
- List all prompts and collect their IDs.
- Retrieve each prompt’s full definition (template
string,parameters,virtual_key, metadata, etc.). - Create a new prompt per ID with the same body fields and a new
modelvalue.
anthropic.claude-3-5-sonnet) with the exact model identifier your workspace uses.
Step 1: List prompts and collect IDs
- Python
- Node.js
Python (steps 2–3): Run the snippets in order in the same session so
BASE, headers, and prompt_ids / prompt_data stay in scope. Node.js: Examples use native fetch (Node.js 18+).Step 2: Fetch one prompt’s full configuration
Use this shape to see which fields the API returns before building the create payload (names vary slightly by version; always log once and adjust keys if needed).- Python
- Node.js
Step 3: Create a single replicated prompt
The replica reuses template content and metadata, overridesmodel, and uses a distinct name so it does not collide with the original.
- Python
- Node.js
Full loop: replicate every prompt
- Python
- Node.js
Field names: If
retrieve responses use different keys (for example nested version objects), log one response and map fields explicitly. Null collection_id: Omit or pass null only if the create API accepts it for your workspace. Rate limits: Add backoff or batching for very large prompt libraries.After replication
- Point applications at the new prompt IDs or keep names predictable (for example
*-replica) and resolve by name if your tooling supports it. - For runtime calls, use the Prompt API (
/v1/prompts/{promptId}/completions) with the replica’s ID.
Summary
Bulk replication avoids manual duplication, keeps templates aligned, and makes model upgrades repeatable across the workspace.

