import { FetchFunction } from '@ai-sdk/provider-utils';
import { LanguageModelV1, LanguageModelV1ObjectGenerationMode, LanguageModelV1CallOptions } from '@ai-sdk/provider';

type DifyChatModelId = string;
/**
 * Settings for the Dify chat API.
 */
interface DifyChatSettings {
    /**
     * Additional inputs to send with the request.
     * This corresponds to the 'inputs' field in Dify's API.
     */
    inputs?: Record<string, any>;
    /**
     * Response mode, defaults to "streaming".
     */
    responseMode?: "streaming" | "blocking";
    /**
     * API key.
     */
    apiKey?: string;
}

interface ModelConfig {
    provider: string;
    baseURL: string;
    headers: () => Record<string, string>;
    fetch?: FetchFunction;
}
interface ExtendedLanguageModelV1CallOptions extends LanguageModelV1CallOptions {
    messages?: Array<{
        role: string;
        content: string | Array<string | {
            type: string;
            [key: string]: any;
        }>;
    }>;
}
declare class DifyChatLanguageModel implements LanguageModelV1 {
    private settings;
    readonly specificationVersion = "v1";
    readonly modelId: string;
    readonly defaultObjectGenerationMode: LanguageModelV1ObjectGenerationMode;
    private readonly generateId;
    private readonly chatMessagesEndpoint;
    private readonly config;
    constructor(modelId: DifyChatModelId, settings: DifyChatSettings, config: ModelConfig);
    get provider(): string;
    doGenerate(options: ExtendedLanguageModelV1CallOptions): Promise<Awaited<ReturnType<LanguageModelV1["doGenerate"]>>>;
    doStream(options: ExtendedLanguageModelV1CallOptions): Promise<Awaited<ReturnType<LanguageModelV1["doStream"]>>>;
    /**
     * Get the request body for the Dify API
     */
    private getRequestBody;
    /**
     * Create the rawCall object for response
     */
    private createRawCall;
    supportsUrl?(url: URL): boolean;
}

interface DifyProvider {
    (modelId: DifyChatModelId, settings?: DifyChatSettings): DifyChatLanguageModel;
    chat(modelId: DifyChatModelId, settings?: DifyChatSettings): DifyChatLanguageModel;
}
interface DifyProviderSettings {
    /**
     * Use a different URL prefix for API calls, e.g. to use self-hosted Dify instance.
     */
    baseURL?: string;
    /**
     * Custom headers to include in the requests.
     */
    headers?: Record<string, string>;
    /**
     * Custom fetch implementation. You can use it as a middleware to intercept requests,
     * or to provide a custom fetch implementation for e.g. testing.
     */
    fetch?: FetchFunction;
}
declare function createDifyProvider(options?: DifyProviderSettings): DifyProvider;
/**
 * Default Dify provider instance.
 */
declare const difyProvider: DifyProvider;

export { type DifyProvider, type DifyProviderSettings, createDifyProvider, difyProvider };
