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

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 ChatCompletionResponse = {
  id: string;
  object: string;
  model: string;
  usage: UsageInfo;
  created: number;
  choices: Array<ChatCompletionChoice>;
};

/** @internal */
export const ChatCompletionResponse$inboundSchema: z.ZodType<
  ChatCompletionResponse,
  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 chatCompletionResponseFromJSON(
  jsonString: string,
): SafeParseResult<ChatCompletionResponse, SDKValidationError> {
  return safeParse(
    jsonString,
    (x) => ChatCompletionResponse$inboundSchema.parse(JSON.parse(x)),
    `Failed to parse 'ChatCompletionResponse' from JSON`,
  );
}
