"use strict";
/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.CreateCompletionAndLt$outboundSchema = exports.CreateCompletionAndLte$outboundSchema = exports.CreateCompletionAndIn$outboundSchema = exports.CreateCompletionAndRouterCompletionsIn$outboundSchema = exports.CreateCompletionAndNin$outboundSchema = exports.CreateCompletionAndRouterCompletionsNin$outboundSchema = exports.CreateCompletionAndExists$outboundSchema = exports.CreateCompletionFilterByOr$outboundSchema = exports.CreateCompletionFilterByRouterCompletionsOr$outboundSchema = exports.CreateCompletionOrEq$outboundSchema = exports.CreateCompletionOrRouterCompletionsEq$outboundSchema = exports.CreateCompletionOrNe$outboundSchema = exports.CreateCompletionOrRouterCompletionsNe$outboundSchema = exports.CreateCompletionOrGt$outboundSchema = exports.CreateCompletionOrGte$outboundSchema = exports.CreateCompletionOrLt$outboundSchema = exports.CreateCompletionOrLte$outboundSchema = exports.CreateCompletionOrIn$outboundSchema = exports.CreateCompletionOrRouterCompletionsIn$outboundSchema = exports.CreateCompletionOrNin$outboundSchema = exports.CreateCompletionOrRouterCompletionsNin$outboundSchema = exports.CreateCompletionOrExists$outboundSchema = exports.CreateCompletionSearchType$outboundSchema = exports.CreateCompletionRouterCompletionsCache$outboundSchema = exports.CreateCompletionRouterCompletionsType$outboundSchema = exports.CreateCompletionInputs$outboundSchema = exports.CreateCompletionInputs2$outboundSchema = exports.CreateCompletionThread$outboundSchema = exports.CreateCompletionPrompt$outboundSchema = exports.CreateCompletionVersion$outboundSchema = exports.CreateCompletionRouterCompletionsFallbacks$outboundSchema = exports.CreateCompletionRouterCompletionsRetry$outboundSchema = exports.CreateCompletionTimeout$outboundSchema = exports.CreateCompletionLoadBalancer$outboundSchema = exports.CreateCompletionLoadBalancer1$outboundSchema = exports.CreateCompletionLoadBalancerModels$outboundSchema = exports.CreateCompletionLoadBalancerType$outboundSchema = exports.CreateCompletionCache$outboundSchema = exports.CreateCompletionType$outboundSchema = exports.CreateCompletionRetry$outboundSchema = exports.CreateCompletionFallbacks$outboundSchema = exports.CreateCompletionStop$outboundSchema = exports.CreateCompletionFinishReason = exports.CreateCompletionRouterCompletionsFinishReason = exports.CreateCompletionLoadBalancerRouterCompletionsType = exports.CreateCompletionSearchType = exports.CreateCompletionRouterCompletionsType = exports.CreateCompletionVersion = exports.CreateCompletionLoadBalancerType = exports.CreateCompletionType = void 0;
exports.CreateCompletionResponse$inboundSchema = exports.CreateCompletionResponseBody$inboundSchema = exports.CreateCompletionUsage$inboundSchema = exports.CreateCompletionCompletionTokensDetails$inboundSchema = exports.CreateCompletionPromptTokensDetails$inboundSchema = exports.Created$inboundSchema = exports.CreateCompletionChoices$inboundSchema = exports.CreateCompletionFinishReason$inboundSchema = exports.CreateCompletionRouterCompletionsResponseBody$inboundSchema = exports.CreateCompletionData$inboundSchema = exports.CreateCompletionRouterCompletionsUsage$inboundSchema = exports.CreateCompletionRouterCompletionsCompletionTokensDetails$inboundSchema = exports.CreateCompletionRouterCompletionsPromptTokensDetails$inboundSchema = exports.CreateCompletionCreated$inboundSchema = exports.CreateCompletionRouterCompletionsChoices$inboundSchema = exports.CreateCompletionRouterCompletionsFinishReason$inboundSchema = exports.CreateCompletionRequestBody$outboundSchema = exports.CreateCompletionOrq$outboundSchema = exports.CreateCompletionRouterCompletionsTimeout$outboundSchema = exports.CreateCompletionRouterCompletionsLoadBalancer$outboundSchema = exports.CreateCompletionLoadBalancerRouterCompletions1$outboundSchema = exports.CreateCompletionLoadBalancerRouterCompletionsModels$outboundSchema = exports.CreateCompletionLoadBalancerRouterCompletionsType$outboundSchema = exports.CreateCompletionKnowledgeBases$outboundSchema = exports.CreateCompletionAgenticRagConfig$outboundSchema = exports.CreateCompletionRerankConfig$outboundSchema = exports.CreateCompletionSearchOptions$outboundSchema = exports.CreateCompletionFilterBy$outboundSchema = exports.CreateCompletionFilterBy1$outboundSchema = exports.CreateCompletion1Eq$outboundSchema = exports.CreateCompletion1RouterCompletionsEq$outboundSchema = exports.CreateCompletion1Ne$outboundSchema = exports.CreateCompletion1RouterCompletionsNe$outboundSchema = exports.CreateCompletion1Gt$outboundSchema = exports.CreateCompletion1Gte$outboundSchema = exports.CreateCompletion1Lt$outboundSchema = exports.CreateCompletion1Lte$outboundSchema = exports.CreateCompletion1In$outboundSchema = exports.CreateCompletion1RouterCompletionsIn$outboundSchema = exports.CreateCompletion1Nin$outboundSchema = exports.CreateCompletion1RouterCompletionsNin$outboundSchema = exports.CreateCompletion1Exists$outboundSchema = exports.CreateCompletionFilterByAnd$outboundSchema = exports.CreateCompletionFilterByRouterCompletionsAnd$outboundSchema = exports.CreateCompletionAndEq$outboundSchema = exports.CreateCompletionAndRouterCompletionsEq$outboundSchema = exports.CreateCompletionAndNe$outboundSchema = exports.CreateCompletionAndRouterCompletionsNe$outboundSchema = exports.CreateCompletionAndGt$outboundSchema = exports.CreateCompletionAndGte$outboundSchema = void 0;
exports.createCompletionStopToJSON = createCompletionStopToJSON;
exports.createCompletionFallbacksToJSON = createCompletionFallbacksToJSON;
exports.createCompletionRetryToJSON = createCompletionRetryToJSON;
exports.createCompletionCacheToJSON = createCompletionCacheToJSON;
exports.createCompletionLoadBalancerModelsToJSON = createCompletionLoadBalancerModelsToJSON;
exports.createCompletionLoadBalancer1ToJSON = createCompletionLoadBalancer1ToJSON;
exports.createCompletionLoadBalancerToJSON = createCompletionLoadBalancerToJSON;
exports.createCompletionTimeoutToJSON = createCompletionTimeoutToJSON;
exports.createCompletionRouterCompletionsRetryToJSON = createCompletionRouterCompletionsRetryToJSON;
exports.createCompletionRouterCompletionsFallbacksToJSON = createCompletionRouterCompletionsFallbacksToJSON;
exports.createCompletionPromptToJSON = createCompletionPromptToJSON;
exports.createCompletionThreadToJSON = createCompletionThreadToJSON;
exports.createCompletionInputs2ToJSON = createCompletionInputs2ToJSON;
exports.createCompletionInputsToJSON = createCompletionInputsToJSON;
exports.createCompletionRouterCompletionsCacheToJSON = createCompletionRouterCompletionsCacheToJSON;
exports.createCompletionOrExistsToJSON = createCompletionOrExistsToJSON;
exports.createCompletionOrRouterCompletionsNinToJSON = createCompletionOrRouterCompletionsNinToJSON;
exports.createCompletionOrNinToJSON = createCompletionOrNinToJSON;
exports.createCompletionOrRouterCompletionsInToJSON = createCompletionOrRouterCompletionsInToJSON;
exports.createCompletionOrInToJSON = createCompletionOrInToJSON;
exports.createCompletionOrLteToJSON = createCompletionOrLteToJSON;
exports.createCompletionOrLtToJSON = createCompletionOrLtToJSON;
exports.createCompletionOrGteToJSON = createCompletionOrGteToJSON;
exports.createCompletionOrGtToJSON = createCompletionOrGtToJSON;
exports.createCompletionOrRouterCompletionsNeToJSON = createCompletionOrRouterCompletionsNeToJSON;
exports.createCompletionOrNeToJSON = createCompletionOrNeToJSON;
exports.createCompletionOrRouterCompletionsEqToJSON = createCompletionOrRouterCompletionsEqToJSON;
exports.createCompletionOrEqToJSON = createCompletionOrEqToJSON;
exports.createCompletionFilterByRouterCompletionsOrToJSON = createCompletionFilterByRouterCompletionsOrToJSON;
exports.createCompletionFilterByOrToJSON = createCompletionFilterByOrToJSON;
exports.createCompletionAndExistsToJSON = createCompletionAndExistsToJSON;
exports.createCompletionAndRouterCompletionsNinToJSON = createCompletionAndRouterCompletionsNinToJSON;
exports.createCompletionAndNinToJSON = createCompletionAndNinToJSON;
exports.createCompletionAndRouterCompletionsInToJSON = createCompletionAndRouterCompletionsInToJSON;
exports.createCompletionAndInToJSON = createCompletionAndInToJSON;
exports.createCompletionAndLteToJSON = createCompletionAndLteToJSON;
exports.createCompletionAndLtToJSON = createCompletionAndLtToJSON;
exports.createCompletionAndGteToJSON = createCompletionAndGteToJSON;
exports.createCompletionAndGtToJSON = createCompletionAndGtToJSON;
exports.createCompletionAndRouterCompletionsNeToJSON = createCompletionAndRouterCompletionsNeToJSON;
exports.createCompletionAndNeToJSON = createCompletionAndNeToJSON;
exports.createCompletionAndRouterCompletionsEqToJSON = createCompletionAndRouterCompletionsEqToJSON;
exports.createCompletionAndEqToJSON = createCompletionAndEqToJSON;
exports.createCompletionFilterByRouterCompletionsAndToJSON = createCompletionFilterByRouterCompletionsAndToJSON;
exports.createCompletionFilterByAndToJSON = createCompletionFilterByAndToJSON;
exports.createCompletion1ExistsToJSON = createCompletion1ExistsToJSON;
exports.createCompletion1RouterCompletionsNinToJSON = createCompletion1RouterCompletionsNinToJSON;
exports.createCompletion1NinToJSON = createCompletion1NinToJSON;
exports.createCompletion1RouterCompletionsInToJSON = createCompletion1RouterCompletionsInToJSON;
exports.createCompletion1InToJSON = createCompletion1InToJSON;
exports.createCompletion1LteToJSON = createCompletion1LteToJSON;
exports.createCompletion1LtToJSON = createCompletion1LtToJSON;
exports.createCompletion1GteToJSON = createCompletion1GteToJSON;
exports.createCompletion1GtToJSON = createCompletion1GtToJSON;
exports.createCompletion1RouterCompletionsNeToJSON = createCompletion1RouterCompletionsNeToJSON;
exports.createCompletion1NeToJSON = createCompletion1NeToJSON;
exports.createCompletion1RouterCompletionsEqToJSON = createCompletion1RouterCompletionsEqToJSON;
exports.createCompletion1EqToJSON = createCompletion1EqToJSON;
exports.createCompletionFilterBy1ToJSON = createCompletionFilterBy1ToJSON;
exports.createCompletionFilterByToJSON = createCompletionFilterByToJSON;
exports.createCompletionSearchOptionsToJSON = createCompletionSearchOptionsToJSON;
exports.createCompletionRerankConfigToJSON = createCompletionRerankConfigToJSON;
exports.createCompletionAgenticRagConfigToJSON = createCompletionAgenticRagConfigToJSON;
exports.createCompletionKnowledgeBasesToJSON = createCompletionKnowledgeBasesToJSON;
exports.createCompletionLoadBalancerRouterCompletionsModelsToJSON = createCompletionLoadBalancerRouterCompletionsModelsToJSON;
exports.createCompletionLoadBalancerRouterCompletions1ToJSON = createCompletionLoadBalancerRouterCompletions1ToJSON;
exports.createCompletionRouterCompletionsLoadBalancerToJSON = createCompletionRouterCompletionsLoadBalancerToJSON;
exports.createCompletionRouterCompletionsTimeoutToJSON = createCompletionRouterCompletionsTimeoutToJSON;
exports.createCompletionOrqToJSON = createCompletionOrqToJSON;
exports.createCompletionRequestBodyToJSON = createCompletionRequestBodyToJSON;
exports.createCompletionRouterCompletionsChoicesFromJSON = createCompletionRouterCompletionsChoicesFromJSON;
exports.createCompletionCreatedFromJSON = createCompletionCreatedFromJSON;
exports.createCompletionRouterCompletionsPromptTokensDetailsFromJSON = createCompletionRouterCompletionsPromptTokensDetailsFromJSON;
exports.createCompletionRouterCompletionsCompletionTokensDetailsFromJSON = createCompletionRouterCompletionsCompletionTokensDetailsFromJSON;
exports.createCompletionRouterCompletionsUsageFromJSON = createCompletionRouterCompletionsUsageFromJSON;
exports.createCompletionDataFromJSON = createCompletionDataFromJSON;
exports.createCompletionRouterCompletionsResponseBodyFromJSON = createCompletionRouterCompletionsResponseBodyFromJSON;
exports.createCompletionChoicesFromJSON = createCompletionChoicesFromJSON;
exports.createdFromJSON = createdFromJSON;
exports.createCompletionPromptTokensDetailsFromJSON = createCompletionPromptTokensDetailsFromJSON;
exports.createCompletionCompletionTokensDetailsFromJSON = createCompletionCompletionTokensDetailsFromJSON;
exports.createCompletionUsageFromJSON = createCompletionUsageFromJSON;
exports.createCompletionResponseBodyFromJSON = createCompletionResponseBodyFromJSON;
exports.createCompletionResponseFromJSON = createCompletionResponseFromJSON;
const z = __importStar(require("zod/v3"));
const event_streams_js_1 = require("../../lib/event-streams.js");
const primitives_js_1 = require("../../lib/primitives.js");
const schemas_js_1 = require("../../lib/schemas.js");
const components = __importStar(require("../components/index.js"));
exports.CreateCompletionType = {
    ExactMatch: "exact_match",
};
exports.CreateCompletionLoadBalancerType = {
    WeightBased: "weight_based",
};
/**
 * Version of the prompt to use (currently only "latest" supported)
 */
