# OpenCode/OpenRouter LLM Provider Migration Inventory

Created: 2026-06-29

This inventory started as the Codex CLI migration tracker. As of 2026-06-29, the
target direction is OpenCode CLI backed by OpenRouter, with shared
OpenAI-compatible client options defaulting to OpenRouter rather than Codex CLI
or direct OpenAI.

## Current Shared Path

- `libs/shared/config/src/loader.ts` now defaults all environments to
  `openrouter`, with `OPENROUTER_MODEL` defaulting to
  `deepseek/deepseek-v4-flash` where a model is needed. `AI_USE_CODEX_CLI=true`
  is treated as a legacy alias for the replacement `opencode-cli` path.
- `OPENROUTER_API_KEY` and `OPENROUTER_BASE_URL` are now the default
  OpenAI-compatible credentials and endpoint inputs for shared chat clients.
- Shared OpenRouter modality defaults live in
  `libs/shared/ai/src/openai-compatible/client-options.ts`: text chat uses
  `deepseek/deepseek-v4-flash`, vision chat uses `google/gemini-2.5-flash-lite`,
  text embeddings use `perplexity/pplx-embed-v1-0.6b`, and image generation uses
  `google/gemini-3.1-flash-lite-image`.
- `libs/shared/ai/src/openai-compatible/client-options.ts` still keeps its
  compatibility-oriented import path, but its default runtime provider is now
  `openrouter`. Production OpenRouter routing requires `OPENROUTER_API_KEY`. The
  focused package export `@oshun/ai/openai-compatible/client-options` is
  available for packages that need only the shared compatible-client resolver
  without importing the local OpenCode server wrapper.
- `libs/shared/ai/src/providers/opencode-cli.ts` now provides a first-class
  OpenCode CLI provider backed by `opencode run` and the OpenRouter
  `deepseek/deepseek-v4-flash` model by default.
- `libs/shared/ai/src/providers/codex-cli.ts` remains only as a compatibility
  adapter for legacy imports; it now delegates to `OpenCodeCliProvider` and
  defaults to OpenCode/OpenRouter rather than `codex exec`.
- `createOpenAICompatibleOpenCodeServer` and
  `startOpenAICompatibleOpenCodeServer` provide the local OpenAI-compatible
  service wrapper backed by OpenCode CLI and OpenRouter. The old
  `createOpenAICompatibleCodexServer`, `startOpenAICompatibleCodexServer`, and
  `oshun-codex-openai` names remain compatibility aliases.

## OpenCode/OpenRouter Target Boundary

- Text chat defaults to OpenRouter model `deepseek/deepseek-v4-flash`.
- OpenCode CLI should replace the Codex CLI command runner for local/CLI-backed
  agent flows and should use an OpenRouter key instead of an OpenAI
  subscription.
- Image, audio, speech, embedding, and other modality-specific flows should use
  the cheapest suitable OpenRouter-backed model or remain explicitly direct only
  when OpenRouter/OpenCode cannot support the modality yet. As of 2026-06-30,
  the public OpenRouter model feeds list `perplexity/pplx-embed-v1-0.6b` as the
  cheapest non-free text embedding model and
  `google/gemini-3.1-flash-lite-image` as the cheapest listed text-to-image
  model; stale `google/gemini-2.5-flash-image-preview[:free]` defaults should
  not be used.

## Direct OpenAI/OpenAI-Compatible Call Sites

These files matched direct OpenAI SDK imports, constructors, chat completions,
responses, image, audio, or embedding calls:

- `apps/oshun/bff/src/sophia/answer-synthesizer-env.ts` and
  `apps/oshun/bff/src/sophia/answer-synthesizer.ts` (migrated optional Sophia
  synthesis chat enhancement to the shared OpenRouter/OpenCode-compatible
  resolver; legacy `OSHUN_LLM_*` triples remain explicit overrides)
- `apps/oshun/bff/src/assistant/llm-reply-composer.ts` (migrated optional
  assistant reply composition chat enhancement to the same shared
  OpenRouter/OpenCode-compatible resolver; legacy `OSHUN_LLM_*` triples remain
  explicit overrides)
- `apps/oshun/bff/src/accessibility/ml-accessibility-service.ts` (migrated
  default visual alt-text chat model to `deepseek/deepseek-v4-flash`; the
  Whisper-compatible transcription branch remains explicit direct audio
  modality)
