/*
 * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
 */

import * as z from "zod/v3";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";

export type EmbeddingResponseData = {
  object?: string | undefined;
  embedding?: Array<number> | undefined;
  index?: number | undefined;
};

/** @internal */
export const EmbeddingResponseData$inboundSchema: z.ZodType<
  EmbeddingResponseData,
  z.ZodTypeDef,
  unknown
> = z.object({
  object: z.string().optional(),
  embedding: z.array(z.number()).optional(),
  index: z.number().int().optional(),
});

export function embeddingResponseDataFromJSON(
  jsonString: string,
): SafeParseResult<EmbeddingResponseData, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => EmbeddingResponseData$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'EmbeddingResponseData' from JSON`,
  );
}
