diff --git a/src/globals.ts b/src/globals.ts index 4d6e327e4..e391479e4 100644 --- a/src/globals.ts +++ b/src/globals.ts @@ -113,6 +113,7 @@ export const ORACLE: string = 'oracle'; export const IO_INTELLIGENCE: string = 'iointelligence'; export const AIBADGR: string = 'aibadgr'; export const OVHCLOUD: string = 'ovhcloud'; +export const GONKAROUTER: string = 'gonkarouter'; export const VALID_PROVIDERS = [ ANTHROPIC, @@ -189,6 +190,7 @@ export const VALID_PROVIDERS = [ IO_INTELLIGENCE, AIBADGR, OVHCLOUD, + GONKAROUTER, ]; export const CONTENT_TYPES = { diff --git a/src/providers/gonkarouter/api.ts b/src/providers/gonkarouter/api.ts new file mode 100644 index 000000000..423080a0d --- /dev/null +++ b/src/providers/gonkarouter/api.ts @@ -0,0 +1,24 @@ +import { ProviderAPIConfig } from '../types'; + +export const GonkaRouterAPIConfig: ProviderAPIConfig = { + getBaseURL: () => `https://api.gonkarouter.io/v1`, + headers({ providerOptions }) { + const { apiKey } = providerOptions; + const headers = { + Authorization: `Bearer ${apiKey}`, + }; + return headers; + }, + getEndpoint({ fn }) { + switch (fn) { + case 'chatComplete': { + return '/chat/completions'; + } + case 'complete': { + return '/completions'; + } + default: + return ''; + } + }, +}; diff --git a/src/providers/gonkarouter/index.ts b/src/providers/gonkarouter/index.ts new file mode 100644 index 000000000..711d42a59 --- /dev/null +++ b/src/providers/gonkarouter/index.ts @@ -0,0 +1,21 @@ +import { GONKAROUTER } from '../../globals'; +import { + chatCompleteParams, + completeParams, + responseTransformers, +} from '../open-ai-base'; +import { ProviderConfigs } from '../types'; +import { GonkaRouterAPIConfig } from './api'; + +export const GonkaRouterProviderConfig: ProviderConfigs = { + // Pure pass-through: do not bake in a default model. Clear the inherited + // OpenAI base default ('gpt-3.5-turbo') so an omitted model surfaces a clean + // "model required" error from GonkaRouter instead of routing to a phantom model. + chatComplete: chatCompleteParams([], { model: undefined }), + complete: completeParams([]), + api: GonkaRouterAPIConfig, + responseTransforms: responseTransformers(GONKAROUTER, { + chatComplete: true, + complete: true, + }), +}; diff --git a/src/providers/index.ts b/src/providers/index.ts index 2cd5355f8..217dd7ad7 100644 --- a/src/providers/index.ts +++ b/src/providers/index.ts @@ -74,6 +74,8 @@ import OracleConfig from './oracle'; import IOIntelligenceConfig from './iointelligence'; import AIBadgrConfig from './aibadgr'; import OVHcloudConfig from './ovhcloud'; +import { GONKAROUTER } from '../globals'; +import { GonkaRouterProviderConfig } from './gonkarouter'; const Providers: { [key: string]: ProviderConfigs } = { openai: OpenAIConfig, @@ -148,6 +150,7 @@ const Providers: { [key: string]: ProviderConfigs } = { iointelligence: IOIntelligenceConfig, aibadgr: AIBadgrConfig, ovhcloud: OVHcloudConfig, + [GONKAROUTER]: GonkaRouterProviderConfig, }; export default Providers;