/*
 * 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";
import {
  ChatCompletionChoice,
  ChatCompletionChoice$inboundSchema,
} from "./chatcompletionchoice.js";
import { UsageInfo, UsageInfo$inboundSchema } from "./usageinfo.js";

export type FIMCompletionResponse = {
  id: string;
  object: string;
  model: string;
  usage: UsageInfo;
  created: number;
  choices: Array<ChatCompletionChoice>;
};

/** @internal */
export const FIMCompletionResponse$inboundSchema: z.ZodType<
  FIMCompletionResponse,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: z.string(),
  object: z.string(),
  model: z.string(),
  usage: UsageInfo$inboundSchema,
  created: z.number().int(),
  choices: z.array(ChatCompletionChoice$inboundSchema),
});

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