import { toOpenAiServiceTierParam } from "../../model-options.js";
function stripOpenAiProviderPrefix(modelId) {
    return modelId.trim().replace(/^openai\//i, "");
}
export function isOpenAiResponsesTextModelId(modelId) {
    const normalized = stripOpenAiProviderPrefix(modelId).toLowerCase();
    return normalized.startsWith("gpt-5") && normalized !== "gpt-5-chat";
}
export function buildOpenAiResponsesRequestOptions(requestOptions, structuredOutput) {
    const serviceTier = toOpenAiServiceTierParam(requestOptions?.serviceTier);
    const text = {
        ...(requestOptions?.textVerbosity ? { verbosity: requestOptions.textVerbosity } : {}),
        ...(structuredOutput
            ? {
                format: {
                    type: "json_schema",
                    name: structuredOutput.name,
                    strict: true,
                    schema: structuredOutput.schema,
                },
            }
            : {}),
    };
    return {
        ...(serviceTier ? { service_tier: serviceTier } : {}),
        ...(requestOptions?.reasoningEffort
            ? { reasoning: { effort: requestOptions.reasoningEffort } }
            : {}),
        ...(Object.keys(text).length > 0 ? { text } : {}),
    };
}
export function buildOpenAiChatRequestOptions(requestOptions) {
    if (!requestOptions)
        return {};
    const serviceTier = toOpenAiServiceTierParam(requestOptions.serviceTier);
    return {
        ...(serviceTier ? { service_tier: serviceTier } : {}),
        ...(requestOptions.reasoningEffort ? { reasoning_effort: requestOptions.reasoningEffort } : {}),
        ...(requestOptions.textVerbosity ? { verbosity: requestOptions.textVerbosity } : {}),
    };
}
//# sourceMappingURL=request-options.js.map