Skip to content

ai: use OpenAI-compatible chat endpoint (gateway-friendly) - #1

Merged
sdelcore merged 1 commit into
mainfrom
ai-openai-compatible
Jun 15, 2026
Merged

sdelcore merged 1 commit into
mainfrom
ai-openai-compatible

Conversation

@sdelcore

Copy link
Copy Markdown
Owner

/api/ai/chat now talks to an OpenAI-compatible /chat/completions endpoint (OPENAI_BASE_URL + OPENAI_API_KEY) instead of calling Anthropic directly.

Why: lets shared sit behind an OpenAI-compatible gateway (LiteLLM), which is the real provider/format abstraction — so shared stays a thin client and can reach any model the gateway exposes. The homelab routes it to LiteLLM → OpenCode Zen (Kimi 2.6). The Anthropic SDK path couldn't be used through LiteLLM (the /v1/messages→openai-provider translation didn't round-trip).

  • Client API unchanged: {messages,system,model,max_tokens}{content,model,stop_reason}.
  • Plain net/http, no AI-SDK dependency (dropped anthropic-sdk-go; didn't add openai-go — its param unions are heavy for one call, and LiteLLM is the abstraction).
  • README + nixos module env var docs updated (ANTHROPIC_API_KEYOPENAI_BASE_URL/OPENAI_API_KEY).

/api/ai/chat now POSTs to an OpenAI-compatible /chat/completions endpoint
(OPENAI_BASE_URL + OPENAI_API_KEY) instead of calling Anthropic directly.
This lets it sit behind an OpenAI-compatible gateway like LiteLLM (which
is the provider/format abstraction) and reach any model the gateway
exposes — the homelab points it at LiteLLM -> OpenCode Zen (Kimi 2.6).

Client request/response shape is unchanged ({messages,system,model,
max_tokens} -> {content,model,stop_reason}). Plain net/http, no AI SDK
dependency (dropped anthropic-sdk-go). SHARED_AI_MODEL default unchanged.
@sdelcore
sdelcore merged commit 8492634 into main Jun 15, 2026
@sdelcore
sdelcore deleted the ai-openai-compatible branch June 15, 2026 12:12
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