Skip to main content
Creating, evaluating, and refining prompts is a core activity for AI engineers. Small changes to a prompt can have big impacts on your application’s behavior. W&B Weave lets you create prompts, publish them, and evolve them over time. This page is for AI engineers who want to create reusable prompt objects in Weave and publish them so application code can reference them. By following this guide, you learn how to create single-string and multi-turn prompts, parameterize them with runtime values, and publish them to your Weave project. For referencing, retrieving, and managing versions of published prompts, see Store and track versions of prompts.
To share a published prompt with your whole organization, see Share prompts with Registry.
If your prompt needs are simple, you can use the built-in weave.StringPrompt or weave.MessagesPrompt classes. If your needs are more complex, you can subclass those or the base class weave.Prompt and override the format method. When you publish a prompt with weave.publish, it appears in your Weave project on the Prompts page, where you and your collaborators can browse and reuse it.

StringPrompt

StringPrompt logs single-string prompts that you might use for system messages, user queries, or any standalone text input to an LLM. Use StringPrompt to manage individual prompt strings that don’t require the complexity of multi-message conversations.

MessagesPrompt

MessagesPrompt lets you log multi-turn conversations and chat-based prompts. It stores an array of message objects (with roles like system, user, and assistant) that represent a complete conversation flow. Use MessagesPrompt for chat-based LLMs where you need to maintain context across multiple messages, define specific conversation patterns, or create reusable conversation templates.

Parameterize prompts

Once you can create static prompts, the next step is to make them reusable across different inputs. Both StringPrompt and MessagesPrompt support dynamic content through parameterization. This lets you create reusable prompt templates with placeholders (using {variable} syntax) that you fill with different values at runtime. Parameterization is useful when your prompts must adapt to different inputs, user data, or contexts while maintaining a consistent structure. The format() method accepts key-value pairs to replace these placeholders with actual values.
The same parameterization pattern also works with MessagesPrompt when you need placeholders inside a multi-turn conversation.

Share prompts with Registry

A published prompt belongs to the Weave project you published it to. To share a prompt version across your organization, link it to a collection in a registry. Linking moves the prompt version from a private, project-level scope to a shared, organization-level scope, where the registry’s visibility settings control who can access it. After you link a prompt version, you can:
  • Browse the prompt’s content, aliases, and tags in Registry alongside your organization’s other assets.
  • Retrieve the prompt in application code with weave.get() and a registry:/// URI that references either a fixed version or an alias.
For example, the first of the following URIs always returns version v4 of the prompt. The second returns whichever version currently has the production alias, which you can reassign to a different version later:
Replace ORG, REGISTRY_NAME, and COLLECTION_NAME with your organization, registry, and collection names. Registry assigns version numbers for you, and they always take the form v followed by a number. A custom alias can’t use the same syntax. Any other name, including one that starts with v such as validated, is an alias. For details, see Alias limits. To link a prompt version, call link_prompt_to_registry() in the Python SDK or linkPromptToRegistry() in the TypeScript SDK. For a complete Python example, including how to view and retrieve a linked prompt, see Link a Weave prompt to a collection.
Last modified on November 20, 2026