Prompt Blueprints are a core concept in PromptLayer that provides a standardized, model-agnostic representation of prompts. They serve as an abstraction layer that:
Creates a unified format that works across all LLM providers (OpenAI, Anthropic, etc.)
Enables seamless switching between different models without code changes
Standardizes how prompts, responses, and tool calls are structured and stored
Ensures consistent handling of various content types (text, images, function calls)
Think of Prompt Blueprints as a universal language for LLM interactions that shields your application from provider-specific implementation details.
Instead of accessing the raw LLM response via response["raw_response"], it’s recommended to use the standardized response["prompt_blueprint"]. This ensures consistency across different providers.
PromptLayer now supports streaming responses with prompt_blueprint integration. When streaming is enabled, each chunk includes both the raw streaming response and the progressively built prompt_blueprint, allowing you to track how the response is constructed in real-time.
import promptlayer# Initialize PromptLayer clientpromptlayer_client = promptlayer.PromptLayer()# Run with streaming enabledresponse_stream = promptlayer_client.run( prompt_name="ai-poet", input_variables={'topic': 'food'}, stream=True)# Process streaming chunksfor chunk in response_stream: # Access the raw streaming response raw_chunk = chunk["raw_response"] # Access the progressively built prompt blueprint prompt_blueprint = chunk["prompt_blueprint"] if raw_chunk.choices and raw_chunk.choices[0].delta.content: print(f"Streaming content: {raw_chunk.choices[0].delta.content}") # The prompt_blueprint shows the current state of the response if prompt_blueprint and prompt_blueprint["prompt_template"]["messages"]: current_response = prompt_blueprint["prompt_template"]["messages"][-1] if current_response.get("content"): print(f"Current response: {current_response['content']}")
import promptlayer# Initialize PromptLayer clientpromptlayer_client = promptlayer.PromptLayer()# Run with streaming enabled for Anthropicresponse_stream = promptlayer_client.run( prompt_name="helpful-assistant", input_variables={'task': 'prompt engineering tip'}, stream=True)# Process streaming chunksfor chunk in response_stream: # Access the raw streaming response raw_chunk = chunk["raw_response"] # Access the progressively built prompt blueprint prompt_blueprint = chunk["prompt_blueprint"] # Handle different Anthropic streaming event types if raw_chunk.get("type") == "content_block_delta": delta = raw_chunk.get("delta", {}) if delta.get("type") == "text_delta": print(f"Streaming content: {delta.get('text', '')}") # The prompt_blueprint shows the current state of the response if prompt_blueprint and prompt_blueprint["prompt_template"]["messages"]: current_response = prompt_blueprint["prompt_template"]["messages"][-1] if current_response.get("content") and len(current_response["content"]) > 0: # Get the text content from the current response text_content = current_response["content"][0].get("text", "") if text_content: print(f"Current response: {text_content}")
Placeholder Messages are a powerful feature that allows you to inject messages into a prompt template at runtime. By using the placeholder role, you can define placeholders within your prompt template that can be replaced with full messages when the prompt is executed.For more detailed information on Placeholder Messages, including how to create and use them, please refer to our dedicated Placeholder Messages Documentation page.
{ "role": "user", "content": [ {"signature": "xxxxxx-xxxxx-xxxx-xxxx", "type": "thinking", "thinking": "User is greeting and asking for my wellbeing."}, {"type": "text", "text": "Hello, how are you?"}, ]}
You’re absolutely right - let me update that part of the documentation to show a more realistic tool response format that uses structured JSON data. Here’s the revised section:
The Prompt Blueprint supports tool and function calling capabilities. This section demonstrates how to define available tools, handle assistant tool calls, and provide tool responses.
The parameters field is of interest because it specifies the expected input parameters for the function. The LLM provider will use this information to generate the appropriate tool call. You can define the parameters using JSON Schema format. You can read moe about how OpenAI uses JSON Schema for defining parameters here. And you can read more about how Anthropic uses JSON Schema for defining parameters here.
After executing the requested function, you can provide the result back to the assistant using a “tool” role message. The response should be structured JSON data:
PromptLayer supports any number of modalities in a single prompt. You can include text, images, videos, and other media types in your prompt templates.The media_variable content allows you to dynamically insert a list of medias into prompt template messages.The media_variable is nested within the message content. The type and name are required fields specifying the type of content and the name of the variable, respectively. The name is the name of the list of medias to be dynamically inserted.
Prompt Blueprints can be configured to produce structured outputs that follow a specific format defined by JSON Schema. This ensures consistent response formats that are easier to parse and integrate with your applications.For detailed information on creating and using structured outputs with your prompt templates, see our Structured Outputs documentation.