exports.CreateCompletionVersion = {
    Latest: "latest",
};
exports.CreateCompletionRouterCompletionsType = {
    ExactMatch: "exact_match",
};
/**
 * The type of search to perform. If not provided, will default to the knowledge base configured `retrieval_type`
 */
exports.CreateCompletionSearchType = {
    VectorSearch: "vector_search",
    KeywordSearch: "keyword_search",
    HybridSearch: "hybrid_search",
};
exports.CreateCompletionLoadBalancerRouterCompletionsType = {
    WeightBased: "weight_based",
};
/**
 * The reason the model stopped generating tokens.
 */
exports.CreateCompletionRouterCompletionsFinishReason = {
    Stop: "stop",
    Length: "length",
    ContentFilter: "content_filter",
    ToolCalls: "tool_calls",
};
/**
 * The reason the model stopped generating tokens.
 */
exports.CreateCompletionFinishReason = {
    Stop: "stop",
    Length: "length",
    ContentFilter: "content_filter",
    ToolCalls: "tool_calls",
};
/** @internal */
exports.CreateCompletionStop$outboundSchema = z.union([z.string(), z.array(z.string())]);
function createCompletionStopToJSON(createCompletionStop) {
    return JSON.stringify(exports.CreateCompletionStop$outboundSchema.parse(createCompletionStop));
}
/** @internal */
exports.CreateCompletionFallbacks$outboundSchema = z.object({
    model: z.string(),
});
function createCompletionFallbacksToJSON(createCompletionFallbacks) {
    return JSON.stringify(exports.CreateCompletionFallbacks$outboundSchema.parse(createCompletionFallbacks));
}
/** @internal */
exports.CreateCompletionRetry$outboundSchema = z.object({
    count: z.number().default(3),
    onCodes: z.array(z.number()).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        onCodes: "on_codes",
    });
});
function createCompletionRetryToJSON(createCompletionRetry) {
    return JSON.stringify(exports.CreateCompletionRetry$outboundSchema.parse(createCompletionRetry));
}
/** @internal */
exports.CreateCompletionType$outboundSchema = z.nativeEnum(exports.CreateCompletionType);
/** @internal */
exports.CreateCompletionCache$outboundSchema = z.object({
    ttl: z.number().default(1800),
    type: exports.CreateCompletionType$outboundSchema,
});
function createCompletionCacheToJSON(createCompletionCache) {
    return JSON.stringify(exports.CreateCompletionCache$outboundSchema.parse(createCompletionCache));
}
/** @internal */
exports.CreateCompletionLoadBalancerType$outboundSchema = z.nativeEnum(exports.CreateCompletionLoadBalancerType);
/** @internal */
exports.CreateCompletionLoadBalancerModels$outboundSchema = z.object({
    model: z.string(),
    weight: z.number().default(0.5),
});
function createCompletionLoadBalancerModelsToJSON(createCompletionLoadBalancerModels) {
    return JSON.stringify(exports.CreateCompletionLoadBalancerModels$outboundSchema.parse(createCompletionLoadBalancerModels));
}
/** @internal */
exports.CreateCompletionLoadBalancer1$outboundSchema = z.object({
    type: exports.CreateCompletionLoadBalancerType$outboundSchema,
    models: z.array(z.lazy(() => exports.CreateCompletionLoadBalancerModels$outboundSchema)),
});
function createCompletionLoadBalancer1ToJSON(createCompletionLoadBalancer1) {
    return JSON.stringify(exports.CreateCompletionLoadBalancer1$outboundSchema.parse(createCompletionLoadBalancer1));
}
/** @internal */
exports.CreateCompletionLoadBalancer$outboundSchema = z.lazy(() => exports.CreateCompletionLoadBalancer1$outboundSchema);
function createCompletionLoadBalancerToJSON(createCompletionLoadBalancer) {
    return JSON.stringify(exports.CreateCompletionLoadBalancer$outboundSchema.parse(createCompletionLoadBalancer));
}
/** @internal */
exports.CreateCompletionTimeout$outboundSchema = z.object({
    callTimeout: z.number(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        callTimeout: "call_timeout",
    });
});
function createCompletionTimeoutToJSON(createCompletionTimeout) {
    return JSON.stringify(exports.CreateCompletionTimeout$outboundSchema.parse(createCompletionTimeout));
}
/** @internal */
exports.CreateCompletionRouterCompletionsRetry$outboundSchema = z.object({
    count: z.number().default(3),
    onCodes: z.array(z.number()).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        onCodes: "on_codes",
    });
});
function createCompletionRouterCompletionsRetryToJSON(createCompletionRouterCompletionsRetry) {
    return JSON.stringify(exports.CreateCompletionRouterCompletionsRetry$outboundSchema.parse(createCompletionRouterCompletionsRetry));
}
/** @internal */
exports.CreateCompletionRouterCompletionsFallbacks$outboundSchema = z.object({
    model: z.string(),
});
function createCompletionRouterCompletionsFallbacksToJSON(createCompletionRouterCompletionsFallbacks) {
    return JSON.stringify(exports.CreateCompletionRouterCompletionsFallbacks$outboundSchema.parse(createCompletionRouterCompletionsFallbacks));
}
/** @internal */
exports.CreateCompletionVersion$outboundSchema = z.nativeEnum(exports.CreateCompletionVersion);
/** @internal */
exports.CreateCompletionPrompt$outboundSchema = z.object({
    id: z.string(),
    version: exports.CreateCompletionVersion$outboundSchema,
});
function createCompletionPromptToJSON(createCompletionPrompt) {
    return JSON.stringify(exports.CreateCompletionPrompt$outboundSchema.parse(createCompletionPrompt));
}
/** @internal */
exports.CreateCompletionThread$outboundSchema = z.object({
    id: z.string(),
    tags: z.array(z.string()).optional(),
});
function createCompletionThreadToJSON(createCompletionThread) {
    return JSON.stringify(exports.CreateCompletionThread$outboundSchema.parse(createCompletionThread));
}
/** @internal */
exports.CreateCompletionInputs2$outboundSchema = z.object({
    key: z.string(),
    value: z.any().optional(),
    isPii: z.boolean().optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        isPii: "is_pii",
    });
});
function createCompletionInputs2ToJSON(createCompletionInputs2) {
    return JSON.stringify(exports.CreateCompletionInputs2$outboundSchema.parse(createCompletionInputs2));
}
/** @internal */
exports.CreateCompletionInputs$outboundSchema = z.union([
    z.record(z.any()),
    z.array(z.lazy(() => exports.CreateCompletionInputs2$outboundSchema)),
]);
function createCompletionInputsToJSON(createCompletionInputs) {
    return JSON.stringify(exports.CreateCompletionInputs$outboundSchema.parse(createCompletionInputs));
}
/** @internal */
exports.CreateCompletionRouterCompletionsType$outboundSchema = z.nativeEnum(exports.CreateCompletionRouterCompletionsType);
/** @internal */
exports.CreateCompletionRouterCompletionsCache$outboundSchema = z.object({
    ttl: z.number().default(1800),
    type: exports.CreateCompletionRouterCompletionsType$outboundSchema,
});
function createCompletionRouterCompletionsCacheToJSON(createCompletionRouterCompletionsCache) {
    return JSON.stringify(exports.CreateCompletionRouterCompletionsCache$outboundSchema.parse(createCompletionRouterCompletionsCache));
}
/** @internal */
exports.CreateCompletionSearchType$outboundSchema = z.nativeEnum(exports.CreateCompletionSearchType);
/** @internal */
exports.CreateCompletionOrExists$outboundSchema = z.object({
    exists: z.boolean(),
});
function createCompletionOrExistsToJSON(createCompletionOrExists) {
    return JSON.stringify(exports.CreateCompletionOrExists$outboundSchema.parse(createCompletionOrExists));
}
/** @internal */
exports.CreateCompletionOrRouterCompletionsNin$outboundSchema = z.union([z.string(), z.number(), z.boolean()]);
function createCompletionOrRouterCompletionsNinToJSON(createCompletionOrRouterCompletionsNin) {
    return JSON.stringify(exports.CreateCompletionOrRouterCompletionsNin$outboundSchema.parse(createCompletionOrRouterCompletionsNin));
}
/** @internal */
exports.CreateCompletionOrNin$outboundSchema = z.object({
    nin: z.array(z.union([z.string(), z.number(), z.boolean()])),
});
function createCompletionOrNinToJSON(createCompletionOrNin) {
    return JSON.stringify(exports.CreateCompletionOrNin$outboundSchema.parse(createCompletionOrNin));
}
/** @internal */
exports.CreateCompletionOrRouterCompletionsIn$outboundSchema = z.union([z.string(), z.number(), z.boolean()]);
function createCompletionOrRouterCompletionsInToJSON(createCompletionOrRouterCompletionsIn) {
    return JSON.stringify(exports.CreateCompletionOrRouterCompletionsIn$outboundSchema.parse(createCompletionOrRouterCompletionsIn));
}
/** @internal */
exports.CreateCompletionOrIn$outboundSchema = z.object({
    in: z.array(z.union([z.string(), z.number(), z.boolean()])),
});
function createCompletionOrInToJSON(createCompletionOrIn) {
    return JSON.stringify(exports.CreateCompletionOrIn$outboundSchema.parse(createCompletionOrIn));
}
/** @internal */
exports.CreateCompletionOrLte$outboundSchema = z.object({
    lte: z.number(),
});
function createCompletionOrLteToJSON(createCompletionOrLte) {
    return JSON.stringify(exports.CreateCompletionOrLte$outboundSchema.parse(createCompletionOrLte));
}
/** @internal */
exports.CreateCompletionOrLt$outboundSchema = z.object({
    lt: z.number(),
});
function createCompletionOrLtToJSON(createCompletionOrLt) {
    return JSON.stringify(exports.CreateCompletionOrLt$outboundSchema.parse(createCompletionOrLt));
}
/** @internal */
exports.CreateCompletionOrGte$outboundSchema = z.object({
    gte: z.number(),
});
function createCompletionOrGteToJSON(createCompletionOrGte) {
    return JSON.stringify(exports.CreateCompletionOrGte$outboundSchema.parse(createCompletionOrGte));
}
/** @internal */
exports.CreateCompletionOrGt$outboundSchema = z.object({
    gt: z.number(),
});
function createCompletionOrGtToJSON(createCompletionOrGt) {
    return JSON.stringify(exports.CreateCompletionOrGt$outboundSchema.parse(createCompletionOrGt));
}
/** @internal */
exports.CreateCompletionOrRouterCompletionsNe$outboundSchema = z.union([z.string(), z.number(), z.boolean()]);
function createCompletionOrRouterCompletionsNeToJSON(createCompletionOrRouterCompletionsNe) {
    return JSON.stringify(exports.CreateCompletionOrRouterCompletionsNe$outboundSchema.parse(createCompletionOrRouterCompletionsNe));
}
/** @internal */
exports.CreateCompletionOrNe$outboundSchema = z.object({
    ne: z.union([z.string(), z.number(), z.boolean()]),
});
function createCompletionOrNeToJSON(createCompletionOrNe) {
    return JSON.stringify(exports.CreateCompletionOrNe$outboundSchema.parse(createCompletionOrNe));
}
/** @internal */
exports.CreateCompletionOrRouterCompletionsEq$outboundSchema = z.union([z.string(), z.number(), z.boolean()]);
function createCompletionOrRouterCompletionsEqToJSON(createCompletionOrRouterCompletionsEq) {
    return JSON.stringify(exports.CreateCompletionOrRouterCompletionsEq$outboundSchema.parse(createCompletionOrRouterCompletionsEq));
}
/** @internal */
exports.CreateCompletionOrEq$outboundSchema = z.object({
    eq: z.union([z.string(), z.number(), z.boolean()]),
});
function createCompletionOrEqToJSON(createCompletionOrEq) {
    return JSON.stringify(exports.CreateCompletionOrEq$outboundSchema.parse(createCompletionOrEq));
}
/** @internal */
exports.CreateCompletionFilterByRouterCompletionsOr$outboundSchema = z.union([
    z.lazy(() => exports.CreateCompletionOrEq$outboundSchema),
    z.lazy(() => exports.CreateCompletionOrNe$outboundSchema),
    z.lazy(() => exports.CreateCompletionOrGt$outboundSchema),
    z.lazy(() => exports.CreateCompletionOrGte$outboundSchema),
    z.lazy(() => exports.CreateCompletionOrLt$outboundSchema),
    z.lazy(() => exports.CreateCompletionOrLte$outboundSchema),
    z.lazy(() => exports.CreateCompletionOrIn$outboundSchema),
    z.lazy(() => exports.CreateCompletionOrNin$outboundSchema),
    z.lazy(() => exports.CreateCompletionOrExists$outboundSchema),
]);
function createCompletionFilterByRouterCompletionsOrToJSON(createCompletionFilterByRouterCompletionsOr) {
    return JSON.stringify(exports.CreateCompletionFilterByRouterCompletionsOr$outboundSchema.parse(createCompletionFilterByRouterCompletionsOr));
}
/** @internal */
exports.CreateCompletionFilterByOr$outboundSchema = z.object({
    or: z.array(z.record(z.union([
        z.lazy(() => exports.CreateCompletionOrEq$outboundSchema),
        z.lazy(() => exports.CreateCompletionOrNe$outboundSchema),
        z.lazy(() => exports.CreateCompletionOrGt$outboundSchema),
        z.lazy(() => exports.CreateCompletionOrGte$outboundSchema),
        z.lazy(() => exports.CreateCompletionOrLt$outboundSchema),
        z.lazy(() => exports.CreateCompletionOrLte$outboundSchema),
        z.lazy(() => exports.CreateCompletionOrIn$outboundSchema),
        z.lazy(() => exports.CreateCompletionOrNin$outboundSchema),
        z.lazy(() => exports.CreateCompletionOrExists$outboundSchema),
    ]))),
});
function createCompletionFilterByOrToJSON(createCompletionFilterByOr) {
    return JSON.stringify(exports.CreateCompletionFilterByOr$outboundSchema.parse(createCompletionFilterByOr));
}
/** @internal */
exports.CreateCompletionAndExists$outboundSchema = z.object({
    exists: z.boolean(),
});
function createCompletionAndExistsToJSON(createCompletionAndExists) {
    return JSON.stringify(exports.CreateCompletionAndExists$outboundSchema.parse(createCompletionAndExists));
}
/** @internal */
exports.CreateCompletionAndRouterCompletionsNin$outboundSchema = z.union([z.string(), z.number(), z.boolean()]);
function createCompletionAndRouterCompletionsNinToJSON(createCompletionAndRouterCompletionsNin) {
    return JSON.stringify(exports.CreateCompletionAndRouterCompletionsNin$outboundSchema.parse(createCompletionAndRouterCompletionsNin));
}
/** @internal */
exports.CreateCompletionAndNin$outboundSchema = z.object({
    nin: z.array(z.union([z.string(), z.number(), z.boolean()])),
});
function createCompletionAndNinToJSON(createCompletionAndNin) {
    return JSON.stringify(exports.CreateCompletionAndNin$outboundSchema.parse(createCompletionAndNin));
}
/** @internal */
exports.CreateCompletionAndRouterCompletionsIn$outboundSchema = z.union([z.string(), z.number(), z.boolean()]);
function createCompletionAndRouterCompletionsInToJSON(createCompletionAndRouterCompletionsIn) {
    return JSON.stringify(exports.CreateCompletionAndRouterCompletionsIn$outboundSchema.parse(createCompletionAndRouterCompletionsIn));
}
/** @internal */
exports.CreateCompletionAndIn$outboundSchema = z.object({
    in: z.array(z.union([z.string(), z.number(), z.boolean()])),
});
function createCompletionAndInToJSON(createCompletionAndIn) {
    return JSON.stringify(exports.CreateCompletionAndIn$outboundSchema.parse(createCompletionAndIn));
}
/** @internal */
exports.CreateCompletionAndLte$outboundSchema = z.object({
    lte: z.number(),
});
function createCompletionAndLteToJSON(createCompletionAndLte) {
    return JSON.stringify(exports.CreateCompletionAndLte$outboundSchema.parse(createCompletionAndLte));
}
/** @internal */
exports.CreateCompletionAndLt$outboundSchema = z.object({
    lt: z.number(),
});
function createCompletionAndLtToJSON(createCompletionAndLt) {
    return JSON.stringify(exports.CreateCompletionAndLt$outboundSchema.parse(createCompletionAndLt));
}
/** @internal */
exports.CreateCompletionAndGte$outboundSchema = z.object({
    gte: z.number(),
});
function createCompletionAndGteToJSON(createCompletionAndGte) {
    return JSON.stringify(exports.CreateCompletionAndGte$outboundSchema.parse(createCompletionAndGte));
}
/** @internal */
exports.CreateCompletionAndGt$outboundSchema = z.object({
    gt: z.number(),
});
function createCompletionAndGtToJSON(createCompletionAndGt) {
    return JSON.stringify(exports.CreateCompletionAndGt$outboundSchema.parse(createCompletionAndGt));
}
/** @internal */
exports.CreateCompletionAndRouterCompletionsNe$outboundSchema = z.union([z.string(), z.number(), z.boolean()]);
function createCompletionAndRouterCompletionsNeToJSON(createCompletionAndRouterCompletionsNe) {
    return JSON.stringify(exports.CreateCompletionAndRouterCompletionsNe$outboundSchema.parse(createCompletionAndRouterCompletionsNe));
}
/** @internal */
exports.CreateCompletionAndNe$outboundSchema = z.object({
    ne: z.union([z.string(), z.number(), z.boolean()]),
});
function createCompletionAndNeToJSON(createCompletionAndNe) {
    return JSON.stringify(exports.CreateCompletionAndNe$outboundSchema.parse(createCompletionAndNe));
}
/** @internal */
exports.CreateCompletionAndRouterCompletionsEq$outboundSchema = z.union([z.string(), z.number(), z.boolean()]);
function createCompletionAndRouterCompletionsEqToJSON(createCompletionAndRouterCompletionsEq) {
    return JSON.stringify(exports.CreateCompletionAndRouterCompletionsEq$outboundSchema.parse(createCompletionAndRouterCompletionsEq));
}
/** @internal */
exports.CreateCompletionAndEq$outboundSchema = z.object({
    eq: z.union([z.string(), z.number(), z.boolean()]),
});
function createCompletionAndEqToJSON(createCompletionAndEq) {
    return JSON.stringify(exports.CreateCompletionAndEq$outboundSchema.parse(createCompletionAndEq));
}
/** @internal */
exports.CreateCompletionFilterByRouterCompletionsAnd$outboundSchema = z.union([
    z.lazy(() => exports.CreateCompletionAndEq$outboundSchema),
    z.lazy(() => exports.CreateCompletionAndNe$outboundSchema),
    z.lazy(() => exports.CreateCompletionAndGt$outboundSchema),
    z.lazy(() => exports.CreateCompletionAndGte$outboundSchema),
    z.lazy(() => exports.CreateCompletionAndLt$outboundSchema),
    z.lazy(() => exports.CreateCompletionAndLte$outboundSchema),
    z.lazy(() => exports.CreateCompletionAndIn$outboundSchema),
    z.lazy(() => exports.CreateCompletionAndNin$outboundSchema),
    z.lazy(() => exports.CreateCompletionAndExists$outboundSchema),
]);
function createCompletionFilterByRouterCompletionsAndToJSON(createCompletionFilterByRouterCompletionsAnd) {
    return JSON.stringify(exports.CreateCompletionFilterByRouterCompletionsAnd$outboundSchema.parse(createCompletionFilterByRouterCompletionsAnd));
}
/** @internal */
exports.CreateCompletionFilterByAnd$outboundSchema = z.object({
    and: z.array(z.record(z.union([
        z.lazy(() => exports.CreateCompletionAndEq$outboundSchema),
        z.lazy(() => exports.CreateCompletionAndNe$outboundSchema),
        z.lazy(() => exports.CreateCompletionAndGt$outboundSchema),
        z.lazy(() => exports.CreateCompletionAndGte$outboundSchema),
        z.lazy(() => exports.CreateCompletionAndLt$outboundSchema),
        z.lazy(() => exports.CreateCompletionAndLte$outboundSchema),
        z.lazy(() => exports.CreateCompletionAndIn$outboundSchema),
        z.lazy(() => exports.CreateCompletionAndNin$outboundSchema),
        z.lazy(() => exports.CreateCompletionAndExists$outboundSchema),
    ]))),
});
function createCompletionFilterByAndToJSON(createCompletionFilterByAnd) {
    return JSON.stringify(exports.CreateCompletionFilterByAnd$outboundSchema.parse(createCompletionFilterByAnd));
}
/** @internal */
exports.CreateCompletion1Exists$outboundSchema = z.object({
    exists: z.boolean(),
});
function createCompletion1ExistsToJSON(createCompletion1Exists) {
    return JSON.stringify(exports.CreateCompletion1Exists$outboundSchema.parse(createCompletion1Exists));
}
/** @internal */
exports.CreateCompletion1RouterCompletionsNin$outboundSchema = z.union([z.string(), z.number(), z.boolean()]);
function createCompletion1RouterCompletionsNinToJSON(createCompletion1RouterCompletionsNin) {
    return JSON.stringify(exports.CreateCompletion1RouterCompletionsNin$outboundSchema.parse(createCompletion1RouterCompletionsNin));
}
/** @internal */
exports.CreateCompletion1Nin$outboundSchema = z.object({
    nin: z.array(z.union([z.string(), z.number(), z.boolean()])),
});
function createCompletion1NinToJSON(createCompletion1Nin) {
    return JSON.stringify(exports.CreateCompletion1Nin$outboundSchema.parse(createCompletion1Nin));
}
/** @internal */
exports.CreateCompletion1RouterCompletionsIn$outboundSchema = z.union([z.string(), z.number(), z.boolean()]);
function createCompletion1RouterCompletionsInToJSON(createCompletion1RouterCompletionsIn) {
    return JSON.stringify(exports.CreateCompletion1RouterCompletionsIn$outboundSchema.parse(createCompletion1RouterCompletionsIn));
}
/** @internal */
exports.CreateCompletion1In$outboundSchema = z.object({
    in: z.array(z.union([z.string(), z.number(), z.boolean()])),
});
function createCompletion1InToJSON(createCompletion1In) {
    return JSON.stringify(exports.CreateCompletion1In$outboundSchema.parse(createCompletion1In));
}
/** @internal */
exports.CreateCompletion1Lte$outboundSchema = z.object({
    lte: z.number(),
});
function createCompletion1LteToJSON(createCompletion1Lte) {
    return JSON.stringify(exports.CreateCompletion1Lte$outboundSchema.parse(createCompletion1Lte));
}
/** @internal */
exports.CreateCompletion1Lt$outboundSchema = z.object({
    lt: z.number(),
});
function createCompletion1LtToJSON(createCompletion1Lt) {
    return JSON.stringify(exports.CreateCompletion1Lt$outboundSchema.parse(createCompletion1Lt));
}
/** @internal */
exports.CreateCompletion1Gte$outboundSchema = z.object({
    gte: z.number(),
});
function createCompletion1GteToJSON(createCompletion1Gte) {
    return JSON.stringify(exports.CreateCompletion1Gte$outboundSchema.parse(createCompletion1Gte));
}
/** @internal */
exports.CreateCompletion1Gt$outboundSchema = z.object({
    gt: z.number(),
});
function createCompletion1GtToJSON(createCompletion1Gt) {
    return JSON.stringify(exports.CreateCompletion1Gt$outboundSchema.parse(createCompletion1Gt));
}
/** @internal */
exports.CreateCompletion1RouterCompletionsNe$outboundSchema = z.union([z.string(), z.number(), z.boolean()]);
function createCompletion1RouterCompletionsNeToJSON(createCompletion1RouterCompletionsNe) {
    return JSON.stringify(exports.CreateCompletion1RouterCompletionsNe$outboundSchema.parse(createCompletion1RouterCompletionsNe));
}
/** @internal */
exports.CreateCompletion1Ne$outboundSchema = z.object({
    ne: z.union([z.string(), z.number(), z.boolean()]),
});
function createCompletion1NeToJSON(createCompletion1Ne) {
    return JSON.stringify(exports.CreateCompletion1Ne$outboundSchema.parse(createCompletion1Ne));
}
/** @internal */
exports.CreateCompletion1RouterCompletionsEq$outboundSchema = z.union([z.string(), z.number(), z.boolean()]);
function createCompletion1RouterCompletionsEqToJSON(createCompletion1RouterCompletionsEq) {
    return JSON.stringify(exports.CreateCompletion1RouterCompletionsEq$outboundSchema.parse(createCompletion1RouterCompletionsEq));
}
/** @internal */
exports.CreateCompletion1Eq$outboundSchema = z.object({
    eq: z.union([z.string(), z.number(), z.boolean()]),
});
function createCompletion1EqToJSON(createCompletion1Eq) {
    return JSON.stringify(exports.CreateCompletion1Eq$outboundSchema.parse(createCompletion1Eq));
}
/** @internal */
exports.CreateCompletionFilterBy1$outboundSchema = z.union([
    z.lazy(() => exports.CreateCompletion1Eq$outboundSchema),
    z.lazy(() => exports.CreateCompletion1Ne$outboundSchema),
    z.lazy(() => exports.CreateCompletion1Gt$outboundSchema),
    z.lazy(() => exports.CreateCompletion1Gte$outboundSchema),
    z.lazy(() => exports.CreateCompletion1Lt$outboundSchema),
    z.lazy(() => exports.CreateCompletion1Lte$outboundSchema),
    z.lazy(() => exports.CreateCompletion1In$outboundSchema),
    z.lazy(() => exports.CreateCompletion1Nin$outboundSchema),
    z.lazy(() => exports.CreateCompletion1Exists$outboundSchema),
]);
function createCompletionFilterBy1ToJSON(createCompletionFilterBy1) {
    return JSON.stringify(exports.CreateCompletionFilterBy1$outboundSchema.parse(createCompletionFilterBy1));
}
/** @internal */
exports.CreateCompletionFilterBy$outboundSchema = z.union([
    z.lazy(() => exports.CreateCompletionFilterByAnd$outboundSchema),
    z.lazy(() => exports.CreateCompletionFilterByOr$outboundSchema),
    z.record(z.union([
        z.lazy(() => exports.CreateCompletion1Eq$outboundSchema),
        z.lazy(() => exports.CreateCompletion1Ne$outboundSchema),
        z.lazy(() => exports.CreateCompletion1Gt$outboundSchema),
        z.lazy(() => exports.CreateCompletion1Gte$outboundSchema),
        z.lazy(() => exports.CreateCompletion1Lt$outboundSchema),
        z.lazy(() => exports.CreateCompletion1Lte$outboundSchema),
        z.lazy(() => exports.CreateCompletion1In$outboundSchema),
        z.lazy(() => exports.CreateCompletion1Nin$outboundSchema),
        z.lazy(() => exports.CreateCompletion1Exists$outboundSchema),
    ])),
]);
function createCompletionFilterByToJSON(createCompletionFilterBy) {
    return JSON.stringify(exports.CreateCompletionFilterBy$outboundSchema.parse(createCompletionFilterBy));
}
/** @internal */
exports.CreateCompletionSearchOptions$outboundSchema = z.object({
    includeVectors: z.boolean().optional(),
    includeMetadata: z.boolean().optional(),
    includeScores: z.boolean().optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        includeVectors: "include_vectors",
        includeMetadata: "include_metadata",
        includeScores: "include_scores",
    });
});
function createCompletionSearchOptionsToJSON(createCompletionSearchOptions) {
    return JSON.stringify(exports.CreateCompletionSearchOptions$outboundSchema.parse(createCompletionSearchOptions));
}
/** @internal */
exports.CreateCompletionRerankConfig$outboundSchema = z.object({
    model: z.string(),
    threshold: z.number().default(0),
    topK: z.number().int().default(10),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        topK: "top_k",
    });
});
function createCompletionRerankConfigToJSON(createCompletionRerankConfig) {
    return JSON.stringify(exports.CreateCompletionRerankConfig$outboundSchema.parse(createCompletionRerankConfig));
}
/** @internal */
exports.CreateCompletionAgenticRagConfig$outboundSchema = z.object({
    model: z.string(),
});
function createCompletionAgenticRagConfigToJSON(createCompletionAgenticRagConfig) {
    return JSON.stringify(exports.CreateCompletionAgenticRagConfig$outboundSchema.parse(createCompletionAgenticRagConfig));
}
/** @internal */
exports.CreateCompletionKnowledgeBases$outboundSchema = z.object({
    topK: z.number().int().optional(),
    threshold: z.number().optional(),
    searchType: exports.CreateCompletionSearchType$outboundSchema.default("hybrid_search"),
    filterBy: z.union([
        z.lazy(() => exports.CreateCompletionFilterByAnd$outboundSchema),
        z.lazy(() => exports.CreateCompletionFilterByOr$outboundSchema),
        z.record(z.union([
            z.lazy(() => exports.CreateCompletion1Eq$outboundSchema),
            z.lazy(() => exports.CreateCompletion1Ne$outboundSchema),
            z.lazy(() => exports.CreateCompletion1Gt$outboundSchema),
            z.lazy(() => exports.CreateCompletion1Gte$outboundSchema),
            z.lazy(() => exports.CreateCompletion1Lt$outboundSchema),
            z.lazy(() => exports.CreateCompletion1Lte$outboundSchema),
            z.lazy(() => exports.CreateCompletion1In$outboundSchema),
            z.lazy(() => exports.CreateCompletion1Nin$outboundSchema),
            z.lazy(() => exports.CreateCompletion1Exists$outboundSchema),
        ])),
    ]).optional(),
    searchOptions: z.lazy(() => exports.CreateCompletionSearchOptions$outboundSchema)
        .optional(),
    rerankConfig: z.lazy(() => exports.CreateCompletionRerankConfig$outboundSchema)
        .optional(),
    agenticRagConfig: z.lazy(() => exports.CreateCompletionAgenticRagConfig$outboundSchema).optional(),
    knowledgeId: z.string(),
    query: z.string().optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        topK: "top_k",
        searchType: "search_type",
        filterBy: "filter_by",
        searchOptions: "search_options",
        rerankConfig: "rerank_config",
        agenticRagConfig: "agentic_rag_config",
        knowledgeId: "knowledge_id",
    });
});
function createCompletionKnowledgeBasesToJSON(createCompletionKnowledgeBases) {
    return JSON.stringify(exports.CreateCompletionKnowledgeBases$outboundSchema.parse(createCompletionKnowledgeBases));
}
/** @internal */
exports.CreateCompletionLoadBalancerRouterCompletionsType$outboundSchema = z
    .nativeEnum(exports.CreateCompletionLoadBalancerRouterCompletionsType);
