11// Openai provider module implements model/runtime integration.
22import type {
3- ProviderAuthMethod ,
43 ProviderResolveDynamicModelContext ,
54 ProviderRuntimeModel ,
65} from "openclaw/plugin-sdk/plugin-entry" ;
@@ -893,8 +892,8 @@ function resolveOpenAIGptForwardCompatModel(ctx: ProviderResolveDynamicModelCont
893892}
894893
895894export function buildOpenAIProvider ( ) : ProviderPlugin {
896- const provider = createOpenAIProvider ( ) ;
897- const apiKeyDefinition = provider . auth . find ( ( method ) => method . id === "api-key" ) ;
895+ const providerDefinition = createOpenAIProvider ( ) ;
896+ const apiKeyDefinition = providerDefinition . auth . find ( ( method ) => method . id === "api-key" ) ;
898897 if ( ! apiKeyDefinition ) {
899898 throw new Error ( "OpenAI provider contract is missing API-key auth" ) ;
900899 }
@@ -915,27 +914,24 @@ export function buildOpenAIProvider(): ProviderPlugin {
915914 applyConfig : ( cfg ) => applyOpenAIConfig ( cfg ) ,
916915 wizard : apiKeyDefinition . wizard ,
917916 } ) ;
918- const auth = provider . auth . map ( ( method ) : ProviderAuthMethod => {
917+ for ( const method of providerDefinition . auth ) {
919918 if ( method . id === "oauth" || method . id === "device-code" ) {
920- return { ...method , run : chatGPTAuthRuns [ method . id ] } ;
919+ method . run = chatGPTAuthRuns [ method . id ] ;
920+ continue ;
921921 }
922- if ( method . id === "api-key" ) {
923- return {
924- ...method ,
925- starterModel : apiKeyRuntime . starterModel ,
926- run : apiKeyRuntime . run ,
927- runNonInteractive : apiKeyRuntime . runNonInteractive ,
928- validateNonInteractive : apiKeyRuntime . validateNonInteractive ,
929- } ;
922+ if ( method . id !== "api-key" ) {
923+ throw new Error ( `OpenAI provider contract has unknown auth method: ${ method . id } ` ) ;
930924 }
931- throw new Error ( `OpenAI provider contract has unknown auth method: ${ method . id } ` ) ;
932- } ) ;
925+ method . starterModel = apiKeyRuntime . starterModel ;
926+ method . run = apiKeyRuntime . run ;
927+ method . runNonInteractive = apiKeyRuntime . runNonInteractive ;
928+ method . validateNonInteractive = apiKeyRuntime . validateNonInteractive ;
929+ }
933930 const codexHooks = buildOpenAICodexProviderHooks ( ) ;
934931 const nativeResponsesHooks = buildOpenAIResponsesProviderHooks ( ) ;
935932 const responsesHooks = buildOpenAIResponsesProviderHooks ( { transport : "sse" } ) ;
936933 return {
937- ...provider ,
938- auth,
934+ ...providerDefinition ,
939935 catalog : {
940936 order : "simple" ,
941937 run : async ( ctx ) => {
0 commit comments