Define LLM completions directly in feature code using chalk.prompts.completion. Messages can use Jinja templates to reference feature values. Stored named prompts and run_prompt are no longer supported.

​
Prompt definitions

To define a direct prompt to perform sentiment analysis on a comment, you could define the following Chalk features utilizing the chalk.prompts library.

import chalk.functions as F
import chalk.prompts as P
from chalk.features import _, features
from pydantic import BaseModel, Field

system_message = """You are a sentiment analysis expert. Analyze the user's comment and determine if it's positive, negative, or neutral.
Rules:
- Be objective and focus on the text's emotional tone
- Consider context and nuance
- Provide a confidence score based on clarity of sentiment"""

user_message = "Analyze this comment: {{User.comment}}"

class UserSentiment(BaseModel):
    sentiment: str = Field(description="positive, negative, or neutral")
    confidence: float = Field(description="on a 1-100 scale")

@features
class User:
    id: str
    comment: str
    actual_sentiment: str
    response: P.PromptResponse = P.completion(
        model="gpt-5.1",
        messages=[
            P.message(role="system", content=system_message),
            P.message(role="user", content=F.jinja(user_message)),
        ],
        output_structure=UserSentiment,
    )
    predicted_sentiment: str = F.json_value(_.response.response, "sentiment")

In the example above, we see how direct prompts integrate with Chalk’s feature system. The prompt uses Jinja templating to dynamically inject the user’s comment into the prompt through {{User.comment}}, allowing the LLM to analyze the specific content at runtime. The UserSentiment Pydantic model defines a structured output format, ensuring consistent response parsing across all completions. While this approach provides fine-grained control over the prompt configuration, it tightly couples the prompt template, model settings, and output structure to your deployment code. Any changes to the prompt template or model parameters require a new deployment.

​
Multimodal Prompts

Chalk’s chat completion API extends beyond text-only interactions by supporting multimodal inputs, enabling you to process images alongside text in your LLM workflows. This capability opens up new possibilities for visual content analysis, allowing you to pass images directly to vision-capable models like GPT-5.1, combine text and image inputs in a single prompt, and extract structured information from visual content. Here’s how you can process a receipt image to extract structured data:

@features
class Receipt:
    image_url: str
    image_response: P.MultimodalPromptResponse = P.completion(
        model="gpt-5.1",
        messages=[
            P.message(
                "user",
                [
                    {"type": "input_text", "text": "Extract all items, prices, and total from this receipt"},
                    {"type": "input_image", "image_url": _.image_url},
                ],
            ),
        ],
    )

Image inputs work with Chalk’s feature system the same way text inputs do. The same structured output capabilities available for text-only prompts apply here, allowing you to define Pydantic models for consistent parsing of visual information extraction tasks.