You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In browser or client-side code, keep provider credentials on the server. Use the rendered request body with your own server endpoint, server action, or edge function rather than calling a provider directly from the client.
252
253
254
+
### Provider-specific fields and raw passthrough
255
+
256
+
Use normalized fields first (`sampling`, `response`, `cache`, `tools`) so prompts stay portable. `response.schema` is the neutral JSON Schema path; adapters emit it as OpenAI/OpenRouter `response_format`, OpenAI Responses `text.format`, Anthropic `output_config.format`, and Gemini `generationConfig.responseJsonSchema`.
257
+
258
+
Use `provider_options` when PromptOpsKit has a known provider-specific mapping, such as Anthropic `top_k`, Gemini's native `response_schema`, or OpenRouter routing fields.
259
+
260
+
```yaml
261
+
response:
262
+
format: json
263
+
schema_name: support_reply
264
+
schema_description: Structured support reply
265
+
schema:
266
+
type: object
267
+
properties:
268
+
answer:
269
+
type: string
270
+
provider_options:
271
+
openrouter:
272
+
provider:
273
+
order: ["anthropic", "openai"]
274
+
transforms: ["middle-out"]
275
+
```
276
+
277
+
When a provider adds a body field PromptOpsKit does not model yet, use `raw`:
278
+
279
+
```yaml
280
+
raw:
281
+
openai:
282
+
service_tier: flex
283
+
anthropic:
284
+
service_tier: auto
285
+
gemini:
286
+
safetySettings:
287
+
- category: HARM_CATEGORY_DANGEROUS_CONTENT
288
+
threshold: BLOCK_ONLY_HIGH
289
+
openrouter:
290
+
usage:
291
+
include: true
292
+
```
293
+
294
+
Each adapter reads only its matching raw block and shallow-merges it into the generated request body after normalized mappings. This is intentionally an escape hatch; prefer first-class fields when they exist.
295
+
253
296
On the server, adapters also provide async prompt-aware helpers so you can use the default `./prompts` and `./.generated-prompts/json` directories without creating a `PromptOpsKit` instance:
254
297
255
298
```typescript
@@ -561,10 +604,11 @@ Prompt files use YAML front matter with these fields:
561
604
|`fallback_models`|`string[]`| Fallback model list |
- Use `response.schema`, `response.schema_name`, `response.schema_description`, and `response.schema_strict` for structured output when possible
248
+
- Use `cache` for provider cache hints
249
+
- Use `tools` for tool definitions
250
+
251
+
Treat `response.schema` as the provider-neutral JSON Schema contract. The adapters emit it through provider-specific request fields: OpenAI/OpenRouter `response_format`, OpenAI Responses `text.format`, Anthropic `output_config.format`, and Gemini `generationConfig.responseJsonSchema`.
252
+
253
+
Use `provider_options` for known non-portable mappings:
254
+
255
+
```yaml
256
+
provider_options:
257
+
anthropic:
258
+
top_k: 40
259
+
tool_choice:
260
+
type: auto
261
+
output_config:
262
+
format:
263
+
type: json_schema
264
+
schema:
265
+
type: object
266
+
gemini:
267
+
# Use only when Gemini's native schema dialect is required.
268
+
response_schema:
269
+
type: object
270
+
response_json_schema:
271
+
type: object
272
+
openrouter:
273
+
provider:
274
+
order: ["anthropic", "openai"]
275
+
transforms: ["middle-out"]
276
+
```
277
+
278
+
Use `raw` only when a vendor request-body field is important and PromptOpsKit does not model it yet:
279
+
280
+
```yaml
281
+
raw:
282
+
openai:
283
+
service_tier: flex
284
+
anthropic:
285
+
service_tier: auto
286
+
gemini:
287
+
safetySettings:
288
+
- category: HARM_CATEGORY_DANGEROUS_CONTENT
289
+
threshold: BLOCK_ONLY_HIGH
290
+
openrouter:
291
+
usage:
292
+
include: true
293
+
```
294
+
295
+
Raw blocks are provider-scoped (`openai`, `openai-responses`/`openai_responses`, `anthropic`, `gemini`/`google`, `openrouter`) and are shallow-merged into the final request body after normalized fields. When adding `raw`, include a short note in `# Notes` explaining why a first-class field is not being used.
296
+
297
+
---
298
+
241
299
## Test sidecars
242
300
243
301
Create a `.test.yaml` file alongside a prompt to define test cases:
`RuntimeRenderOptions` for direct adapter rendering supports `environment`, `tier`, `runtime`, `variables`, `onContextOverflow`, `history`, `toolRegistry`, and `strict`.
250
+
`RuntimeRenderOptions` for direct adapter rendering supports `environment`, `tier`, `runtime`, `variables`, `onContextOverflow`, `history`, `toolRegistry`, `strict`, and `openaiResponses`.
251
+
252
+
Runtime overrides can include the same overridable front matter fields as `environments` and `tiers`, including `raw` provider passthrough blocks. Raw blocks are merged into provider request bodies after normalized fields and provider-specific options.
Object fields (`reasoning`, `sampling`, `response`, `cache`, `provider_options`) are shallow-merged — individual sub-fields are replaced, but you don't need to repeat every sub-field.
60
+
Object fields (`reasoning`, `sampling`, `response`, `cache`, `raw`, `provider_options`) are shallow-merged — individual sub-fields are replaced, but you don't need to repeat every sub-field.
Copy file name to clipboardExpand all lines: docs/prompt-format.md
+55-1Lines changed: 55 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -132,6 +132,44 @@ cache:
132
132
- `gemini.cached_content`(or `google.cached_content`) maps to `cachedContent` for requests that reuse a previously created Gemini cache.
133
133
- You can safely include multiple provider blocks in the same prompt. Each adapter only reads its own block (`openai`, `anthropic`, or `gemini`/`google`) and ignores the others.
134
134
135
+
## Structured JSON output
136
+
137
+
Use the neutral `response` block for structured JSON whenever possible:
138
+
139
+
```yaml
140
+
response:
141
+
format: json
142
+
schema_name: support_reply
143
+
schema_description: Structured support reply
144
+
schema:
145
+
type: object
146
+
properties:
147
+
answer:
148
+
type: string
149
+
```
150
+
151
+
Adapters emit this JSON Schema through the provider-specific body shape: OpenAI/OpenRouter `response_format`, OpenAI Responses `text.format`, Anthropic `output_config.format`, and Gemini `generationConfig.responseJsonSchema`.
152
+
153
+
Use provider-specific schema fields only when the vendor dialect itself matters, such as `provider_options.gemini.response_schema` for Gemini's native schema form.
154
+
155
+
## Raw provider passthrough
156
+
157
+
Use `raw` when a provider supports a request-body field that PromptOpsKit does not expose yet:
158
+
159
+
```yaml
160
+
raw:
161
+
openai:
162
+
service_tier: flex
163
+
anthropic:
164
+
service_tier: auto
165
+
gemini:
166
+
safetySettings:
167
+
- category: HARM_CATEGORY_DANGEROUS_CONTENT
168
+
threshold: BLOCK_ONLY_HIGH
169
+
```
170
+
171
+
Each adapter reads only its own raw block. Raw values are shallow-merged into the generated body after normalized mappings, so they can override generated fields. Prefer normalized fields (`sampling`, `response`, `cache`, `tools`) and `provider_options` first; reserve `raw` for vendor-specific fields that would otherwise be impossible to send.
172
+
135
173
## Sections
136
174
137
175
The Markdown body is split on **H1 headings** into named sections. Three section names are recognized (case-insensitive):
0 commit comments