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

import * as z from "zod/v4";
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 {
  FineTunedModelCapabilities,
  FineTunedModelCapabilities$inboundSchema,
} from "./finetunedmodelcapabilities.js";

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

/** @internal */
export const CompletionFineTunedModel$inboundSchema: z.ZodType<
  CompletionFineTunedModel,
  unknown
> = z.object({
  id: z.string(),
  object: z.literal("model").default("model"),
  created: z.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: FineTunedModelCapabilities$inboundSchema,
  max_context_length: z.int().default(32768),
  aliases: z.array(z.string()).optional(),
  job: z.nullable(z.string()).optional(),
  model_type: z.literal("completion"),
}).transform((v) => {
  return remap$(v, {
    "owned_by": "ownedBy",
    "workspace_id": "workspaceId",
    "root_version": "rootVersion",
    "max_context_length": "maxContextLength",
    "model_type": "modelType",
  });
});

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