import { ChatCompletionCreateParams, ChatCompletionMessageToolCall, ChatCompletionMessage, ChatCompletionTool } from 'openai/resources';

type Role = "system" | "user" | "assistant" | "tool" | "function" | "human";
type FunctionDef = ChatCompletionCreateParams.Function;
interface TextContent {
    type: "text";
    text: string;
}
interface ImageContent {
    type: "image_url";
    image_url: {
        url: string;
    };
}
interface Message {
    role: Role;
    content: string | Array<TextContent | ImageContent>;
    tool_calls?: ChatCompletionMessageToolCall[];
    name?: string;
    tool?: string | ChatCompletionMessageToolCall;
    tool_call_id?: string;
    function_call?: string | ChatCompletionMessage.FunctionCall;
}
type RequestBody = {
    messages: Message[];
    model: string;
    frequency_penalty?: number | null;
    logit_bias?: {
        [tokenId: number]: number;
    } | null;
    max_tokens?: number | null;
    n?: number | null;
    presence_penalty?: number | null;
    response_providerFormat?: {
        type: string;
    } | null;
    seed?: number | null;
    stop?: string | string[] | null;
    stream?: boolean | null;
    temperature?: number | null;
    top_p?: number | null;
    tools?: Array<ChatCompletionTool>;
    response_format?: {
        type: "json_object";
    };
    tool_choice?: "auto" | "none" | {
        type: "function";
        function: {
            name: string;
        };
    };
    user?: string | null;
    logprobs?: any | null;
};
type ProviderFormat = "openai" | "anthropic" | "google" | "cohere";
type ModelType = "chat" | "multi" | "completion" | "embedding" | "other";
type ModelProvider = "openai" | "anthropic" | "perplexity" | "replicate" | "azure" | "mistral" | "groq" | "google" | "gcp_vertex" | "cohere" | "cloudflare" | "ai21" | "together" | "custom-deployment" | "bedrock";
type ModelDetails = {
    format: ProviderFormat;
    type: ModelType;
    inputCost?: number;
    outputCost?: number;
};
declare const ProviderBase: {
    [key: string]: string;
};
declare const AvailableModels: {
    [name: string]: ModelDetails;
};
declare const ModelProviderMap: {
    [name: string]: string;
};
interface ProviderResponse {
    stream: ReadableStream<Uint8Array> | null;
    response: Response;
}
type KluConfig = {
    fallback: {
        model: string;
        key: string;
    }[];
    retries: number;
};

interface EnvironmentContext {
    waitUntil(promise: Promise<any>): void;
}
declare function EdgeOpenAIProxyV1(): (request: Request, env: any, ctx: EnvironmentContext) => Promise<Response>;

declare function OpenAI(url: string, headers: Record<string, string>, body: string, setHeader: (name: string, value: string) => void, setStatus: (code: number) => void, res: WritableStream<Uint8Array>, ctx: EnvironmentContext, env: any): Promise<Response | undefined>;

declare function getCompletionFromStream(stream: string): {
    raw_ouput: string;
    completion: string;
    raw_output?: undefined;
} | {
    raw_output: string;
    completion: string;
    raw_ouput?: undefined;
};
declare function logToKlu(body: RequestBody, kluApiKey: string, output: any, stream: boolean | undefined, actionGuid: string | undefined, dataGuid: string | undefined): Promise<void>;
declare function getProvider(model: string, url: string, headers: Record<string, string>): ModelProvider;
declare function getBaseURL(provider: string, headers: Record<string, string>): string;
declare function flattenChunks(allChunks: Uint8Array[]): string;
interface AIStreamParser {
    (data: string): {
        data: string | null;
        finished: boolean;
    };
}
declare function createEventStreamTransformer(customParser: AIStreamParser): TransformStream<Uint8Array, Uint8Array>;
declare function getMimeType(base64: string): string;
declare function returnProviderKey(provider: string, env: any): any;

export { AvailableModels, EdgeOpenAIProxyV1, type EnvironmentContext, type FunctionDef, type ImageContent, type KluConfig, type Message, type ModelDetails, type ModelProvider, ModelProviderMap, type ModelType, OpenAI, ProviderBase, type ProviderFormat, type ProviderResponse, type RequestBody, type Role, type TextContent, createEventStreamTransformer, flattenChunks, getBaseURL, getCompletionFromStream, getMimeType, getProvider, logToKlu, returnProviderKey };
