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

import * as z from "zod/v3";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
import {
  FTModelCapabilitiesOut,
  FTModelCapabilitiesOut$inboundSchema,
} from "./ftmodelcapabilitiesout.js";

export type CompletionFTModelOut = {
  id: string;
  object?: "model" | undefined;
  created: number;
  ownedBy: string;
  workspaceId: string;
  root: string;
  rootVersion: string;
  archived: boolean;
  name?: string | null | undefined;
  description?: string | null | undefined;
  capabilities: FTModelCapabilitiesOut;
  maxContextLength: number | undefined;
  aliases?: Array<string> | undefined;
  job: string;
  modelType?: "completion" | undefined;
};

/** @internal */
export const CompletionFTModelOut$inboundSchema: z.ZodType<
  CompletionFTModelOut,
  z.ZodTypeDef,
  unknown
> = z.object({
  id: z.string(),
  object: z.literal("model").default("model"),
  created: z.number().int(),
  owned_by: z.string(),
  workspace_id: z.string(),
  root: z.string(),
  root_version: z.string(),
  archived: z.boolean(),
  name: z.nullable(z.string()).optional(),
  description: z.nullable(z.string()).optional(),
  capabilities: FTModelCapabilitiesOut$inboundSchema,
  max_context_length: z.number().int().default(32768),
  aliases: z.array(z.string()).optional(),
  job: z.string(),
  model_type: z.literal("completion").default("completion"),
}).transform((v) => {
  return remap$(v, {
    "owned_by": "ownedBy",
    "workspace_id": "workspaceId",
    "root_version": "rootVersion",
    "max_context_length": "maxContextLength",
    "model_type": "modelType",
  });
});

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