/**
 * Shared HTTP helpers for AI provider adapters: a timeout-bounded fetch, a
 * status->AIConnectionStatus mapper, and an SSRF guard for custom base URLs.
 * Built-in providers use fixed hostnames; only custom endpoints are
 * admin-controlled and therefore validated/resolved.
 */
import type { AIConnectionStatus } from '../types.js';
export interface AdapterContext {
    apiKey: string;
    baseUrl?: string;
    organizationId?: string;
    projectId?: string;
    /** Injectable fetch for tests; defaults to global `fetch`. */
    fetchImpl?: typeof fetch;
    timeoutMs?: number;
}
/** Map an HTTP response status to a connection-health value. */
export declare function statusFromHttp(status: number): AIConnectionStatus;
/** A short, safe message for a status (never contains the key). */
export declare function messageFromStatus(status: AIConnectionStatus, httpStatus?: number): string;
/** Best-effort extraction of a provider error message from a JSON error body. */
export declare function extractProviderErrorMessage(payload: unknown): string | undefined;
export declare function timedFetch(url: string, init: RequestInit, ctx: AdapterContext): Promise<Response>;
/**
 * Validate a custom provider base URL against SSRF (no private/internal hosts,
 * https/http only) AND resolve its DNS to defend against rebinding. Throws on
 * rejection with a safe message.
 */
export declare function assertSafeBaseUrl(baseUrl: string): Promise<void>;
/** Strip a trailing slash so we can append `/models` etc. cleanly. */
export declare function trimTrailingSlash(url: string): string;
export interface GenerateTextOptions {
    /** Provider-native model id (e.g. `gpt-4o`, `claude-sonnet-4-6`). */
    model: string;
    prompt: string;
    system?: string;
    maxTokens?: number;
    temperature?: number;
}
export interface GenerateTextResult {
    text: string;
    usage: {
        promptTokens: number;
        completionTokens: number;
        totalTokens: number;
    };
    /** Provider-native model id that produced the result. */
    model: string;
}
/** Build an adapter error from a non-2xx response, including provider detail when safe. */
export declare function adapterHttpErrorFromResponse(res: Response): Promise<AdapterHttpError>;
/**
 * Call an OpenAI-compatible `/chat/completions` endpoint. Shared by the OpenAI,
 * xAI, and custom adapters (all speak the same wire format). `base` must already
 * be validated/SSRF-checked by the caller for admin-controlled endpoints.
 */
export declare function openAiChat(base: string, headers: Record<string, string>, ctx: AdapterContext, opts: GenerateTextOptions): Promise<GenerateTextResult>;
/** Error carrying a mapped connection status so the runtime can react sensibly. */
export declare class AdapterHttpError extends Error {
    readonly connectionStatus: AIConnectionStatus;
    readonly httpStatus: number;
    constructor(connectionStatus: AIConnectionStatus, httpStatus: number, detail?: string);
}
/** Best-effort extraction of model ids from an OpenAI-compatible list payload. */
export declare function extractModelIds(payload: unknown): string[];
//# sourceMappingURL=http.d.ts.map