/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 * @generated-id: 1f5a1e8c8aa9
 */

import * as z from "zod/v4";
import { remap as remap$ } from "../../lib/primitives.js";
import { smartUnion } from "../../types/smartUnion.js";
import {
  EmbeddingDtype,
  EmbeddingDtype$outboundSchema,
} from "./embeddingdtype.js";
import {
  EncodingFormat,
  EncodingFormat$outboundSchema,
} from "./encodingformat.js";

/**
 * Text to embed.
 */
export type EmbeddingRequestInputs = string | Array<string>;

export type EmbeddingRequest = {
  /**
   * ID of the model to use.
   */
  model: string;
  metadata?: { [k: string]: any } | null | undefined;
  /**
   * Text to embed.
   */
  inputs: string | Array<string>;
  /**
   * The dimension of the output embeddings when feature available. If not provided, a default output dimension will be used.
   */
  outputDimension?: number | null | undefined;
  outputDtype?: EmbeddingDtype | undefined;
  encodingFormat?: EncodingFormat | undefined;
};

/** @internal */
export type EmbeddingRequestInputs$Outbound = string | Array<string>;

/** @internal */
export const EmbeddingRequestInputs$outboundSchema: z.ZodType<
  EmbeddingRequestInputs$Outbound,
  EmbeddingRequestInputs
> = smartUnion([z.string(), z.array(z.string())]);

export function embeddingRequestInputsToJSON(
  embeddingRequestInputs: EmbeddingRequestInputs,
): string {
  return JSON.stringify(
    EmbeddingRequestInputs$outboundSchema.parse(embeddingRequestInputs),
  );
}

/** @internal */
export type EmbeddingRequest$Outbound = {
  model: string;
  metadata?: { [k: string]: any } | null | undefined;
  input: string | Array<string>;
  output_dimension?: number | null | undefined;
  output_dtype?: string | undefined;
  encoding_format?: string | undefined;
};

/** @internal */
export const EmbeddingRequest$outboundSchema: z.ZodType<
  EmbeddingRequest$Outbound,
  EmbeddingRequest
> = z.object({
  model: z.string(),
  metadata: z.nullable(z.record(z.string(), z.any())).optional(),
  inputs: smartUnion([z.string(), z.array(z.string())]),
  outputDimension: z.nullable(z.int()).optional(),
  outputDtype: EmbeddingDtype$outboundSchema.optional(),
  encodingFormat: EncodingFormat$outboundSchema.optional(),
}).transform((v) => {
  return remap$(v, {
    inputs: "input",
    outputDimension: "output_dimension",
    outputDtype: "output_dtype",
    encodingFormat: "encoding_format",
  });
});

export function embeddingRequestToJSON(
  embeddingRequest: EmbeddingRequest,
): string {
  return JSON.stringify(
    EmbeddingRequest$outboundSchema.parse(embeddingRequest),
  );
}
