TypeScript SDK
Escalate only when needed
Parse the review and retry with a stronger frontier model when it falls below your threshold:TypeScript SDK
request_id so failures remain traceable.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Evaluate important outputs in your application and escalate to a stronger model when needed.
const draft = await client.responses.create({
model: "gpt-5.6-luna",
input: customerPrompt,
});
const review = await client.responses.create({
model: "claude-sonnet-5",
input: `Score this answer from 0 to 1 for factual support and completeness.\n\n${draft.output_text}`,
text: {
format: {
type: "json_schema",
name: "quality_review",
strict: true,
schema: {
type: "object",
properties: {
score: { type: "number" },
reason: { type: "string" },
},
required: ["score", "reason"],
additionalProperties: false,
},
},
},
});
const quality = JSON.parse(review.output_text) as { score: number; reason: string };
const final = quality.score >= 0.85
? draft
: await client.responses.create({
model: "gpt-5.6-sol",
input: customerPrompt,
instructions: `Improve the answer. Reviewer feedback: ${quality.reason}`,
});
console.log(final.output_text);
console.log("Total cost:", draft.cost_usd + review.cost_usd + (final === draft ? 0 : final.cost_usd));
request_id so failures remain traceable.
| Workload | Useful check |
|---|---|
| Structured extraction | JSON Schema plus business validation |
| RAG | Citation presence and source coverage |
| Code generation | Typecheck, tests, and static analysis |
| Customer support | Policy compliance and escalation triggers |
| High-stakes synthesis | Independent model review with a written rubric |