import { ServerError } from '../../utility/errors/hdbError.ts';
import type { BackendOpts, EmbedOpts, GenerateChunk, GenerateInput, GenerateOpts, GenerateResult, ModelBackend, ModelCallResult, ModelCapabilities } from '../../resources/models/types.ts';
export type OpenAIBackendKind = 'embedding' | 'generative';
export interface OpenAIBackendConfig {
    /** Bearer token for the upstream API. Required. */
    apiKey?: string;
    /** Default model when the caller doesn't pass `opts.model`. */
    model?: string;
    /** Base URL of the OpenAI-compatible endpoint (default `https://api.openai.com/v1`). */
    baseUrl?: string;
    /** Per-request timeout. When set, combined with `opts.signal` via `AbortSignal.any`. */
    requestTimeoutMs?: number;
    /** Forwarded as `OpenAI-Organization` header when set. */
    organization?: string;
}
/**
 * `ModelBackend` implementation talking to OpenAI's HTTP API (or any
 * OpenAI-compatible endpoint).
 *
 * - `embed` → `POST {baseUrl}/embeddings`
 * - `generate` → `POST {baseUrl}/chat/completions` (always chat shape)
 * - `generateStream` → same with `stream: true`; consumes SSE wire format and
 *   yields `GenerateChunk` per delta.
 *
 * Capabilities advertise `tools: true` — first backend with native tool-call
 * support. `adapters: false` — OpenAI doesn't expose LoRA adapter selection
 * externally. `toolMode: 'return'` (Phase 1 default) is supported end-to-end;
 * `toolMode: 'auto'` is reserved for #612.
 */
export declare class OpenAIBackend implements ModelBackend {
    #private;
    readonly name = "openai";
    constructor(config?: OpenAIBackendConfig, fetchImpl?: typeof fetch);
    capabilities(): ModelCapabilities;
    embed(input: string | string[], opts: BackendOpts<EmbedOpts>): Promise<ModelCallResult<Float32Array[]>>;
    generate(input: GenerateInput, opts: BackendOpts<GenerateOpts>): Promise<ModelCallResult<GenerateResult>>;
    generateStream(input: GenerateInput, opts: BackendOpts<GenerateOpts>): AsyncIterable<GenerateChunk>;
}
/**
 * Boot-bridge helper. Called from `resources/models/bootstrap.ts` for each
 * `models.embedding.<name>` / `models.generative.<name>` entry whose
 * `backend: openai`.
 */
export declare function registerOpenAIBackend(args: {
    logicalName: string;
    kind: OpenAIBackendKind;
    config: OpenAIBackendConfig;
}): void;
export declare class OpenAIBackendError extends ServerError {
    constructor(message: string);
}