/** @internal */
exports.CreateCompletionLoadBalancerRouterCompletionsModels$outboundSchema = z.object({
    model: z.string(),
    weight: z.number().default(0.5),
});
function createCompletionLoadBalancerRouterCompletionsModelsToJSON(createCompletionLoadBalancerRouterCompletionsModels) {
    return JSON.stringify(exports.CreateCompletionLoadBalancerRouterCompletionsModels$outboundSchema.parse(createCompletionLoadBalancerRouterCompletionsModels));
}
/** @internal */
exports.CreateCompletionLoadBalancerRouterCompletions1$outboundSchema = z.object({
    type: exports.CreateCompletionLoadBalancerRouterCompletionsType$outboundSchema,
    models: z.array(z.lazy(() => exports.CreateCompletionLoadBalancerRouterCompletionsModels$outboundSchema)),
});
function createCompletionLoadBalancerRouterCompletions1ToJSON(createCompletionLoadBalancerRouterCompletions1) {
    return JSON.stringify(exports.CreateCompletionLoadBalancerRouterCompletions1$outboundSchema.parse(createCompletionLoadBalancerRouterCompletions1));
}
/** @internal */
exports.CreateCompletionRouterCompletionsLoadBalancer$outboundSchema = z.lazy(() => exports.CreateCompletionLoadBalancerRouterCompletions1$outboundSchema);
function createCompletionRouterCompletionsLoadBalancerToJSON(createCompletionRouterCompletionsLoadBalancer) {
    return JSON.stringify(exports.CreateCompletionRouterCompletionsLoadBalancer$outboundSchema.parse(createCompletionRouterCompletionsLoadBalancer));
}
/** @internal */
exports.CreateCompletionRouterCompletionsTimeout$outboundSchema = z.object({
    callTimeout: z.number(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        callTimeout: "call_timeout",
    });
});
function createCompletionRouterCompletionsTimeoutToJSON(createCompletionRouterCompletionsTimeout) {
    return JSON.stringify(exports.CreateCompletionRouterCompletionsTimeout$outboundSchema.parse(createCompletionRouterCompletionsTimeout));
}
/** @internal */
exports.CreateCompletionOrq$outboundSchema = z.object({
    name: z.string().optional(),
    retry: z.lazy(() => exports.CreateCompletionRouterCompletionsRetry$outboundSchema)
        .optional(),
    fallbacks: z.array(z.lazy(() => exports.CreateCompletionRouterCompletionsFallbacks$outboundSchema)).optional(),
    prompt: z.lazy(() => exports.CreateCompletionPrompt$outboundSchema).optional(),
    identity: components.PublicIdentity$outboundSchema.optional(),
    contact: components.PublicContact$outboundSchema.optional(),
    thread: z.lazy(() => exports.CreateCompletionThread$outboundSchema).optional(),
    inputs: z.union([
        z.record(z.any()),
        z.array(z.lazy(() => exports.CreateCompletionInputs2$outboundSchema)),
    ]).optional(),
    cache: z.lazy(() => exports.CreateCompletionRouterCompletionsCache$outboundSchema)
        .optional(),
    knowledgeBases: z.array(z.lazy(() => exports.CreateCompletionKnowledgeBases$outboundSchema)).optional(),
    loadBalancer: z.lazy(() => exports.CreateCompletionLoadBalancerRouterCompletions1$outboundSchema).optional(),
    timeout: z.lazy(() => exports.CreateCompletionRouterCompletionsTimeout$outboundSchema)
        .optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        knowledgeBases: "knowledge_bases",
        loadBalancer: "load_balancer",
    });
});
function createCompletionOrqToJSON(createCompletionOrq) {
    return JSON.stringify(exports.CreateCompletionOrq$outboundSchema.parse(createCompletionOrq));
}
/** @internal */
exports.CreateCompletionRequestBody$outboundSchema = z.object({
    model: z.string(),
    prompt: z.string(),
    echo: z.nullable(z.boolean().default(false)),
    frequencyPenalty: z.nullable(z.number().default(0)),
    maxTokens: z.nullable(z.number().default(16)),
    presencePenalty: z.nullable(z.number().default(0)),
    seed: z.nullable(z.number()).optional(),
    stop: z.nullable(z.union([z.string(), z.array(z.string())])).optional(),
    temperature: z.nullable(z.number().default(1)),
    topP: z.nullable(z.number().default(1)),
    n: z.nullable(z.number().default(1)),
    user: z.string().optional(),
    name: z.string().optional(),
    fallbacks: z.array(z.lazy(() => exports.CreateCompletionFallbacks$outboundSchema))
        .optional(),
    retry: z.lazy(() => exports.CreateCompletionRetry$outboundSchema).optional(),
    cache: z.lazy(() => exports.CreateCompletionCache$outboundSchema).optional(),
    loadBalancer: z.lazy(() => exports.CreateCompletionLoadBalancer1$outboundSchema)
        .optional(),
    timeout: z.lazy(() => exports.CreateCompletionTimeout$outboundSchema).optional(),
    orq: z.lazy(() => exports.CreateCompletionOrq$outboundSchema).optional(),
    stream: z.boolean().default(false),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        frequencyPenalty: "frequency_penalty",
        maxTokens: "max_tokens",
        presencePenalty: "presence_penalty",
        topP: "top_p",
        loadBalancer: "load_balancer",
    });
});
function createCompletionRequestBodyToJSON(createCompletionRequestBody) {
    return JSON.stringify(exports.CreateCompletionRequestBody$outboundSchema.parse(createCompletionRequestBody));
}
/** @internal */
exports.CreateCompletionRouterCompletionsFinishReason$inboundSchema = z
    .nativeEnum(exports.CreateCompletionRouterCompletionsFinishReason);
