import { ProviderV1, EmbeddingModelV1 } from '@ai-sdk/provider';
import { FetchFunction } from '@ai-sdk/provider-utils';

type JinaEmbeddingModelId = 'jina-embeddings-v3' | 'jina-embeddings-v2-base-en' | 'jina-embeddings-v2-base-code' | 'jina-clip-v2' | 'jina-clip-v1' | (string & {});
interface JinaEmbeddingSettings {
    /**
     * The input type for the embeddings.
     *
     * Defaults to `retrieval.passage`.
     *
     * Used to convey intended downstream application to help the model produce better embeddings.
     *
     * Must be one of the following values:
     * - `retrieval.query`: Specifies the given text is a query in a search or retrieval setting.
     * - `retrieval.passage`: Specifies the given text is a document in a search or retrieval setting.
     * - `text-matching`: Specifies the given text is used for Semantic Textual Similarity.
     * - `classification`: Specifies that the embedding is used for classification.
     * - `separation`: Specifies that the embedding is used for clustering.
     */
    inputType?: 'text-matching' | 'retrieval.query' | 'retrieval.passage' | 'separation' | 'classification' | undefined;
    /**
     * The number of dimensions for the resulting output embeddings.
     *
     * - `jina-embeddings-v3`:
     *   - Min Output Dimensions: 32 for better performance
     *   - Max Output Dimensions: 1,024
     *
     * - `jina-clip-v2`:
     *   - Min Output Dimensions: 64
     *   - Max Output Dimensions: 1,024
     *
     * - `jina-clip-v1`:
     *   - Output Dimensions: 768
     *
     * Please refer to the model documentation for the supported values.
     *
     * @see https://jina.ai/api-dashboard/embedding
     */
    outputDimension?: number;
    /**
     * Late chunking
     *
     * When enabled, the model will automatically split the input into chunks of 1024 tokens each.
     *
     * @see https://jina.ai/news/jina-embeddings-v3-a-frontier-multilingual-embedding-model/#parameter-latechunking
     *
     * Defaults to false.
     *
     * This is only supported in text embedding models.
     */
    lateChunking?: boolean;
    /**
     * The data type for the resulting output embeddings.
     *
     * Defaults to `float`.
     *
     * - `float`: 32-bit floating-point numbers
     * - `binary`: 8-bit binary values
     * - `ubinary`: 8-bit unsigned binary values
     * - `base64`: Base64 encoded strings
     */
    embeddingType?: 'float' | 'binary' | 'ubinary' | 'base64';
    /**
     * Whether to normalize the resulting output embeddings.
     * Scales the embedding so its Euclidean (L2) norm becomes 1, preserving direction. Useful when downstream involves dot-product, classification, visualization.
     * Defaults to true.
     */
    normalized?: boolean;
    /**
     * Truncate at Maximum Context Length which is 8k tokens
     *
     * When enabled, the model will automatically drop the tail that extends beyond the maximum context length allowed by the model instead of throwing an error.
     *
     * Defaults to false.
     */
    truncate?: boolean;
}

type MultimodalEmbeddingInput = {
    text?: string;
    image?: string;
};

interface JinaProvider extends ProviderV1 {
    /**
     * Create a text embedding model for string inputs only.
     * This ensures type safety by only allowing string arrays.
     * @param modelId - The Jina model ID
     * @param settings - Optional model settings
     */
    textEmbeddingModel(modelId: JinaEmbeddingModelId, settings?: JinaEmbeddingSettings): EmbeddingModelV1<string>;
    /**
     * Create a multimodal embedding model for MultimodalEmbeddingInput only.
     * This ensures type safety by only allowing MultimodalEmbeddingInput arrays.
     * @param modelId - The Jina model ID
     * @param settings - Optional model settings
     */
    multiModalEmbeddingModel(modelId: JinaEmbeddingModelId, settings?: JinaEmbeddingSettings): EmbeddingModelV1<MultimodalEmbeddingInput>;
}
interface JinaProviderSettings {
    /**
     * Use a different URL prefix for API calls, e.g. to use proxy servers.
     * The default prefix is `https://api.jina.ai/v1`.
     */
    baseURL?: string;
    /**
     * API key that is being send using the `Authorization` header.
     * It defaults to the `JINA_API_KEY` environment variable.
     */
    apiKey?: 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 createJina(options?: JinaProviderSettings): JinaProvider;
declare const jina: JinaProvider;

export { type JinaProvider, type JinaProviderSettings, type MultimodalEmbeddingInput, createJina, jina };
