Interface CompletionAttempt

One provider attempt. outcome settles when iteration ends (a never-iterated attempt never calls the provider).

interface CompletionAttempt {
    outcome: Promise<CompletionOutcome>;
    schemaInPayload?: boolean;
    schemaRoute?: "none" | "json_schema" | "forced_tool";
}

Hierarchy

  • AsyncIterable<ModelCompletionResponse>
    • CompletionAttempt

Properties

outcome: Promise<CompletionOutcome>
schemaInPayload?: boolean

For an attempt with a response schema: true when the hop's provider payload carries the schema (a strict json_schema, Anthropic's forced schema tool, Gemini's responseSchema), false when the schema reaches the model in the prompt alone (no payload for the provider or model, or a JSON mode without one). Unset for an attempt with no schema. It describes the request that answered: a provider that sends the request again without the schema payload (OpenRouter's json_object retry when no endpoint takes the strict schema) says so on its chunks, and the value turns false, so read it once the attempt's stream has ended.

schemaRoute?: "none" | "json_schema" | "forced_tool"

For an attempt with a response schema on an Anthropic hop: the route the hop's request took, as the provider's chunks say it (schemaRoute), else the route of the hop's marker. json_schema (the JSON output format; a text answer that parses is lifted into structuredOutput), forced_tool (a schema tool call whose arguments parse is lifted) or none (the schema rode the prompt; nothing is lifted). Unset on other providers and without a schema; like schemaInPayload, read it once the stream has ended.