/** @internal */
exports.CreateCompletionRouterCompletionsChoices$inboundSchema = z.object({
    finish_reason: exports.CreateCompletionRouterCompletionsFinishReason$inboundSchema,
    index: z.number(),
    text: z.string(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "finish_reason": "finishReason",
    });
});
function createCompletionRouterCompletionsChoicesFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.CreateCompletionRouterCompletionsChoices$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateCompletionRouterCompletionsChoices' from JSON`);
}
/** @internal */
exports.CreateCompletionCreated$inboundSchema = z.union([z.string(), z.number()]);
function createCompletionCreatedFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.CreateCompletionCreated$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateCompletionCreated' from JSON`);
}
/** @internal */
exports.CreateCompletionRouterCompletionsPromptTokensDetails$inboundSchema = z.object({
    cached_tokens: z.nullable(z.number().int()).optional(),
    cache_creation_tokens: z.nullable(z.number().int()).optional(),
    audio_tokens: z.nullable(z.number().int()).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "cached_tokens": "cachedTokens",
        "cache_creation_tokens": "cacheCreationTokens",
        "audio_tokens": "audioTokens",
    });
});
function createCompletionRouterCompletionsPromptTokensDetailsFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.CreateCompletionRouterCompletionsPromptTokensDetails$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateCompletionRouterCompletionsPromptTokensDetails' from JSON`);
}
/** @internal */
exports.CreateCompletionRouterCompletionsCompletionTokensDetails$inboundSchema = z.object({
    reasoning_tokens: z.nullable(z.number()).optional(),
    accepted_prediction_tokens: z.nullable(z.number()).optional(),
    rejected_prediction_tokens: z.nullable(z.number()).optional(),
    audio_tokens: z.nullable(z.number().int()).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "reasoning_tokens": "reasoningTokens",
        "accepted_prediction_tokens": "acceptedPredictionTokens",
        "rejected_prediction_tokens": "rejectedPredictionTokens",
        "audio_tokens": "audioTokens",
    });
});
function createCompletionRouterCompletionsCompletionTokensDetailsFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.CreateCompletionRouterCompletionsCompletionTokensDetails$inboundSchema
        .parse(JSON.parse(x)), `Failed to parse 'CreateCompletionRouterCompletionsCompletionTokensDetails' from JSON`);
}
/** @internal */
exports.CreateCompletionRouterCompletionsUsage$inboundSchema = z.object({
    completion_tokens: z.number().optional(),
    prompt_tokens: z.number().optional(),
    total_tokens: z.number().optional(),
    prompt_tokens_details: z.nullable(z.lazy(() => exports.CreateCompletionRouterCompletionsPromptTokensDetails$inboundSchema)).optional(),
    completion_tokens_details: z.nullable(z.lazy(() => exports.CreateCompletionRouterCompletionsCompletionTokensDetails$inboundSchema)).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "completion_tokens": "completionTokens",
        "prompt_tokens": "promptTokens",
        "total_tokens": "totalTokens",
        "prompt_tokens_details": "promptTokensDetails",
        "completion_tokens_details": "completionTokensDetails",
    });
});
function createCompletionRouterCompletionsUsageFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.CreateCompletionRouterCompletionsUsage$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateCompletionRouterCompletionsUsage' from JSON`);
}
/** @internal */
exports.CreateCompletionData$inboundSchema = z.object({
    id: z.string(),
    choices: z.array(z.lazy(() => exports.CreateCompletionRouterCompletionsChoices$inboundSchema)),
    created: z.union([z.string(), z.number()]).optional(),
    model: z.string(),
    system_fingerprint: z.string().optional(),
    object: z.string(),
    usage: z.lazy(() => exports.CreateCompletionRouterCompletionsUsage$inboundSchema)
        .optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "system_fingerprint": "systemFingerprint",
    });
});
function createCompletionDataFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.CreateCompletionData$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateCompletionData' from JSON`);
}
/** @internal */
exports.CreateCompletionRouterCompletionsResponseBody$inboundSchema = z.object({
    data: z.string().optional().transform((v, ctx) => {
        if (v === undefined)
            return undefined;
        try {
            return JSON.parse(v);
        }
        catch (err) {
            ctx.addIssue({ code: "custom", message: `malformed json: ${err}` });
            return z.NEVER;
        }
    }).pipe(z.lazy(() => exports.CreateCompletionData$inboundSchema).optional()),
});
function createCompletionRouterCompletionsResponseBodyFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.CreateCompletionRouterCompletionsResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateCompletionRouterCompletionsResponseBody' from JSON`);
}
/** @internal */
exports.CreateCompletionFinishReason$inboundSchema = z.nativeEnum(exports.CreateCompletionFinishReason);
/** @internal */
exports.CreateCompletionChoices$inboundSchema = z.object({
    finish_reason: exports.CreateCompletionFinishReason$inboundSchema,
    index: z.number(),
    text: z.string(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "finish_reason": "finishReason",
    });
});
function createCompletionChoicesFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.CreateCompletionChoices$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateCompletionChoices' from JSON`);
}
/** @internal */
exports.Created$inboundSchema = z.union([z.string(), z.number()]);
function createdFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.Created$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'Created' from JSON`);
}
/** @internal */
exports.CreateCompletionPromptTokensDetails$inboundSchema = z.object({
    cached_tokens: z.nullable(z.number().int()).optional(),
    cache_creation_tokens: z.nullable(z.number().int()).optional(),
    audio_tokens: z.nullable(z.number().int()).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "cached_tokens": "cachedTokens",
        "cache_creation_tokens": "cacheCreationTokens",
        "audio_tokens": "audioTokens",
    });
});
function createCompletionPromptTokensDetailsFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.CreateCompletionPromptTokensDetails$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateCompletionPromptTokensDetails' from JSON`);
}
/** @internal */
exports.CreateCompletionCompletionTokensDetails$inboundSchema = z.object({
    reasoning_tokens: z.nullable(z.number()).optional(),
    accepted_prediction_tokens: z.nullable(z.number()).optional(),
    rejected_prediction_tokens: z.nullable(z.number()).optional(),
    audio_tokens: z.nullable(z.number().int()).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "reasoning_tokens": "reasoningTokens",
        "accepted_prediction_tokens": "acceptedPredictionTokens",
        "rejected_prediction_tokens": "rejectedPredictionTokens",
        "audio_tokens": "audioTokens",
    });
});
function createCompletionCompletionTokensDetailsFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.CreateCompletionCompletionTokensDetails$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateCompletionCompletionTokensDetails' from JSON`);
}
/** @internal */
exports.CreateCompletionUsage$inboundSchema = z.object({
    completion_tokens: z.number().optional(),
    prompt_tokens: z.number().optional(),
    total_tokens: z.number().optional(),
    prompt_tokens_details: z.nullable(z.lazy(() => exports.CreateCompletionPromptTokensDetails$inboundSchema)).optional(),
    completion_tokens_details: z.nullable(z.lazy(() => exports.CreateCompletionCompletionTokensDetails$inboundSchema)).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "completion_tokens": "completionTokens",
        "prompt_tokens": "promptTokens",
        "total_tokens": "totalTokens",
        "prompt_tokens_details": "promptTokensDetails",
        "completion_tokens_details": "completionTokensDetails",
    });
});
function createCompletionUsageFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.CreateCompletionUsage$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateCompletionUsage' from JSON`);
}
/** @internal */
exports.CreateCompletionResponseBody$inboundSchema = z.object({
    id: z.string(),
    choices: z.array(z.lazy(() => exports.CreateCompletionChoices$inboundSchema)),
    created: z.union([z.string(), z.number()]).optional(),
    model: z.string(),
    system_fingerprint: z.string().optional(),
    object: z.string(),
    usage: z.lazy(() => exports.CreateCompletionUsage$inboundSchema).optional(),
}).transform((v) => {
    return (0, primitives_js_1.remap)(v, {
        "system_fingerprint": "systemFingerprint",
    });
});
function createCompletionResponseBodyFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.CreateCompletionResponseBody$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateCompletionResponseBody' from JSON`);
}
/** @internal */
exports.CreateCompletionResponse$inboundSchema = z.union([
    z.lazy(() => exports.CreateCompletionResponseBody$inboundSchema),
    z.instanceof((ReadableStream))
        .transform(stream => {
        return new event_streams_js_1.EventStream(stream, rawEvent => {
            if (rawEvent.data === "[DONE]")
                return { done: true };
            return {
                value: z.lazy(() => exports.CreateCompletionRouterCompletionsResponseBody$inboundSchema).parse(rawEvent),
            };
        });
    }),
]);
function createCompletionResponseFromJSON(jsonString) {
    return (0, schemas_js_1.safeParse)(jsonString, (x) => exports.CreateCompletionResponse$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'CreateCompletionResponse' from JSON`);
}
//# sourceMappingURL=createcompletion.js.map