/** * OpenAI Responses API provider (`/v1/responses`). * * Why this exists as its own provider rather than another `baseUrl` on the * OpenAI-format chat/completions client: * * OpenAI's reasoning models (gpt-5.x) REJECT function tools on * `/v1/chat/completions` unless `reasoning_effort` is `"none"` — i.e. the only * way to keep tools on that endpoint is to turn the reasoning off, which is the * entire value of the model for an agentic workload. `/v1/responses` supports * tools AND reasoning, but speaks a genuinely different wire format (`input` * items instead of `messages`, `function_call` output items instead of * `tool_calls`, `response.*` SSE events instead of `choices[].delta`). * * That is two hosts speaking two protocols, not one protocol with a second host — * so it gets its own `LLMProvider`, and the chat/completions client goes back to * being purely the HuggingFace router. * * ── Reasoning round-trip (the load-bearing constraint) ────────────────────── * Verified against the live API: a `function_call` item fed back on a later turn * WITHOUT its originating `reasoning` item is a 400: * * "Item 'fc_…' of type 'function_call' was provided without its required * 'reasoning' item: 'rs_…'." * * So the raw output items of every assistant turn must survive verbatim into the * next request. The agentic loop round-trips `response.content` (Anthropic content * blocks) unchanged, so we smuggle the raw item array through a `thinking` block * (a real Anthropic block type that every other consumer already ignores) and * expand it back on the way out. Byte-exact ids, byte-exact ordering. */ import type Anthropic from '@anthropic-ai/sdk'; import type { LLMProvider, ChatOptions, LLMResponse, ToolDefinition } from './provider.js'; export declare const OPENAI_RESPONSES_URL = "https://api.openai.com/v1/responses"; /** An output item: `reasoning`, `function_call`, `message`, … Echoed verbatim. */ type ResponseItem = Record & { type: string; }; export declare class OpenAIResponsesProvider implements LLMProvider { private apiKey; private baseUrl; constructor(apiKey?: string, baseUrl?: string); chat(options: ChatOptions): Promise; /** The exact request body for a turn. Public: it is the whole wire contract. */ buildBody(options: ChatOptions): Record; private _streamChat; } /** * Assistant content blocks for the agentic loop. * * Block 0 carries the raw output items (see the reasoning round-trip note at the * top of this file); the text and tool_use blocks after it are the loop's own * view of the same turn. */ export declare function buildContentBlocks(items: ResponseItem[], text: string): Anthropic.ContentBlock[]; /** Recover the verbatim raw items an assistant turn was built from, if present. */ export declare function extractRawItems(content: Anthropic.MessageParam['content']): ResponseItem[] | undefined; /** Anthropic messages → Responses API `input` items. */ export declare function convertInput(messages: Anthropic.MessageParam[]): ResponseItem[]; /** Tool definitions are flat on the Responses API (no nested `function` object). */ export declare function convertTools(tools: ToolDefinition[]): Record[]; export {}; //# sourceMappingURL=openai-responses-provider.d.ts.map