import type { EmbeddingProvider } from '../spi/embedding-provider.js';
/** A non-2xx answer (or a malformed one) from an embeddings or rerank endpoint. */
export declare class HttpModelError extends Error {
    /** HTTP status; `502` when the endpoint answered 2xx with a body that doesn't fit the contract. */
    readonly status: number;
    constructor(
    /** HTTP status; `502` when the endpoint answered 2xx with a body that doesn't fit the contract. */
    status: number, message: string);
}
export interface OpenAiEmbeddingsOptions {
    /** The embedding model id, sent as `model`. */
    model: string;
    /**
     * Base URL up to and including `/v1` — the client posts to `<baseUrl>/embeddings`. Default
     * `https://api.openai.com/v1`. Point it at any OpenAI-compatible server: Azure/OpenRouter/an LLM
     * gateway, Ollama (`http://localhost:11434/v1`), Hugging Face TEI, vLLM, LocalAI, LM Studio…
     */
    baseUrl?: string;
    /** Sent as `Authorization: Bearer <apiKey>` when set. Local servers usually need none. */
    apiKey?: string;
    /** Output width for models that support shortening (`text-embedding-3-*`), sent as `dimensions`. */
    dimensions?: number;
    /**
     * Inputs per request. Default 64. When the server refuses a request for its size (see
     * {@link isBatchTooLarge}) the batch is split in halves and retried, and later requests use the
     * size that worked — so a server whose limit is below this (TEI's `--max-client-batch-size`
     * defaults to 32) costs one refused request, not a failed ingestion.
     */
    batchSize?: number;
    /**
     * Inputs longer than this many characters are truncated before sending, so one oversized chunk
     * doesn't fail a whole batch on the model's context limit. Default 24 000 (≈ 6–8k tokens); set
     * `Infinity` to send inputs as they are.
     */
    maxInputChars?: number;
    /** Extra request headers (an org/project id, a gateway's attribution header). */
    headers?: Record<string, string>;
    /** Per-request timeout. Default 120 000 ms. */
    timeoutMs?: number;
    /**
     * Called with the provider-reported token count of every request. The same counts also reach the
     * ledger and quota through `embedWithUsage`; this is for your own metering on top.
     */
    onUsage?: (tokens: number) => void;
    /**
     * Called when the server refused a batch for its size and it was split — a misconfiguration worth
     * surfacing: raise the server's limit (TEI: `--max-client-batch-size`) or lower `batchSize`.
     */
    onWarn?: (message: string) => void;
    /** `fetch` to use. Default the global one. */
    fetch?: typeof fetch;
}
/**
 * Did the server refuse this request for its **size** — too many inputs (TEI's
 * `--max-client-batch-size`: `batch size 64 > maximum allowed batch size 32`) or too large a
 * payload? Those are fixed by sending fewer inputs per request; anything else (auth, a bad model,
 * one input over the context window) is not, and is rethrown as is.
 */
export declare function isBatchTooLarge(error: unknown): boolean;
/**
 * An {@link EmbeddingProvider} over any OpenAI-compatible `POST /v1/embeddings` endpoint, with no SDK
 * dependency: OpenAI itself, or a gateway/local server speaking the same protocol (TEI, Ollama,
 * vLLM, LocalAI…). For a Vercel AI SDK model use `aiSdkEmbedding` from `-ai-sdk` instead.
 *
 * Batches by {@link OpenAiEmbeddingsOptions.batchSize} — splitting and retrying a batch the server
 * refuses as too large, and remembering the size that worked — restores input order from each item's
 * `index`, and fails loudly (an {@link HttpModelError}) on a non-2xx answer or a vector count that
 * doesn't match the inputs. Empty strings are sent as a single space, since OpenAI rejects them.
 * Implements `embedWithUsage` with the provider-reported tokens (summed over the batches) and model, so
 * embedding spend reaches the ledger and the quota.
 *
 * ```ts
 * const embedder = openAiEmbeddings({ model: 'text-embedding-3-small', apiKey: process.env.OPENAI_API_KEY });
 * const local = openAiEmbeddings({ baseUrl: 'http://tei:8080/v1', model: 'BAAI/bge-m3' });
 * ```
 */
export declare function openAiEmbeddings(options: OpenAiEmbeddingsOptions): EmbeddingProvider;
/** The human part of an error body: OpenAI's `error.message`, a bare `message`/`error`, or the text. */
export declare function errorMessageOf(body: string): string;
//# sourceMappingURL=openai-embeddings.d.ts.map