- `apps/lilith/svc-ai/src/conversation-generation/conversation-generation-service.ts`
  (migrated logical OpenAI-compatible conversation turns to shared OpenRouter
  credentials, endpoint, and `deepseek/deepseek-v4-flash` default model)
- `apps/lilith/svc-ai/src/llm-orchestration.ts` (migrated the OpenAI provider
  adapter to shared OpenRouter-compatible credentials, endpoint, and
  `deepseek/deepseek-v4-flash` default model; Azure OpenAI remains explicit)
- `apps/lakshmi/worker/src/index.ts` (no runtime provider call; contains only a
  future embeddings placeholder comment)
- `services/metis/src/metis/services/tutoring_service.py` (migrated the tutoring
  OpenAI-compatible chat branch to OpenRouter/OpenCode-compatible credentials,
  endpoint, and `deepseek/deepseek-v4-flash` default model; explicit OpenAI
  remains opt-in)
- `services/psyche/knowledge-base/src/knowledge_base/rag/generator.py` (migrated
  RAG OpenAI-compatible chat and streaming generation to
  OpenRouter/OpenCode-compatible credentials, endpoint, and
  `deepseek/deepseek-v4-flash` default model; explicit OpenAI remains opt-in)
- `services/psyche/voice-engine/src/voice_engine/conversation/llm.py` (migrated
  voice conversation OpenAI-compatible chat and streaming generation to
  OpenRouter/OpenCode-compatible credentials, endpoint, and
  `deepseek/deepseek-v4-flash` default model; explicit OpenAI remains opt-in)
- `apps/veritas/api/src/interfaces/http/routes/v1/writingAssistant.ts` (migrated
  OpenAI-compatible writing provider branch to shared OpenRouter credentials,
  endpoint, and `deepseek/deepseek-v4-flash` default model; Anthropic remains
  explicitly direct)
- `apps/veritas/agents/src/core/llm-client.ts` (migrated OpenAI provider client
  factory and default agent LLM configs to `@oshun/ai/openai-compatible`;
  production now requires `OPENROUTER_API_KEY`)
- `apps/veritas/ai-workers/src/workers/base/llm.ts` (migrated chat client
  factory to `@oshun/ai/openai-compatible`)
- `apps/veritas/nlp/src/services/claims/llm.ts` (migrated chat client factory to
  `@oshun/ai/openai-compatible`)
- `apps/veritas/nlp/src/services/summarization/abstractive.ts` (migrated chat
  client factory to `@oshun/ai/openai-compatible`)
- `apps/veritas/nlp/src/services/embeddings/openai.ts` (left direct: embeddings
  are outside the current shared OpenRouter chat migration)
- `apps/veritas/video/src/providers/whisper.ts`
- `apps/veritas/video/src/providers/whisper.spec.ts`
- `apps/yemaya/api/src/services/agent-runtime.ts` (migrated logical OpenAI agent
  completion registration to OpenRouter/OpenCode-compatible configuration and
  `deepseek/deepseek-v4-flash` default model; explicit OpenAI remains opt-in)
- `libs/veritas/agents-core/src/llm.ts` (migrated logical OpenAI-compatible
  agent completions to OpenRouter/OpenCode-compatible credentials, endpoint, and
  `deepseek/deepseek-v4-flash` default model; explicit OpenAI remains opt-in)
- `libs/aphrodite/stream-content-analysis/src/stream-analyzer.ts` (migrated
  OpenAI-compatible vision chat analysis to shared OpenRouter credentials,
  endpoint, and `deepseek/deepseek-v4-flash` default model)
- `libs/aphrodite/content-tagging/src/category-detector.ts` (migrated
  OpenAI-compatible visual category classification chat requests to the shared
  OpenRouter-compatible client options and `deepseek/deepseek-v4-flash` default
  model)
- `libs/contracts/src/tts/providers/openai-adapter.ts`
- `libs/hathor/llm-npc/src/platforms/llm-client.ts` (migrated the OpenAI logical
  provider branch to shared OpenRouter credentials, endpoint, and
  `deepseek/deepseek-v4-flash` default model)
- `libs/iris/conversation-providers-openai/src/openai-provider.ts` (migrated
  default OpenAI-compatible client factory and chat model to shared
  OpenRouter-compatible options; embeddings/moderation retain their explicit
  request models)
