declare namespace HuggingFaceTextGenerationTypes {
    type Request = {
        model: string;
        inputs: string;
        parameters?: {
            top_k?: number;
            top_p?: number;
            temperature?: number;
            repetition_penalty?: number;
            max_new_tokens?: number;
            max_time?: number;
            return_full_text?: boolean;
            num_return_sequences?: number;
            do_sample?: boolean;
        };
        options?: {
            use_cache?: boolean;
            wait_for_model?: boolean;
        };
    };
    type RequestOptions = {
        apiKey?: string;
        apiUrl?: string;
        fetch?: typeof fetch;
        headers?: Record<string, string>;
        signal?: AbortSignal;
    };
    type GeneratedText = {
        generated_text: string;
    };
    type Response = GeneratedText | GeneratedText[];
    type Chunk = {
        token: {
            id: number;
            text: string;
            logprob: number;
            special: boolean;
        };
        generated_text: string;
        details?: {
            finishReason: string;
            generated_tokens: number;
            seed?: number;
        };
    };
}
/**
 * Run a textGeneration task against the HF inference API
 *
 * @see https://huggingface.co/docs/api-inference/detailed_parameters#text-generation-task
 *
 * @param request The request body sent to HF. See their documentation linked above for details
 * @param options
 * @param options.apiKey The HuggingFace access token. If not provided, requests will be throttled
 * @param options.apiUrl The HuggingFace API URL. Defaults to https://api-inference.huggingface.co/models/
 * @param options.fetch The fetch implementation to use. Defaults to globalThis.fetch
 * @param options.headers Optionally add additional HTTP headers to the request.
 * @param options.signal An AbortSignal that can be used to abort the fetch request.
 * @returns The response body from HF. See their documentation linked above for details
 */
declare function run(request: HuggingFaceTextGenerationTypes.Request, options: HuggingFaceTextGenerationTypes.RequestOptions): Promise<HuggingFaceTextGenerationTypes.Response>;
/**
 * Stream a textGeneration task against the HF inference API. The resulting stream is the raw unmodified bytes from the API
 *
 * @see https://huggingface.co/docs/api-inference/detailed_parameters#text-generation-task
 *
 * @param request The request body sent to HF. See their documentation linked above for details
 * @param options
 * @param options.apiKey The HuggingFace access token. If not provided, requests will be throttled
 * @param options.apiUrl The HuggingFace API URL. Defaults to https://api-inference.huggingface.co/models/
 * @param options.fetch The fetch implementation to use. Defaults to globalThis.fetch
 * @param options.headers Optionally add additional HTTP headers to the request.
 * @param options.signal An AbortSignal that can be used to abort the fetch request.
 * @returns A stream of bytes directly from the API.
 */
declare function streamBytes(request: HuggingFaceTextGenerationTypes.Request, options: HuggingFaceTextGenerationTypes.RequestOptions): Promise<ReadableStream<Uint8Array>>;
/**
 * Stream a textGeneration task against the HF inference API. The resulting stream is the parsed stream data as JavaScript objects.
 * Example chunk:
 *   {
 *     token: { id: 11, text: ' and', logprob: -0.00002193451, special: false },
 *     generated_text: null,
 *     details: null
 *   }
 *
 * @see https://huggingface.co/docs/api-inference/detailed_parameters#text-generation-task
 *
 * @param request The request body sent to HF. See their documentation linked above for details
 * @param options
 * @param options.apiKey The HuggingFace access token. If not provided, requests will be throttled
 * @param options.apiUrl The HuggingFace API URL. Defaults to https://api-inference.huggingface.co/models/
 * @param options.fetch The fetch implementation to use. Defaults to globalThis.fetch
 * @param options.headers Optionally add additional HTTP headers to the request.
 * @param options.signal An AbortSignal that can be used to abort the fetch request.
 * @returns A stream of objects representing each chunk from the API
 */
declare function stream(request: HuggingFaceTextGenerationTypes.Request, options: HuggingFaceTextGenerationTypes.RequestOptions): Promise<ReadableStream<HuggingFaceTextGenerationTypes.Chunk>>;
/**
 * Run a streaming completion against the HF inference API. The resulting stream emits only the string tokens.
 * Note that this will strip the STOP token '</s>' from the text.
 *
 * @see https://huggingface.co/docs/api-inference/detailed_parameters#text-generation-task
 *
 * @param request The request body sent to HF. See their documentation linked above for details
 * @param options
 * @param options.apiKey The HuggingFace access token. If not provided, requests will be throttled
 * @param options.apiUrl The HuggingFace API URL. Defaults to https://api-inference.huggingface.co/models/
 * @param options.fetch The fetch implementation to use. Defaults to globalThis.fetch
 * @param options.headers Optionally add additional HTTP headers to the request.
 * @param options.signal An AbortSignal that can be used to abort the fetch request.
 * @returns A stream of tokens from the API.
 */
declare function streamTokens(request: HuggingFaceTextGenerationTypes.Request, options: HuggingFaceTextGenerationTypes.RequestOptions): Promise<ReadableStream<string>>;
/**
 * An object that encapsulates methods for calling the HF inference API
 */
declare class HuggingFaceTextGeneration {
    static run: typeof run;
    static streamBytes: typeof streamBytes;
    static stream: typeof stream;
    static streamTokens: typeof streamTokens;
}

export { HuggingFaceTextGeneration, HuggingFaceTextGenerationTypes };
