/* tslint:disable */
/* eslint-disable */
/**
 * Nech.PL Audio Intelligence API
 * Stem-aware audio analysis — emotion, features, sample role, loop grading, onsets/tempo, waveform & spectrogram, loudness, naming. The `audio` API of the Nech.PL APIs platform, served at /audio/v1/...; the gateway does central auth + metering (Bearer token).
 *
 * The version of the OpenAPI document: 0.1.0
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */

import * as runtime from '../runtime';
import {
    type HTTPValidationError,
    HTTPValidationErrorFromJSON,
    HTTPValidationErrorToJSON,
} from '../models/HTTPValidationError';
import {
    type JobStatus,
    JobStatusFromJSON,
    JobStatusToJSON,
} from '../models/JobStatus';

export interface AnalyzeAllRequest {
    file: Blob;
}

export interface AnalyzeEmotionRequest {
    file: Blob;
}

export interface AnalyzeSamplesRequest {
    file: Blob;
    name?: string;
}

export interface CancelJobRequest {
    jobId: string;
}

export interface FeaturesRequest {
    file: Blob;
    rhythm?: boolean;
}

export interface GetJobRequest {
    jobId: string;
}

export interface GradeRequest {
    file: Blob;
    role?: string;
}

export interface LoudnessRequest {
    file: Blob;
}

export interface NamingRequest {
    file: Blob;
    index?: number;
}

export interface OnsetsRequest {
    file: Blob;
}

export interface SpectrumRequest {
    file: Blob;
    bands?: number;
    frames?: number;
    mel?: boolean;
}

export interface WaveformRequest {
    file: Blob;
    bins?: number;
}

/**
 * 
 */
export class AudioApi extends runtime.BaseAPI {