- `libs/iris/conversation-providers-openai/src/openai-provider.test.ts`
- `libs/iris/multimodal/vision/video/src/video-analyzer.ts`
- `libs/isis/ai-providers/src/providers/conversational-ai/llm-adapters/gpt51-adapter.ts`
  (migrated OpenAI-compatible client factory and default cost-tier model to
  `@oshun/ai/openai-compatible` / `deepseek/deepseek-v4-flash`)
- `libs/isis/ai-providers/src/providers/conversational-ai/llm-adapters/gpt51-adapter.js`
  (kept committed JS mirror aligned with the migrated TypeScript adapter)
- `libs/isis/ai-providers/src/providers/llm/openai.ts` (migrated OpenAI LLM
  provider client factory to `@oshun/ai/openai-compatible`)
- `libs/isis/ai-providers/src/providers/llm/openai.js` (kept committed JS mirror
  aligned with the migrated TypeScript provider)
- `libs/isis/ai-providers/src/providers/llm/xai.ts` (migrated xAI compatibility
  provider client factory and default chat model to shared OpenRouter-compatible
  options)
- `libs/isis/ai-providers/src/providers/llm/xai.js` (kept committed JS mirror
  aligned with the migrated TypeScript provider)
- `libs/psyche/database/src/psyche_database/vector/embeddings.py`
- `libs/psyche/memory-archival/src/embeddings.ts`
- `libs/shared/ai/src/providers/opencode-cli.ts` (added OpenCode CLI provider
  using OpenRouter defaults)
- `libs/shared/ai/src/providers/codex-cli.ts` (legacy compatibility adapter now
  delegates to OpenCode CLI/OpenRouter instead of spawning Codex)
- `libs/shared/ai/src/providers/openai.ts` (migrated OpenAI LLM provider client
  factory to OpenRouter through `@oshun/ai/openai-compatible`; production
  requires `OPENROUTER_API_KEY`)
- `libs/shared/ai/src/providers/xai.ts` (migrated xAI compatibility provider
  client factory and default chat model to shared OpenRouter-compatible options)
- `libs/veritas/live-stream/src/interactive/ai-response-generator.ts` (migrated
  OpenAI-compatible viewer-response generation to shared OpenRouter credentials,
  endpoint, and `deepseek/deepseek-v4-flash` default model)
- `libs/veritas/live-stream/src/interactive/ai-moderation.ts` (migrated
  OpenAI-compatible Q&A moderation to shared OpenRouter credentials, endpoint,
  and `deepseek/deepseek-v4-flash` default model)
- `libs/veritas/developer-support/src/chatbot.ts` (migrated OpenAI chat client
  factory to `@oshun/ai/openai-compatible`; production now requires
  `OPENROUTER_API_KEY`)
- `libs/veritas/llm/src/client.ts` (migrated OpenAI client factory and default
  balanced/budget routing to `@oshun/ai/openai-compatible`; Anthropic remains
  explicit quality-first and fallback)
- `libs/veritas/nlp-core/src/providers/openai.ts` (migrated abstractive
  summarization chat client factory to `@oshun/ai/openai-compatible`; embeddings
  remain direct OpenAI because they are outside the current shared OpenRouter
  chat migration)
- `services/metis/src/metis/services/tutoring_service.py`
- `services/psyche/conferencing/src/video_conferencing/perception/behavior_analysis.py`
- `services/psyche/knowledge-base/src/knowledge_base/embedding/generators.py`
- `services/psyche/knowledge-base/src/knowledge_base/rag/generator.py`
- `services/psyche/orchestrator/src/orchestrator/caching/embedding_service.py`
- `services/psyche/perception-engine/src/perception_engine/intent/behavioral.py`
- `services/psyche/video-conferencing/src/video_conferencing/perception/behavior_analysis.py`
- `services/psyche/voice-engine/src/voice_engine/conversation/llm.py`

## Next Migration Order

1. Route remaining TypeScript chat/vision call sites through the shared
   OpenRouter-compatible options or service boundary.
2. Pick the cheapest suitable OpenRouter model per unsupported modality and keep
   any direct non-OpenRouter adapter explicitly documented until migrated.
3. Update Python/service call sites to use the same shared OpenRouter service
   contract where feasible.
