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

import * as z from "zod/v4";
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,
  unknown
> = z.object({
  id: z.string(),
  object: z.string(),
  model: z.string(),
  usage: UsageInfo$inboundSchema,
  created: z.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`,
  );
}
