@@ -22,6 +22,11 @@ context:
2222 - app_context
2323includes:
2424 - ./shared/tone.md
25+ environments:
26+ dev:
27+ model: gpt-5.4-mini
28+ sampling:
29+ temperature: 0.2
2530---
2631
2732# System instructions
@@ -66,6 +71,47 @@ const TEST_SIDECAR = `cases:
6671 app_context: "Settings page"
6772` ;
6873
74+ const EXAMPLE_USAGE = `// Example: render the hello prompt and send it to OpenAI
75+ // Full docs: https://promptopskit.com/docs/#/getting-started
76+
77+ import { createPromptOpsKit } from 'promptopskit';
78+
79+ async function main() {
80+ const kit = createPromptOpsKit({ sourceDir: './prompts' });
81+
82+ // Determine environment from ENV var (defaults to 'dev')
83+ // - dev: uses gpt-5.4-mini with temperature 0.2 (see hello.md environments)
84+ // - production: uses base model gpt-5.4 with default settings
85+ const environment = process.env.NODE_ENV === 'production' ? 'prod' : 'dev';
86+
87+ const { request } = await kit.renderPrompt({
88+ path: 'hello',
89+ provider: 'openai',
90+ environment,
91+ variables: {
92+ name: 'World',
93+ app_context: 'Welcome screen',
94+ },
95+ });
96+
97+ console.log('Model:', request.body.model);
98+
99+ const res = await fetch('https://api.openai.com/v1/chat/completions', {
100+ method: 'POST',
101+ headers: {
102+ 'Content-Type': 'application/json',
103+ Authorization: \`Bearer \${process.env.OPENAI_API_KEY}\`,
104+ },
105+ body: JSON.stringify(request.body),
106+ });
107+
108+ const data = await res.json();
109+ console.log(data.choices[0].message.content);
110+ }
111+
112+ main();
113+ ` ;
114+
69115export async function init ( args : string [ ] ) : Promise < void > {
70116 if ( args . includes ( '--help' ) || args . includes ( '-h' ) ) {
71117 console . log ( HELP ) ;
@@ -79,6 +125,7 @@ export async function init(args: string[]): Promise<void> {
79125 { path : join ( dir , 'hello.md' ) , content : HELLO_PROMPT } ,
80126 { path : join ( dir , 'hello.test.yaml' ) , content : TEST_SIDECAR } ,
81127 { path : join ( dir , 'shared' , 'tone.md' ) , content : TONE_INCLUDE } ,
128+ { path : join ( dir , 'example-usage.ts' ) , content : EXAMPLE_USAGE } ,
82129 ] ;
83130
84131 let created = 0 ;
0 commit comments