Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@
"openai-codex/gpt-5.1-codex-mini"
]
},
"anthropic": {
"enabled": false,
"baseUrl": "https://api.anthropic.com/v1",
"method": "api-key",
"models": ["anthropic/claude-sonnet-4-6"]
},
"openrouter": {
"enabled": false,
"baseUrl": "https://openrouter.ai/api/v1",
Expand Down
1 change: 1 addition & 0 deletions container/shared/provider-context.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export interface ProviderContextValidationParams {
provider?: string;
providerMethod?: string;
baseUrl?: string;
apiKey?: string;
model?: string;
Expand Down
7 changes: 6 additions & 1 deletion container/shared/provider-context.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const API_KEY_REQUIRED_PROVIDERS = new Set([
'hybridai',
'openai-codex',
'anthropic',
'openrouter',
'mistral',
'huggingface',
Expand All @@ -15,6 +16,9 @@ function buildMissingContextError(params) {

export function getProviderContextError(params) {
const provider = String(params.provider || 'hybridai').trim() || 'hybridai';
const anthropicUsesClaudeCli =
provider === 'anthropic' &&
String(params.providerMethod || '') === 'claude-cli';
if (!String(params.baseUrl || '').trim()) {
return buildMissingContextError({
toolName: params.toolName,
Expand All @@ -31,7 +35,8 @@ export function getProviderContextError(params) {
}
if (
API_KEY_REQUIRED_PROVIDERS.has(provider) &&
!String(params.apiKey || '').trim()
!String(params.apiKey || '').trim() &&
!anthropicUsesClaudeCli
) {
return buildMissingContextError({
toolName: params.toolName,
Expand Down
5 changes: 5 additions & 0 deletions container/src/browser-tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,15 @@ type BrowserModelContext = {
provider:
| 'hybridai'
| 'openai-codex'
| 'anthropic'
| 'openrouter'
| 'mistral'
| 'huggingface'
| 'ollama'
| 'lmstudio'
| 'llamacpp'
| 'vllm';
providerMethod?: string;
baseUrl: string;
apiKey: string;
model: string;
Expand Down Expand Up @@ -238,6 +240,7 @@ export function setBrowserModelContext(
provider:
| 'hybridai'
| 'openai-codex'
| 'anthropic'
| 'openrouter'
| 'mistral'
| 'huggingface'
Expand All @@ -246,6 +249,7 @@ export function setBrowserModelContext(
| 'llamacpp'
| 'vllm'
| undefined,
providerMethod: string | undefined,
baseUrl: string,
apiKey: string,
model: string,
Expand All @@ -255,6 +259,7 @@ export function setBrowserModelContext(
): void {
currentBrowserModelContext = {
provider: provider || 'hybridai',
providerMethod,
baseUrl: String(baseUrl || '')
.trim()
.replace(/\/+$/, ''),
Expand Down
16 changes: 16 additions & 0 deletions container/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ function resolveTaskModelsForRequest(
!incomingTaskModel.error &&
String(incomingTaskModel.provider || '') ===
String(storedTaskModel?.provider || '') &&
String(incomingTaskModel.providerMethod || '') ===
String(storedTaskModel?.providerMethod || '') &&
normalizeTaskModelBaseUrl(incomingTaskModel.baseUrl) ===
normalizeTaskModelBaseUrl(storedTaskModel?.baseUrl) &&
String(incomingTaskModel.model || '').trim() ===
Expand Down Expand Up @@ -690,13 +692,15 @@ async function callHybridAIWithRetry(params: {
provider?:
| 'hybridai'
| 'openai-codex'
| 'anthropic'
| 'openrouter'
| 'mistral'
| 'huggingface'
| 'ollama'
| 'lmstudio'
| 'llamacpp'
| 'vllm';
providerMethod?: string;
baseUrl: string;
apiKey: string;
model: string;
Expand All @@ -714,6 +718,7 @@ async function callHybridAIWithRetry(params: {
}): Promise<ChatCompletionResponse> {
const {
provider,
providerMethod,
baseUrl,
apiKey,
model,
Expand Down Expand Up @@ -745,6 +750,7 @@ async function callHybridAIWithRetry(params: {
try {
response = await callRoutedModelStream({
provider,
providerMethod,
baseUrl,
apiKey,
model,
Expand All @@ -768,6 +774,7 @@ async function callHybridAIWithRetry(params: {
if (!fallbackEligible) throw streamErr;
response = await callRoutedModel({
provider,
providerMethod,
baseUrl,
apiKey,
model,
Expand Down Expand Up @@ -839,6 +846,7 @@ async function processRequest(
provider:
| 'hybridai'
| 'openai-codex'
| 'anthropic'
| 'openrouter'
| 'mistral'
| 'huggingface'
Expand All @@ -847,6 +855,7 @@ async function processRequest(
| 'llamacpp'
| 'vllm'
| undefined,
providerMethod: string | undefined,
isLocal: boolean | undefined,
contextWindow: number | undefined,
thinkingFormat: 'qwen' | undefined,
Expand Down Expand Up @@ -993,6 +1002,7 @@ async function processRequest(
try {
response = await callHybridAIWithRetry({
provider,
providerMethod,
baseUrl,
apiKey,
model,
Expand Down Expand Up @@ -1551,6 +1561,7 @@ async function main(): Promise<void> {
setWebSearchConfig(firstInput.webSearch);
setModelContext(
firstInput.provider,
firstInput.providerMethod,
firstInput.baseUrl,
storedApiKey,
firstInput.model,
Expand Down Expand Up @@ -1598,6 +1609,7 @@ async function main(): Promise<void> {
storedApiKey,
firstInput.baseUrl,
firstInput.provider,
firstInput.providerMethod,
firstInput.isLocal,
firstInput.contextWindow,
firstInput.thinkingFormat,
Expand Down Expand Up @@ -1632,6 +1644,7 @@ async function main(): Promise<void> {
storedApiKey,
firstInput.baseUrl,
firstInput.provider,
firstInput.providerMethod,
firstInput.isLocal,
firstInput.contextWindow,
firstInput.thinkingFormat,
Expand Down Expand Up @@ -1697,6 +1710,7 @@ async function main(): Promise<void> {
setWebSearchConfig(input.webSearch);
setModelContext(
input.provider,
input.providerMethod,
input.baseUrl,
apiKey,
input.model,
Expand Down Expand Up @@ -1748,6 +1762,7 @@ async function main(): Promise<void> {
apiKey,
input.baseUrl,
input.provider,
input.providerMethod,
input.isLocal,
input.contextWindow,
input.thinkingFormat,
Expand Down Expand Up @@ -1781,6 +1796,7 @@ async function main(): Promise<void> {
apiKey,
input.baseUrl,
input.provider,
input.providerMethod,
input.isLocal,
input.contextWindow,
input.thinkingFormat,
Expand Down
Loading
Loading