    /**
     * Creates request options for analyzeAll without sending the request
     */
    async analyzeAllRequestOpts(requestParameters: AnalyzeAllRequest): Promise<runtime.RequestOpts> {
        if (requestParameters['file'] == null) {
            throw new runtime.RequiredError(
                'file',
                'Required parameter "file" was null or undefined when calling analyzeAll().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        const consumes: runtime.Consume[] = [
            { contentType: 'multipart/form-data' },
        ];
        // @ts-ignore: canConsumeForm may be unused
        const canConsumeForm = runtime.canConsumeForm(consumes);

        let formParams: { append(param: string, value: any): any };
        let useForm = false;
        // use FormData to transmit files using content-type "multipart/form-data"
        useForm = canConsumeForm;
        if (useForm) {
            formParams = new FormData();
        } else {
            formParams = new URLSearchParams();
        }

        if (requestParameters['file'] != null) {
            formParams.append('file', requestParameters['file'] as any);
        }


        let urlPath = `/analyze`;

        return {
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: formParams,
        };
    }

    /**
     * One call → emotion + features + sample role for a clip (fewer round-trips for hexa). Each is the same engine the dedicated routes use. Cached as a unit.
     * Analyze All
     */
    async analyzeAllRaw(requestParameters: AnalyzeAllRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<any>> {
        const requestOptions = await this.analyzeAllRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        if (this.isJsonMime(response.headers.get('content-type'))) {
            return new runtime.JSONApiResponse<any>(response);
        } else {
            return new runtime.TextApiResponse(response) as any;
        }
    }

    /**
     * One call → emotion + features + sample role for a clip (fewer round-trips for hexa). Each is the same engine the dedicated routes use. Cached as a unit.
     * Analyze All
     */
    async analyzeAll(requestParameters: AnalyzeAllRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<any> {
        const response = await this.analyzeAllRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for analyzeEmotion without sending the request
     */
    async analyzeEmotionRequestOpts(requestParameters: AnalyzeEmotionRequest): Promise<runtime.RequestOpts> {
        if (requestParameters['file'] == null) {
            throw new runtime.RequiredError(
                'file',
                'Required parameter "file" was null or undefined when calling analyzeEmotion().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        const consumes: runtime.Consume[] = [
            { contentType: 'multipart/form-data' },
        ];
        // @ts-ignore: canConsumeForm may be unused
        const canConsumeForm = runtime.canConsumeForm(consumes);

        let formParams: { append(param: string, value: any): any };
        let useForm = false;
        // use FormData to transmit files using content-type "multipart/form-data"
        useForm = canConsumeForm;
        if (useForm) {
            formParams = new FormData();
        } else {
            formParams = new URLSearchParams();
        }

        if (requestParameters['file'] != null) {
            formParams.append('file', requestParameters['file'] as any);
        }


        let urlPath = `/analyze/emotion`;

        return {
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: formParams,
        };
    }

    /**
     * Upload a short audio clip → valence/arousal + top emotions. Cached (#26): the same audio returns instantly on a repeat instead of recomputing.
     * Analyze Emotion
     */
    async analyzeEmotionRaw(requestParameters: AnalyzeEmotionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<any>> {
        const requestOptions = await this.analyzeEmotionRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        if (this.isJsonMime(response.headers.get('content-type'))) {
            return new runtime.JSONApiResponse<any>(response);
        } else {
            return new runtime.TextApiResponse(response) as any;
        }
    }

    /**
     * Upload a short audio clip → valence/arousal + top emotions. Cached (#26): the same audio returns instantly on a repeat instead of recomputing.
     * Analyze Emotion
     */
    async analyzeEmotion(requestParameters: AnalyzeEmotionRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<any> {
        const response = await this.analyzeEmotionRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for analyzeSamples without sending the request
     */
    async analyzeSamplesRequestOpts(requestParameters: AnalyzeSamplesRequest): Promise<runtime.RequestOpts> {
        if (requestParameters['file'] == null) {
            throw new runtime.RequiredError(
                'file',
                'Required parameter "file" was null or undefined when calling analyzeSamples().'
            );
        }

        const queryParameters: any = {};

        if (requestParameters['name'] != null) {
            queryParameters['name'] = requestParameters['name'];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        const consumes: runtime.Consume[] = [
            { contentType: 'multipart/form-data' },
        ];
        // @ts-ignore: canConsumeForm may be unused
        const canConsumeForm = runtime.canConsumeForm(consumes);

        let formParams: { append(param: string, value: any): any };
        let useForm = false;
        // use FormData to transmit files using content-type "multipart/form-data"
        useForm = canConsumeForm;
        if (useForm) {
            formParams = new FormData();
        } else {
            formParams = new URLSearchParams();
        }

        if (requestParameters['file'] != null) {
            formParams.append('file', requestParameters['file'] as any);
        }


        let urlPath = `/analyze/samples`;

        return {
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: formParams,
        };
    }

    /**
     * Upload a one-shot/loop → per-sample EDA + MEASURED role (percs|bass|melodic| tops|atmos) from the spectrum, never the name. Optional `name` only disambiguates breaks/drums. Torch-free, cached.
     * Analyze Samples
     */
    async analyzeSamplesRaw(requestParameters: AnalyzeSamplesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<any>> {
        const requestOptions = await this.analyzeSamplesRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        if (this.isJsonMime(response.headers.get('content-type'))) {
            return new runtime.JSONApiResponse<any>(response);
        } else {
            return new runtime.TextApiResponse(response) as any;
        }
    }

    /**
     * Upload a one-shot/loop → per-sample EDA + MEASURED role (percs|bass|melodic| tops|atmos) from the spectrum, never the name. Optional `name` only disambiguates breaks/drums. Torch-free, cached.
     * Analyze Samples
     */
    async analyzeSamples(requestParameters: AnalyzeSamplesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<any> {
        const response = await this.analyzeSamplesRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for cancelJob without sending the request
     */
    async cancelJobRequestOpts(requestParameters: CancelJobRequest): Promise<runtime.RequestOpts> {
        if (requestParameters['jobId'] == null) {
            throw new runtime.RequiredError(
                'jobId',
                'Required parameter "jobId" was null or undefined when calling cancelJob().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};


        let urlPath = `/jobs/{job_id}`;
        urlPath = urlPath.replace('{job_id}', encodeURIComponent(String(requestParameters['jobId'])));

        return {
            path: urlPath,
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Cancel a pending/running job (cooperative — a running handler stops at its next progress checkpoint). Idempotent: cancelling a finished job is a no-op.
     * Cancel Job
     */
    async cancelJobRaw(requestParameters: CancelJobRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<JobStatus>> {
        const requestOptions = await this.cancelJobRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => JobStatusFromJSON(jsonValue));
    }

    /**
     * Cancel a pending/running job (cooperative — a running handler stops at its next progress checkpoint). Idempotent: cancelling a finished job is a no-op.
     * Cancel Job
     */
    async cancelJob(requestParameters: CancelJobRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<JobStatus> {
        const response = await this.cancelJobRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for features without sending the request
     */
    async featuresRequestOpts(requestParameters: FeaturesRequest): Promise<runtime.RequestOpts> {
        if (requestParameters['file'] == null) {
            throw new runtime.RequiredError(
                'file',
                'Required parameter "file" was null or undefined when calling features().'
            );
        }

        const queryParameters: any = {};

        if (requestParameters['rhythm'] != null) {
            queryParameters['rhythm'] = requestParameters['rhythm'];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        const consumes: runtime.Consume[] = [
            { contentType: 'multipart/form-data' },
        ];
        // @ts-ignore: canConsumeForm may be unused
        const canConsumeForm = runtime.canConsumeForm(consumes);

        let formParams: { append(param: string, value: any): any };
        let useForm = false;
        // use FormData to transmit files using content-type "multipart/form-data"
        useForm = canConsumeForm;
        if (useForm) {
            formParams = new FormData();
        } else {
            formParams = new URLSearchParams();
        }

        if (requestParameters['file'] != null) {
            formParams.append('file', requestParameters['file'] as any);
        }


        let urlPath = `/features`;

        return {
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: formParams,
        };
    }

    /**
     * Upload a clip → the ~35-dim audio feature stack (spectral moments, MFCCs, chroma/key, envelope, + rhythm when `rhythm=true`). Torch-free, cached.
     * Features
     */
    async featuresRaw(requestParameters: FeaturesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<any>> {
        const requestOptions = await this.featuresRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        if (this.isJsonMime(response.headers.get('content-type'))) {
            return new runtime.JSONApiResponse<any>(response);
        } else {
            return new runtime.TextApiResponse(response) as any;
        }
    }

    /**
     * Upload a clip → the ~35-dim audio feature stack (spectral moments, MFCCs, chroma/key, envelope, + rhythm when `rhythm=true`). Torch-free, cached.
     * Features
     */
    async features(requestParameters: FeaturesRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<any> {
        const response = await this.featuresRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for getJob without sending the request
     */
    async getJobRequestOpts(requestParameters: GetJobRequest): Promise<runtime.RequestOpts> {
        if (requestParameters['jobId'] == null) {
            throw new runtime.RequiredError(
                'jobId',
                'Required parameter "jobId" was null or undefined when calling getJob().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};


        let urlPath = `/jobs/{job_id}`;
        urlPath = urlPath.replace('{job_id}', encodeURIComponent(String(requestParameters['jobId'])));

        return {
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Poll an async job. 404 if it doesn\'t exist OR belongs to another tenant (we don\'t leak job existence across accounts).
     * Get Job
     */
    async getJobRaw(requestParameters: GetJobRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<JobStatus>> {
        const requestOptions = await this.getJobRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => JobStatusFromJSON(jsonValue));
    }

    /**
     * Poll an async job. 404 if it doesn\'t exist OR belongs to another tenant (we don\'t leak job existence across accounts).
     * Get Job
     */
    async getJob(requestParameters: GetJobRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<JobStatus> {
        const response = await this.getJobRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for grade without sending the request
     */
    async gradeRequestOpts(requestParameters: GradeRequest): Promise<runtime.RequestOpts> {
        if (requestParameters['file'] == null) {
            throw new runtime.RequiredError(
                'file',
                'Required parameter "file" was null or undefined when calling grade().'
            );
        }

        const queryParameters: any = {};

        if (requestParameters['role'] != null) {
            queryParameters['role'] = requestParameters['role'];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        const consumes: runtime.Consume[] = [
            { contentType: 'multipart/form-data' },
        ];
        // @ts-ignore: canConsumeForm may be unused
        const canConsumeForm = runtime.canConsumeForm(consumes);

        let formParams: { append(param: string, value: any): any };
        let useForm = false;
        // use FormData to transmit files using content-type "multipart/form-data"
        useForm = canConsumeForm;
        if (useForm) {
            formParams = new FormData();
        } else {
            formParams = new URLSearchParams();
        }

        if (requestParameters['file'] != null) {
            formParams.append('file', requestParameters['file'] as any);
        }


        let urlPath = `/grade`;

        return {
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: formParams,
        };
    }

    /**
     * Upload a loop/one-shot → the Foundry\'s MECHANICAL quality grade: composite 0..1 + S/A/B/C/D tier, per-rule sub-scores (seam click, zero-crossing cleanliness, DC, bar self-consistency, level, bass mono-compat) + flags. `role` (\'bass\'|\'drums\'|…) is a hint. WAV/FLAC preferred. Torch-free, cached.
     * Grade
     */
    async gradeRaw(requestParameters: GradeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<any>> {
        const requestOptions = await this.gradeRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        if (this.isJsonMime(response.headers.get('content-type'))) {
            return new runtime.JSONApiResponse<any>(response);
        } else {
            return new runtime.TextApiResponse(response) as any;
        }
    }

    /**
     * Upload a loop/one-shot → the Foundry\'s MECHANICAL quality grade: composite 0..1 + S/A/B/C/D tier, per-rule sub-scores (seam click, zero-crossing cleanliness, DC, bar self-consistency, level, bass mono-compat) + flags. `role` (\'bass\'|\'drums\'|…) is a hint. WAV/FLAC preferred. Torch-free, cached.
     * Grade
     */
    async grade(requestParameters: GradeRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<any> {
        const response = await this.gradeRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for healthz without sending the request
     */
    async healthzRequestOpts(): Promise<runtime.RequestOpts> {
        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};


        let urlPath = `/healthz`;

        return {
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Healthz
     */
    async healthzRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<any>> {
        const requestOptions = await this.healthzRequestOpts();
        const response = await this.request(requestOptions, initOverrides);

        if (this.isJsonMime(response.headers.get('content-type'))) {
            return new runtime.JSONApiResponse<any>(response);
        } else {
            return new runtime.TextApiResponse(response) as any;
        }
    }

    /**
     * Healthz
     */
    async healthz(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<any> {
        const response = await this.healthzRaw(initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for loudness without sending the request
     */
    async loudnessRequestOpts(requestParameters: LoudnessRequest): Promise<runtime.RequestOpts> {
        if (requestParameters['file'] == null) {
            throw new runtime.RequiredError(
                'file',
                'Required parameter "file" was null or undefined when calling loudness().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        const consumes: runtime.Consume[] = [
            { contentType: 'multipart/form-data' },
        ];
        // @ts-ignore: canConsumeForm may be unused
        const canConsumeForm = runtime.canConsumeForm(consumes);

        let formParams: { append(param: string, value: any): any };
        let useForm = false;
        // use FormData to transmit files using content-type "multipart/form-data"
        useForm = canConsumeForm;
        if (useForm) {
            formParams = new FormData();
        } else {
            formParams = new URLSearchParams();
        }

        if (requestParameters['file'] != null) {
            formParams.append('file', requestParameters['file'] as any);
        }


        let urlPath = `/loudness`;

        return {
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: formParams,
        };
    }

    /**
     * Upload audio → BS.1770 integrated LUFS + sample/true peak + crest + the gain (dB) to hit each delivery target (-14 streaming, -9 club). Torch-free, cached.
     * Loudness
     */
    async loudnessRaw(requestParameters: LoudnessRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<any>> {
        const requestOptions = await this.loudnessRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        if (this.isJsonMime(response.headers.get('content-type'))) {
            return new runtime.JSONApiResponse<any>(response);
        } else {
            return new runtime.TextApiResponse(response) as any;
        }
    }

    /**
     * Upload audio → BS.1770 integrated LUFS + sample/true peak + crest + the gain (dB) to hit each delivery target (-14 streaming, -9 club). Torch-free, cached.
     * Loudness
     */
    async loudness(requestParameters: LoudnessRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<any> {
        const response = await this.loudnessRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for naming without sending the request
     */
    async namingRequestOpts(requestParameters: NamingRequest): Promise<runtime.RequestOpts> {
        if (requestParameters['file'] == null) {
            throw new runtime.RequiredError(
                'file',
                'Required parameter "file" was null or undefined when calling naming().'
            );
        }

        const queryParameters: any = {};

        if (requestParameters['index'] != null) {
            queryParameters['index'] = requestParameters['index'];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        const consumes: runtime.Consume[] = [
            { contentType: 'multipart/form-data' },
        ];
        // @ts-ignore: canConsumeForm may be unused
        const canConsumeForm = runtime.canConsumeForm(consumes);

        let formParams: { append(param: string, value: any): any };
        let useForm = false;
        // use FormData to transmit files using content-type "multipart/form-data"
        useForm = canConsumeForm;
        if (useForm) {
            formParams = new FormData();
        } else {
            formParams = new URLSearchParams();
        }

        if (requestParameters['file'] != null) {
            formParams.append('file', requestParameters['file'] as any);
        }


        let urlPath = `/naming`;

        return {
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: formParams,
        };
    }

    /**
     * Upload a sample → a convention-compliant name (NN_role_character) derived from the MEASURED role + character, not the file name. Torch-free, cached.
     * Naming
     */
    async namingRaw(requestParameters: NamingRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<any>> {
        const requestOptions = await this.namingRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        if (this.isJsonMime(response.headers.get('content-type'))) {
            return new runtime.JSONApiResponse<any>(response);
        } else {
            return new runtime.TextApiResponse(response) as any;
        }
    }

    /**
     * Upload a sample → a convention-compliant name (NN_role_character) derived from the MEASURED role + character, not the file name. Torch-free, cached.
     * Naming
     */
    async naming(requestParameters: NamingRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<any> {
        const response = await this.namingRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for onsets without sending the request
     */
    async onsetsRequestOpts(requestParameters: OnsetsRequest): Promise<runtime.RequestOpts> {
        if (requestParameters['file'] == null) {
            throw new runtime.RequiredError(
                'file',
                'Required parameter "file" was null or undefined when calling onsets().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        const consumes: runtime.Consume[] = [
            { contentType: 'multipart/form-data' },
        ];
        // @ts-ignore: canConsumeForm may be unused
        const canConsumeForm = runtime.canConsumeForm(consumes);

        let formParams: { append(param: string, value: any): any };
        let useForm = false;
        // use FormData to transmit files using content-type "multipart/form-data"
        useForm = canConsumeForm;
        if (useForm) {
            formParams = new FormData();
        } else {
            formParams = new URLSearchParams();
        }

        if (requestParameters['file'] != null) {
            formParams.append('file', requestParameters['file'] as any);
        }


        let urlPath = `/onsets`;

        return {
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: formParams,
        };
    }

    /**
     * Upload audio → onset hit times (s) + tempo + onset rate. The cheapest tier (no model): rhythmic hits for visual sync / slicing. Torch-free, cached.
     * Onsets
     */
    async onsetsRaw(requestParameters: OnsetsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<any>> {
        const requestOptions = await this.onsetsRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        if (this.isJsonMime(response.headers.get('content-type'))) {
            return new runtime.JSONApiResponse<any>(response);
        } else {
            return new runtime.TextApiResponse(response) as any;
        }
    }

    /**
     * Upload audio → onset hit times (s) + tempo + onset rate. The cheapest tier (no model): rhythmic hits for visual sync / slicing. Torch-free, cached.
     * Onsets
     */
    async onsets(requestParameters: OnsetsRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<any> {
        const response = await this.onsetsRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for separate without sending the request
     */
    async separateRequestOpts(): Promise<runtime.RequestOpts> {
        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};


        let urlPath = `/separate`;

        return {
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Stem separation (demucs/roformer). erable has no GPU and no CPU-viable path, so this is a deliberate 503 until a GPU-runner backend is wired (env-selected, same response shape). The route exists now so hexa can code against it and get a clean, documented \"compute pending\" rather than a 404.
     * Separate
     */
    async separateRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<any>> {
        const requestOptions = await this.separateRequestOpts();
        const response = await this.request(requestOptions, initOverrides);

        if (this.isJsonMime(response.headers.get('content-type'))) {
            return new runtime.JSONApiResponse<any>(response);
        } else {
            return new runtime.TextApiResponse(response) as any;
        }
    }

    /**
     * Stem separation (demucs/roformer). erable has no GPU and no CPU-viable path, so this is a deliberate 503 until a GPU-runner backend is wired (env-selected, same response shape). The route exists now so hexa can code against it and get a clean, documented \"compute pending\" rather than a 404.
     * Separate
     */
    async separate(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<any> {
        const response = await this.separateRaw(initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for spectrum without sending the request
     */
    async spectrumRequestOpts(requestParameters: SpectrumRequest): Promise<runtime.RequestOpts> {
        if (requestParameters['file'] == null) {
            throw new runtime.RequiredError(
                'file',
                'Required parameter "file" was null or undefined when calling spectrum().'
            );
        }

        const queryParameters: any = {};

        if (requestParameters['bands'] != null) {
            queryParameters['bands'] = requestParameters['bands'];
        }

        if (requestParameters['frames'] != null) {
            queryParameters['frames'] = requestParameters['frames'];
        }

        if (requestParameters['mel'] != null) {
            queryParameters['mel'] = requestParameters['mel'];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        const consumes: runtime.Consume[] = [
            { contentType: 'multipart/form-data' },
        ];
        // @ts-ignore: canConsumeForm may be unused
        const canConsumeForm = runtime.canConsumeForm(consumes);

        let formParams: { append(param: string, value: any): any };
        let useForm = false;
        // use FormData to transmit files using content-type "multipart/form-data"
        useForm = canConsumeForm;
        if (useForm) {
            formParams = new FormData();
        } else {
            formParams = new URLSearchParams();
        }

        if (requestParameters['file'] != null) {
            formParams.append('file', requestParameters['file'] as any);
        }


        let urlPath = `/spectrum`;

        return {
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: formParams,
        };
    }

    /**
     * FFT-as-a-service: a downsampled, render-ready spectrogram (`bands`×`frames`, 0..1). `mel=` perceptual vs log-linear; `frames=1` → a single averaged FFT spectrum. Bounded payload → caches cheaply. Torch-free.
     * Spectrum
     */
    async spectrumRaw(requestParameters: SpectrumRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<any>> {
        const requestOptions = await this.spectrumRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        if (this.isJsonMime(response.headers.get('content-type'))) {
            return new runtime.JSONApiResponse<any>(response);
        } else {
            return new runtime.TextApiResponse(response) as any;
        }
    }

    /**
     * FFT-as-a-service: a downsampled, render-ready spectrogram (`bands`×`frames`, 0..1). `mel=` perceptual vs log-linear; `frames=1` → a single averaged FFT spectrum. Bounded payload → caches cheaply. Torch-free.
     * Spectrum
     */
    async spectrum(requestParameters: SpectrumRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<any> {
        const response = await this.spectrumRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for waveform without sending the request
     */
    async waveformRequestOpts(requestParameters: WaveformRequest): Promise<runtime.RequestOpts> {
        if (requestParameters['file'] == null) {
            throw new runtime.RequiredError(
                'file',
                'Required parameter "file" was null or undefined when calling waveform().'
            );
        }

        const queryParameters: any = {};

        if (requestParameters['bins'] != null) {
            queryParameters['bins'] = requestParameters['bins'];
        }

        const headerParameters: runtime.HTTPHeaders = {};

        const consumes: runtime.Consume[] = [
            { contentType: 'multipart/form-data' },
        ];
        // @ts-ignore: canConsumeForm may be unused
        const canConsumeForm = runtime.canConsumeForm(consumes);

        let formParams: { append(param: string, value: any): any };
        let useForm = false;
        // use FormData to transmit files using content-type "multipart/form-data"
        useForm = canConsumeForm;
        if (useForm) {
            formParams = new FormData();
        } else {
            formParams = new URLSearchParams();
        }

        if (requestParameters['file'] != null) {
            formParams.append('file', requestParameters['file'] as any);
        }


        let urlPath = `/waveform`;

        return {
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: formParams,
        };
    }

    /**
     * Upload audio → render-ready waveform: per-bin [min,max] + a 0..1 RMS energy envelope (`?bins=`, ≤4000). For audio-reactive visuals. Torch-free, cached.
     * Waveform
     */
    async waveformRaw(requestParameters: WaveformRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<any>> {
        const requestOptions = await this.waveformRequestOpts(requestParameters);
        const response = await this.request(requestOptions, initOverrides);

        if (this.isJsonMime(response.headers.get('content-type'))) {
            return new runtime.JSONApiResponse<any>(response);
        } else {
            return new runtime.TextApiResponse(response) as any;
        }
    }

    /**
     * Upload audio → render-ready waveform: per-bin [min,max] + a 0..1 RMS energy envelope (`?bins=`, ≤4000). For audio-reactive visuals. Torch-free, cached.
     * Waveform
     */
    async waveform(requestParameters: WaveformRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<any> {
        const response = await this.waveformRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * Creates request options for whoami without sending the request
     */
    async whoamiRequestOpts(): Promise<runtime.RequestOpts> {
        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};


        let urlPath = `/me`;

        return {
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        };
    }

    /**
     * Echo the caller\'s gateway-resolved identity — handy for onboarding smoke tests.
     * Whoami
     */
    async whoamiRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<any>> {
        const requestOptions = await this.whoamiRequestOpts();
        const response = await this.request(requestOptions, initOverrides);

        if (this.isJsonMime(response.headers.get('content-type'))) {
            return new runtime.JSONApiResponse<any>(response);
        } else {
            return new runtime.TextApiResponse(response) as any;
        }
    }

    /**
     * Echo the caller\'s gateway-resolved identity — handy for onboarding smoke tests.
     * Whoami
     */
    async whoami(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<any> {
        const response = await this.whoamiRaw(initOverrides);
        return await response.value();
    }

}
