Skip to content

feat(ai): add openai-compatible structured + streaming adapters - #295

Merged
cordialApple merged 1 commit into
mainfrom
feat/openai-provider-adapter
Jul 22, 2026
Merged

feat(ai): add openai-compatible structured + streaming adapters#295
cordialApple merged 1 commit into
mainfrom
feat/openai-provider-adapter

Conversation

@cordialApple

Copy link
Copy Markdown
Owner

what

Add OpenAI-compatible provider adapters — one code path serves Ollama, LM Studio, vLLM, llama.cpp, and OpenAI itself. Third PR in the local-LLM routing sequence (PR1 structured seam, PR2 native-free routing surface).

  • providers/openai.tsopenaiStructured (StructuredProvider over /chat/completions with json_schema response_format) + openaiTransport (AiTransport over SSE stream). Both take injectable baseUrl/apiKey/fetch; fall back to lazy getSecret('openai_api_key') + resolveAiFetch() in prod.
  • registry.ts — wire the openai branch to build both adapters without touching secrets at construction time. Gemini branch still throws "not available yet" (lands next PR).
  • routing.ts — add DEFAULT_OPENAI_BASE.

why

Route high-volume tiers to a local/cheap backend so cost does not balloon. OpenAI-compat is the one wire format every local runtime speaks.

test

  • openai-provider.test.ts — structured maps completion + usage + refusal + non-2xx + empty-key guard; transport streams delta tokens, reports final usage chunk, routes errors to onError. All native-free (injected fetch).
  • registry.test.ts — openai builds adapter/transport without db; gemini still throws.
  • gate: typecheck + lint clean, 783 passed | 1 skipped.

@cordialApple
cordialApple merged commit c678528 into main Jul 22, 2026
1 check passed
@cordialApple
cordialApple deleted the feat/openai-provider-adapter branch July 22, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant