Skip to content

Prompts

Shows how to list and retrieve prompts with their content.

This example assumes using HammingAI; is in scope and apiKey contains your HammingAI API key.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
using var client = new HammingAIClient(apiKey);

// List all prompts in the workspace.
var promptsList = await client.Prompts.ListPromptsAsync();

Console.WriteLine($"Found {promptsList.Prompts!.Count} prompts.");

// Get a specific prompt by slug to see its content.
if (promptsList.Prompts.Count > 0)
{
    var slug = promptsList.Prompts[0].Slug!;
    var promptResponse = await client.Prompts.GetPromptAsync(slug: slug);

    var promptValue = promptResponse.Prompt!.Value;
    Console.WriteLine($"Prompt slug: {promptValue.Value1?.Slug}");

    if (promptValue.Value2?.Content is not null)
    {
        Console.WriteLine($"Model: {promptValue.Value2.Content.LanguageModel}");
        Console.WriteLine($"Messages: {promptValue.Value2.Content.ChatMessages?.Count ?? 0}");
    }
}