import type { Brain } from "../core/types.js"; import { type StreamEngineConfig } from "./stream-engine.js"; export interface OpenAIBrainConfig extends StreamEngineConfig { /** Base URL of your OpenAI-compatible gateway (without /chat/completions). Overridden by model.baseUrl if set. */ baseUrl?: string; /** API key. Overridden by per-call options.apiKey / getApiKeyAndHeaders. */ apiKey?: string; /** Extra headers merged into every request. */ headers?: Record; /** Inject a custom fetch (tests / proxies). Defaults to global fetch. */ fetchImpl?: typeof fetch; /** * For weaker models that emit tool calls as TEXT (`{...}` / fenced json) * instead of native tool calls: promote them to real tool calls. Off by default. Native models * don't need this. */ repairTextToolCalls?: boolean; /** * Replay assistant `reasoning_content` back to the provider on follow-up requests (design/46). * **On by default**, and **conditional**: thinking is replayed only on prior assistant **tool-call** * turns — DeepSeek V4 **requires** it there (else it errors/degrades), while non-tool turns ignore it, * so replaying there only bloats the context window (prefix-cache cuts the *cost* of that bloat but not * the *window occupancy* → earlier compaction). Replaying just the tool-call turns is correctness- * equivalent and leaner. Set `false` to never replay (e.g. a provider that rejects the field). * Anthropic uses `createAnthropicBrain`, which always replays thinking blocks with their signature. */ replayThinking?: boolean; /** * Detect **degenerate repetition** (the model looping on the same char/phrase forever) mid-stream * and cut it off — the turn ends `error` ("degenerate repetition") so the loop stops paying and a * team member's looped output is treated as a failed turn, not a real statement. Default true. */ detectRepetition?: boolean; } /** * Create a Brain that talks to an OpenAI-compatible chat-completions endpoint (your model gateway). * Translates the unified Context into an OpenAI request and the streamed response back into the unified * AssistantMessageEvent protocol, including native tool calls. The connect/retry/timeout/read-loop * machinery lives in the shared {@link runStreamingBrain} engine (design/32); this adapter owns the * OpenAI request shaping + chat-completions SSE parsing + finalization. */ export declare function createOpenAIBrain(config?: OpenAIBrainConfig): Brain; //# sourceMappingURL=openai.d.ts.map