@adaline/openai 1.18.1 → 1.18.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2,17 +2,17 @@ import { z } from 'zod';
2
2
  import { RangeConfigItem, CHAT_CONFIG, SelectBooleanConfigItem, SelectStringConfigItem, ObjectSchemaConfigItem, ChatModelSchema, EmbeddingModelSchema, MultiStringConfigItem, ProviderError, urlWithoutTrailingSlash, InvalidModelRequestError, removeUndefinedEntries, getMimeTypeFromBase64, InvalidConfigError, InvalidMessagesError, InvalidToolsError, ModelResponseError, InvalidEmbeddingRequestsError } from '@adaline/provider';
3
3
  import { ResponseSchema, SystemRoleLiteral, UserRoleLiteral, AssistantRoleLiteral, ToolRoleLiteral, TextModalityLiteral, ImageModalityLiteral, ToolCallModalityLiteral, ToolResponseModalityLiteral, EmbeddingTextModalityLiteral, EmbeddingTokenModalityLiteral, Config, Base64ImageContentTypeLiteral, UrlImageContentTypeLiteral, Message, Tool, createTextContent, createToolCallContent, EmbeddingRequests, Base64EmbeddingLiteral, FloatEmbeddingLiteral, createPartialTextMessage, createPartialToolCallMessage } from '@adaline/types';
4
4
 
5
- var ii=Object.defineProperty,ai=Object.defineProperties;var ri=Object.getOwnPropertyDescriptors;var xn=Object.getOwnPropertySymbols;var li=Object.prototype.hasOwnProperty,pi=Object.prototype.propertyIsEnumerable;var ye=(i,e)=>(e=Symbol[i])?e:Symbol.for("Symbol."+i),mi=i=>{throw TypeError(i)};var Sn=(i,e,s)=>e in i?ii(i,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[e]=s,b=(i,e)=>{for(var s in e||(e={}))li.call(e,s)&&Sn(i,s,e[s]);if(xn)for(var s of xn(e))pi.call(e,s)&&Sn(i,s,e[s]);return i},q=(i,e)=>ai(i,ri(e));var k=(i,e,s)=>new Promise((o,t)=>{var n=p=>{try{l(s.next(p));}catch(_){t(_);}},r=p=>{try{l(s.throw(p));}catch(_){t(_);}},l=p=>p.done?o(p.value):Promise.resolve(p.value).then(n,r);l((s=s.apply(i,e)).next());}),In=function(i,e){this[0]=i,this[1]=e;},ie=(i,e,s)=>{var o=(r,l,p,_)=>{try{var T=s[r](l),x=(l=T.value)instanceof In,O=T.done;Promise.resolve(x?l[0]:l).then(I=>x?o(r==="return"?r:"next",l[1]?{done:I.done,value:I.value}:I,p,_):p({value:I,done:O})).catch(I=>o("throw",I,p,_));}catch(I){_(I);}},t=r=>n[r]=l=>new Promise((p,_)=>o(r,l,p,_)),n={};return s=s.apply(i,e),n[ye("asyncIterator")]=()=>n,t("next"),t("throw"),t("return"),n},Me=i=>{var e=i[ye("asyncIterator")],s=!1,o,t={};return e==null?(e=i[ye("iterator")](),o=n=>t[n]=r=>e[n](r)):(e=e.call(i),o=n=>t[n]=r=>{if(s){if(s=!1,n==="throw")throw r;return r}return s=!0,{done:!1,value:new In(new Promise(l=>{var p=e[n](r);p instanceof Object||mi("Object expected"),l(p);}),1)}}),t[ye("iterator")]=()=>t,o("next"),"throw"in e?o("throw"):t.throw=n=>{throw n},"return"in e&&o("return"),t};var Xo=RangeConfigItem({param:"temperature",title:CHAT_CONFIG.TEMPERATURE.title,description:CHAT_CONFIG.TEMPERATURE.description,min:0,max:2,step:.01,default:1}),Zo=i=>RangeConfigItem({param:"max_completion_tokens",title:CHAT_CONFIG.MAX_TOKENS.title,description:CHAT_CONFIG.MAX_TOKENS.description,min:0,max:i,step:1,default:0}),et=i=>MultiStringConfigItem({param:"stop",title:CHAT_CONFIG.STOP(i).title,description:CHAT_CONFIG.STOP(i).description,max:i}),ot=RangeConfigItem({param:"top_p",title:CHAT_CONFIG.TOP_P.title,description:CHAT_CONFIG.TOP_P.description,min:0,max:1,step:.01,default:1}),tt=RangeConfigItem({param:"frequency_penalty",title:CHAT_CONFIG.FREQUENCY_PENALTY.title,description:CHAT_CONFIG.FREQUENCY_PENALTY.description,min:-2,max:2,step:.01,default:0}),nt=RangeConfigItem({param:"presence_penalty",title:CHAT_CONFIG.PRESENCE_PENALTY.title,description:CHAT_CONFIG.PRESENCE_PENALTY.description,min:-2,max:2,step:.01,default:0}),st=RangeConfigItem({param:"seed",title:CHAT_CONFIG.SEED.title,description:CHAT_CONFIG.SEED.description,min:0,max:1e6,step:1,default:0}),it=SelectBooleanConfigItem({param:"logprobs",title:CHAT_CONFIG.LOG_PROBS.title,description:CHAT_CONFIG.LOG_PROBS.description,default:!1}),at=RangeConfigItem({param:"top_logprobs",title:CHAT_CONFIG.TOP_LOG_PROBS.title,description:CHAT_CONFIG.TOP_LOG_PROBS.description,min:0,max:20,step:1,default:0}),rt=SelectStringConfigItem({param:"tool_choice",title:"Tool choice",description:"Controls which (if any) tool is called by the model. 'none' means the model will not call a function. 'auto' means the model can pick between generating a message or calling a tool.",default:"auto",choices:["auto","required","none"]}),lt=SelectStringConfigItem({param:"reasoning_effort",title:"Reasoning Effort",description:"Controls the depth of the model's reasoning before delivering an answer. 'minimal' prioritizes speed, 'high' engages in deep reasoning.",default:"medium",choices:["minimal","low","medium","high"]}),pt=SelectStringConfigItem({param:"verbosity",title:"Verbosity",description:"Controls the length and detail of the model's responses, independent of reasoning depth. 'low' generates concise answers, 'high' provides comprehensive responses.",default:"medium",choices:["low","medium","high"]});var Y=(i,e)=>z.object({temperature:Xo.schema,maxTokens:Zo(i).schema,stop:et(e).schema,topP:ot.schema,frequencyPenalty:tt.schema,presencePenalty:nt.schema,seed:st.schema.transform(s=>s===0?void 0:s),logProbs:it.schema,topLogProbs:at.schema,toolChoice:rt.schema}),Q=(i,e)=>({temperature:Xo.def,maxTokens:Zo(i).def,stop:et(e).def,topP:ot.def,frequencyPenalty:tt.def,presencePenalty:nt.def,seed:st.def,logProbs:it.def,topLogProbs:at.def,toolChoice:rt.def});var Rn=ObjectSchemaConfigItem({param:"response_schema",title:CHAT_CONFIG.RESPONSE_SCHEMA.title,description:CHAT_CONFIG.RESPONSE_SCHEMA.description,objectSchema:ResponseSchema}),An=SelectStringConfigItem({param:"response_format",title:CHAT_CONFIG.RESPONSE_FORMAT_WITH_SCHEMA.title,description:CHAT_CONFIG.RESPONSE_FORMAT_WITH_SCHEMA.description,default:"text",choices:["text","json_object","json_schema"]}),X=(i,e)=>q(b({},Q(i,e)),{responseFormat:An.def,responseSchema:Rn.def}),Z=(i,e)=>Y(i,e).extend({responseFormat:An.schema,responseSchema:Rn.schema});var Gn=(i,e)=>q(b({},Q(i,e)),{reasoningEffort:lt.def,verbosity:pt.def,responseFormat:X(i,e).responseFormat,responseSchema:X(i,e).responseSchema}),En=(i,e)=>Y(i,e).extend({reasoningEffort:lt.schema,verbosity:pt.schema,responseFormat:Z(i,e).shape.responseFormat,responseSchema:Z(i,e).shape.responseSchema});var wn=RangeConfigItem({param:"temperature",title:CHAT_CONFIG.TEMPERATURE.title,description:CHAT_CONFIG.TEMPERATURE.description,min:0,max:2,step:.01,default:1}),vn=RangeConfigItem({param:"temperature",title:CHAT_CONFIG.TEMPERATURE.title,description:CHAT_CONFIG.TEMPERATURE.description,min:1,max:1,step:.01,default:1}),Pe=SelectStringConfigItem({param:"reasoning_effort",title:"Reasoning Effort",description:"Constrains effort on reasoning for reasoning models. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.",default:"medium",choices:["low","medium","high"]}),Ln=(i,e)=>q(b({},X(i,e)),{temperature:wn.def,reasoningEffort:Pe.def}),Dn=(i,e)=>Z(i,e).extend({temperature:wn.schema,reasoningEffort:Pe.schema}),Nn=(i,e)=>q(b({},X(i,e)),{temperature:vn.def,reasoningEffort:Pe.def}),qn=(i,e)=>Z(i,e).extend({temperature:vn.schema,reasoningEffort:Pe.schema});var Bn=SelectStringConfigItem({param:"response_format",title:CHAT_CONFIG.RESPONSE_FORMAT.title,description:CHAT_CONFIG.RESPONSE_FORMAT.description,default:"text",choices:["text","json_object"]}),Un=(i,e)=>q(b({},Q(i,e)),{responseFormat:Bn.def}),jn=(i,e)=>Y(i,e).extend({responseFormat:Bn.schema});var mt=SelectStringConfigItem({param:"encoding_format",title:"Encoding format",description:"Select the encoding format for the word embedding.",default:"float",choices:["float","base64"]}),dt=i=>RangeConfigItem({param:"dimensions",title:"Dimensions",description:"Select the number of dimensions for the word embedding.",min:1,max:i,step:1,default:i});var be=()=>z.object({encodingFormat:mt.schema}),xe=()=>({encodingFormat:mt.def});var $n=i=>be().extend({dimensions:dt(i).schema}),Fn=i=>q(b({},xe()),{dimensions:dt(i).def});var a={base:(i,e)=>({def:Q(i,e),schema:Y(i,e)}),responseFormat:(i,e)=>({def:Un(i,e),schema:jn(i,e)}),responseSchema:(i,e)=>({def:X(i,e),schema:Z(i,e)}),oSeries:(i,e)=>({def:Ln(i,e),schema:Dn(i,e)}),o1Series:(i,e)=>({def:Nn(i,e),schema:qn(i,e)}),gpt5:(i,e)=>({def:Gn(i,e),schema:En(i,e)})},J={base:()=>({def:xe(),schema:be()}),dimensions:i=>({def:Fn(i),schema:$n(i)})};var f={"gpt-3.5-turbo-0125":{modelName:"gpt-3.5-turbo-0125",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gpt-3.5-turbo-1106":{modelName:"gpt-3.5-turbo-1106",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gpt-3.5-turbo":{modelName:"gpt-3.5-turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gpt-4-0125-preview":{modelName:"gpt-4-0125-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:30,outputPricePerMillion:60}}}]},"gpt-4-0613":{modelName:"gpt-4-0613",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:30,outputPricePerMillion:60}}}]},"gpt-4-1106-preview":{modelName:"gpt-4-1106-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:30,outputPricePerMillion:60}}}]},"gpt-4-turbo-2024-04-09":{modelName:"gpt-4-turbo-2024-04-09",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:10,outputPricePerMillion:30}}}]},"gpt-4-turbo-preview":{modelName:"gpt-4-turbo-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:10,outputPricePerMillion:30}}}]},"gpt-4-turbo":{modelName:"gpt-4-turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:10,outputPricePerMillion:30}}}]},"gpt-4":{modelName:"gpt-4",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:30,outputPricePerMillion:60}}}]},"gpt-4o-2024-05-13":{modelName:"gpt-4o-2024-05-13",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:5,outputPricePerMillion:20}}}]},"gpt-4o-2024-08-06":{modelName:"gpt-4o-2024-08-06",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gpt-4o-mini-2024-07-18":{modelName:"gpt-4o-mini-2024-07-18",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.6,outputPricePerMillion:2.4}}}]},"gpt-4o-mini":{modelName:"gpt-4o-mini",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.6,outputPricePerMillion:2.4}}}]},"gpt-4o":{modelName:"gpt-4o",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:5,outputPricePerMillion:20}}}]},"chatgpt-4o-latest":{modelName:"chatgpt-4o-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:5,outputPricePerMillion:15}}}]},"o1-2024-12-17":{modelName:"o1-2024-12-17",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:15,outputPricePerMillion:60}}}]},o1:{modelName:"o1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:15,outputPricePerMillion:60}}}]},"o3-mini-2025-01-31":{modelName:"o3-mini-2025-01-31",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.1,outputPricePerMillion:4.4}}}]},"o3-mini":{modelName:"o3-mini",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.1,outputPricePerMillion:4.4}}}]},"o3-2025-04-16":{modelName:"o3-2025-04-16",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:10,outputPricePerMillion:40}}}]},o3:{modelName:"o3",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:10,outputPricePerMillion:40}}}]},"o4-mini-2025-04-16":{modelName:"o4-mini-2025-04-16",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.1,outputPricePerMillion:4.4}}}]},"o4-mini":{modelName:"o4-mini",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.1,outputPricePerMillion:4.4}}}]},"gpt-4.1":{modelName:"gpt-4.1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:2,outputPricePerMillion:8}}}]},"gpt-4.1-mini":{modelName:"gpt-4.1-mini",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.4,outputPricePerMillion:1.6}}}]},"gpt-4.1-nano":{modelName:"gpt-4.1-nano",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gpt-5":{modelName:"gpt-5",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gpt-5-mini":{modelName:"gpt-5-mini",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.25,outputPricePerMillion:2}}}]},"gpt-5-nano":{modelName:"gpt-5-nano",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.05,outputPricePerMillion:.4}}}]},"gpt-5-chat-latest":{modelName:"gpt-5-chat-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gpt-5.1":{modelName:"gpt-5.1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.5,outputPricePerMillion:12}}}]},"gpt-5.2":{modelName:"gpt-5.2",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.75,outputPricePerMillion:14}}}]},"gpt-5.2-codex":{modelName:"gpt-5.2-codex",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.75,outputPricePerMillion:14}}}]},"gpt-5.2-chat-latest":{modelName:"gpt-5.2-chat-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.75,outputPricePerMillion:14}}}]},"gpt-5.2-pro":{modelName:"gpt-5.2-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:21,outputPricePerMillion:168}}}]},"gpt-5.3-codex":{modelName:"gpt-5.3-codex",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:2.1,outputPricePerMillion:16.8}}}]}};var Pi="openai",K=class{constructor(){this.version="v1";this.name=Pi;this.chatModelFactories={[Ee]:{model:ke,modelOptions:Wn,modelSchema:_t},[Ie]:{model:Re,modelOptions:Jn,modelSchema:ut},[Ae]:{model:Ge,modelOptions:Kn,modelSchema:ft},[we]:{model:ve,modelOptions:Yn,modelSchema:gt},[Le]:{model:De,modelOptions:Qn,modelSchema:Tt},[Ne]:{model:qe,modelOptions:Xn,modelSchema:yt},[ze]:{model:Be,modelOptions:Zn,modelSchema:Mt},[Ue]:{model:je,modelOptions:es,modelSchema:Ct},[$e]:{model:Fe,modelOptions:os,modelSchema:Ot},[no]:{model:so,modelOptions:ls,modelSchema:At},[He]:{model:Ve,modelOptions:ts,modelSchema:Pt},[Je]:{model:Ke,modelOptions:ns,modelSchema:bt},[Qe]:{model:Xe,modelOptions:is,modelSchema:St},[ct]:{model:Se,modelOptions:Vn,modelSchema:ht},[Ze]:{model:eo,modelOptions:as,modelSchema:It},[We]:{model:Ye,modelOptions:ss,modelSchema:xt},[oo]:{model:to,modelOptions:rs,modelSchema:Rt},[io]:{model:ao,modelOptions:ps,modelSchema:Gt},[ro]:{model:lo,modelOptions:ms,modelSchema:Et},[po]:{model:mo,modelOptions:ds,modelSchema:kt},[co]:{model:ho,modelOptions:cs,modelSchema:wt},[uo]:{model:fo,modelOptions:hs,modelSchema:vt},[_o]:{model:go,modelOptions:us,modelSchema:Lt},[To]:{model:yo,modelOptions:fs,modelSchema:Dt},[Oo]:{model:Po,modelOptions:gs,modelSchema:qt},[So]:{model:Io,modelOptions:ys,modelSchema:Bt},[Ro]:{model:Ao,modelOptions:Ms,modelSchema:Ut},[Go]:{model:Eo,modelOptions:Cs,modelSchema:jt},[bo]:{model:xo,modelOptions:Ts,modelSchema:zt},[Mo]:{model:Co,modelOptions:_s,modelSchema:Nt},[vo]:{model:Lo,modelOptions:Ps,modelSchema:Ft},[ko]:{model:wo,modelOptions:Os,modelSchema:$t},[Qt]:{model:zo,modelOptions:Is,modelSchema:Xt},[Wt]:{model:qo,modelOptions:Ss,modelSchema:Yt},[Ht]:{model:Do,modelOptions:bs,modelSchema:Vt},[Jt]:{model:No,modelOptions:xs,modelSchema:Kt},[Zt]:{model:Bo,modelOptions:Rs,modelSchema:en},[on]:{model:Uo,modelOptions:As,modelSchema:tn}};this.embeddingModelFactories={[nn]:{model:jo,modelOptions:Gs,modelSchema:sn},[an]:{model:$o,modelOptions:Es,modelSchema:rn},[ln]:{model:Fo,modelOptions:ks,modelSchema:pn}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((e,s)=>(e[s]=this.chatModelFactories[s].modelSchema,e),{})}chatModel(e){let s=e.modelName;if(!(s in this.chatModelFactories))throw new ProviderError({info:`OpenAI chat model: ${s} not found`,cause:new Error(`OpenAI chat model: ${s} not found, available chat models:
5
+ var ii=Object.defineProperty,ai=Object.defineProperties;var ri=Object.getOwnPropertyDescriptors;var xn=Object.getOwnPropertySymbols;var li=Object.prototype.hasOwnProperty,pi=Object.prototype.propertyIsEnumerable;var ye=(i,e)=>(e=Symbol[i])?e:Symbol.for("Symbol."+i),mi=i=>{throw TypeError(i)};var Sn=(i,e,s)=>e in i?ii(i,e,{enumerable:true,configurable:true,writable:true,value:s}):i[e]=s,b=(i,e)=>{for(var s in e||(e={}))li.call(e,s)&&Sn(i,s,e[s]);if(xn)for(var s of xn(e))pi.call(e,s)&&Sn(i,s,e[s]);return i},q=(i,e)=>ai(i,ri(e));var k=(i,e,s)=>new Promise((o,t)=>{var n=p=>{try{l(s.next(p));}catch(_){t(_);}},r=p=>{try{l(s.throw(p));}catch(_){t(_);}},l=p=>p.done?o(p.value):Promise.resolve(p.value).then(n,r);l((s=s.apply(i,e)).next());}),In=function(i,e){this[0]=i,this[1]=e;},ie=(i,e,s)=>{var o=(r,l,p,_)=>{try{var T=s[r](l),x=(l=T.value)instanceof In,O=T.done;Promise.resolve(x?l[0]:l).then(I=>x?o(r==="return"?r:"next",l[1]?{done:I.done,value:I.value}:I,p,_):p({value:I,done:O})).catch(I=>o("throw",I,p,_));}catch(I){_(I);}},t=r=>n[r]=l=>new Promise((p,_)=>o(r,l,p,_)),n={};return s=s.apply(i,e),n[ye("asyncIterator")]=()=>n,t("next"),t("throw"),t("return"),n},Me=i=>{var e=i[ye("asyncIterator")],s=false,o,t={};return e==null?(e=i[ye("iterator")](),o=n=>t[n]=r=>e[n](r)):(e=e.call(i),o=n=>t[n]=r=>{if(s){if(s=false,n==="throw")throw r;return r}return s=true,{done:false,value:new In(new Promise(l=>{var p=e[n](r);p instanceof Object||mi("Object expected"),l(p);}),1)}}),t[ye("iterator")]=()=>t,o("next"),"throw"in e?o("throw"):t.throw=n=>{throw n},"return"in e&&o("return"),t};var Xo=RangeConfigItem({param:"temperature",title:CHAT_CONFIG.TEMPERATURE.title,description:CHAT_CONFIG.TEMPERATURE.description,min:0,max:2,step:.01,default:1}),Zo=i=>RangeConfigItem({param:"max_completion_tokens",title:CHAT_CONFIG.MAX_TOKENS.title,description:CHAT_CONFIG.MAX_TOKENS.description,min:0,max:i,step:1,default:0}),et=i=>MultiStringConfigItem({param:"stop",title:CHAT_CONFIG.STOP(i).title,description:CHAT_CONFIG.STOP(i).description,max:i}),ot=RangeConfigItem({param:"top_p",title:CHAT_CONFIG.TOP_P.title,description:CHAT_CONFIG.TOP_P.description,min:0,max:1,step:.01,default:1}),tt=RangeConfigItem({param:"frequency_penalty",title:CHAT_CONFIG.FREQUENCY_PENALTY.title,description:CHAT_CONFIG.FREQUENCY_PENALTY.description,min:-2,max:2,step:.01,default:0}),nt=RangeConfigItem({param:"presence_penalty",title:CHAT_CONFIG.PRESENCE_PENALTY.title,description:CHAT_CONFIG.PRESENCE_PENALTY.description,min:-2,max:2,step:.01,default:0}),st=RangeConfigItem({param:"seed",title:CHAT_CONFIG.SEED.title,description:CHAT_CONFIG.SEED.description,min:0,max:1e6,step:1,default:0}),it=SelectBooleanConfigItem({param:"logprobs",title:CHAT_CONFIG.LOG_PROBS.title,description:CHAT_CONFIG.LOG_PROBS.description,default:false}),at=RangeConfigItem({param:"top_logprobs",title:CHAT_CONFIG.TOP_LOG_PROBS.title,description:CHAT_CONFIG.TOP_LOG_PROBS.description,min:0,max:20,step:1,default:0}),rt=SelectStringConfigItem({param:"tool_choice",title:"Tool choice",description:"Controls which (if any) tool is called by the model. 'none' means the model will not call a function. 'auto' means the model can pick between generating a message or calling a tool.",default:"auto",choices:["auto","required","none"]}),lt=SelectStringConfigItem({param:"reasoning_effort",title:"Reasoning Effort",description:"Controls the depth of the model's reasoning before delivering an answer. 'minimal' prioritizes speed, 'high' engages in deep reasoning.",default:"medium",choices:["minimal","low","medium","high"]}),pt=SelectStringConfigItem({param:"verbosity",title:"Verbosity",description:"Controls the length and detail of the model's responses, independent of reasoning depth. 'low' generates concise answers, 'high' provides comprehensive responses.",default:"medium",choices:["low","medium","high"]});var Y=(i,e)=>z.object({temperature:Xo.schema,maxTokens:Zo(i).schema,stop:et(e).schema,topP:ot.schema,frequencyPenalty:tt.schema,presencePenalty:nt.schema,seed:st.schema.transform(s=>s===0?void 0:s),logProbs:it.schema,topLogProbs:at.schema,toolChoice:rt.schema}),Q=(i,e)=>({temperature:Xo.def,maxTokens:Zo(i).def,stop:et(e).def,topP:ot.def,frequencyPenalty:tt.def,presencePenalty:nt.def,seed:st.def,logProbs:it.def,topLogProbs:at.def,toolChoice:rt.def});var Rn=ObjectSchemaConfigItem({param:"response_schema",title:CHAT_CONFIG.RESPONSE_SCHEMA.title,description:CHAT_CONFIG.RESPONSE_SCHEMA.description,objectSchema:ResponseSchema}),An=SelectStringConfigItem({param:"response_format",title:CHAT_CONFIG.RESPONSE_FORMAT_WITH_SCHEMA.title,description:CHAT_CONFIG.RESPONSE_FORMAT_WITH_SCHEMA.description,default:"text",choices:["text","json_object","json_schema"]}),X=(i,e)=>q(b({},Q(i,e)),{responseFormat:An.def,responseSchema:Rn.def}),Z=(i,e)=>Y(i,e).extend({responseFormat:An.schema,responseSchema:Rn.schema});var Gn=(i,e)=>q(b({},Q(i,e)),{reasoningEffort:lt.def,verbosity:pt.def,responseFormat:X(i,e).responseFormat,responseSchema:X(i,e).responseSchema}),En=(i,e)=>Y(i,e).extend({reasoningEffort:lt.schema,verbosity:pt.schema,responseFormat:Z(i,e).shape.responseFormat,responseSchema:Z(i,e).shape.responseSchema});var wn=RangeConfigItem({param:"temperature",title:CHAT_CONFIG.TEMPERATURE.title,description:CHAT_CONFIG.TEMPERATURE.description,min:0,max:2,step:.01,default:1}),vn=RangeConfigItem({param:"temperature",title:CHAT_CONFIG.TEMPERATURE.title,description:CHAT_CONFIG.TEMPERATURE.description,min:1,max:1,step:.01,default:1}),Pe=SelectStringConfigItem({param:"reasoning_effort",title:"Reasoning Effort",description:"Constrains effort on reasoning for reasoning models. Reducing reasoning effort can result in faster responses and fewer tokens used on reasoning in a response.",default:"medium",choices:["low","medium","high"]}),Ln=(i,e)=>q(b({},X(i,e)),{temperature:wn.def,reasoningEffort:Pe.def}),Dn=(i,e)=>Z(i,e).extend({temperature:wn.schema,reasoningEffort:Pe.schema}),Nn=(i,e)=>q(b({},X(i,e)),{temperature:vn.def,reasoningEffort:Pe.def}),qn=(i,e)=>Z(i,e).extend({temperature:vn.schema,reasoningEffort:Pe.schema});var Bn=SelectStringConfigItem({param:"response_format",title:CHAT_CONFIG.RESPONSE_FORMAT.title,description:CHAT_CONFIG.RESPONSE_FORMAT.description,default:"text",choices:["text","json_object"]}),Un=(i,e)=>q(b({},Q(i,e)),{responseFormat:Bn.def}),jn=(i,e)=>Y(i,e).extend({responseFormat:Bn.schema});var mt=SelectStringConfigItem({param:"encoding_format",title:"Encoding format",description:"Select the encoding format for the word embedding.",default:"float",choices:["float","base64"]}),dt=i=>RangeConfigItem({param:"dimensions",title:"Dimensions",description:"Select the number of dimensions for the word embedding.",min:1,max:i,step:1,default:i});var be=()=>z.object({encodingFormat:mt.schema}),xe=()=>({encodingFormat:mt.def});var $n=i=>be().extend({dimensions:dt(i).schema}),Fn=i=>q(b({},xe()),{dimensions:dt(i).def});var a={base:(i,e)=>({def:Q(i,e),schema:Y(i,e)}),responseFormat:(i,e)=>({def:Un(i,e),schema:jn(i,e)}),responseSchema:(i,e)=>({def:X(i,e),schema:Z(i,e)}),oSeries:(i,e)=>({def:Ln(i,e),schema:Dn(i,e)}),o1Series:(i,e)=>({def:Nn(i,e),schema:qn(i,e)}),gpt5:(i,e)=>({def:Gn(i,e),schema:En(i,e)})},J={base:()=>({def:xe(),schema:be()}),dimensions:i=>({def:Fn(i),schema:$n(i)})};var f={"gpt-3.5-turbo-0125":{modelName:"gpt-3.5-turbo-0125",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gpt-3.5-turbo-1106":{modelName:"gpt-3.5-turbo-1106",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gpt-3.5-turbo":{modelName:"gpt-3.5-turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:1.5}}}]},"gpt-4-0125-preview":{modelName:"gpt-4-0125-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:30,outputPricePerMillion:60}}}]},"gpt-4-0613":{modelName:"gpt-4-0613",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:30,outputPricePerMillion:60}}}]},"gpt-4-1106-preview":{modelName:"gpt-4-1106-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:30,outputPricePerMillion:60}}}]},"gpt-4-turbo-2024-04-09":{modelName:"gpt-4-turbo-2024-04-09",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:10,outputPricePerMillion:30}}}]},"gpt-4-turbo-preview":{modelName:"gpt-4-turbo-preview",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:10,outputPricePerMillion:30}}}]},"gpt-4-turbo":{modelName:"gpt-4-turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:10,outputPricePerMillion:30}}}]},"gpt-4":{modelName:"gpt-4",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:30,outputPricePerMillion:60}}}]},"gpt-4o-2024-05-13":{modelName:"gpt-4o-2024-05-13",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:5,outputPricePerMillion:20}}}]},"gpt-4o-2024-08-06":{modelName:"gpt-4o-2024-08-06",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:2.5,outputPricePerMillion:10}}}]},"gpt-4o-mini-2024-07-18":{modelName:"gpt-4o-mini-2024-07-18",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.6,outputPricePerMillion:2.4}}}]},"gpt-4o-mini":{modelName:"gpt-4o-mini",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.6,outputPricePerMillion:2.4}}}]},"gpt-4o":{modelName:"gpt-4o",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:5,outputPricePerMillion:20}}}]},"chatgpt-4o-latest":{modelName:"chatgpt-4o-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:5,outputPricePerMillion:15}}}]},"o1-2024-12-17":{modelName:"o1-2024-12-17",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:15,outputPricePerMillion:60}}}]},o1:{modelName:"o1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:15,outputPricePerMillion:60}}}]},"o3-mini-2025-01-31":{modelName:"o3-mini-2025-01-31",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.1,outputPricePerMillion:4.4}}}]},"o3-mini":{modelName:"o3-mini",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.1,outputPricePerMillion:4.4}}}]},"o3-2025-04-16":{modelName:"o3-2025-04-16",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:10,outputPricePerMillion:40}}}]},o3:{modelName:"o3",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:10,outputPricePerMillion:40}}}]},"o4-mini-2025-04-16":{modelName:"o4-mini-2025-04-16",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.1,outputPricePerMillion:4.4}}}]},"o4-mini":{modelName:"o4-mini",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.1,outputPricePerMillion:4.4}}}]},"gpt-4.1":{modelName:"gpt-4.1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:2,outputPricePerMillion:8}}}]},"gpt-4.1-mini":{modelName:"gpt-4.1-mini",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.4,outputPricePerMillion:1.6}}}]},"gpt-4.1-nano":{modelName:"gpt-4.1-nano",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.4}}}]},"gpt-5":{modelName:"gpt-5",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gpt-5-mini":{modelName:"gpt-5-mini",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.25,outputPricePerMillion:2}}}]},"gpt-5-nano":{modelName:"gpt-5-nano",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.05,outputPricePerMillion:.4}}}]},"gpt-5-chat-latest":{modelName:"gpt-5-chat-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:10}}}]},"gpt-5.1":{modelName:"gpt-5.1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.5,outputPricePerMillion:12}}}]},"gpt-5.2":{modelName:"gpt-5.2",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.75,outputPricePerMillion:14}}}]},"gpt-5.2-codex":{modelName:"gpt-5.2-codex",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.75,outputPricePerMillion:14}}}]},"gpt-5.2-chat-latest":{modelName:"gpt-5.2-chat-latest",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.75,outputPricePerMillion:14}}}]},"gpt-5.2-pro":{modelName:"gpt-5.2-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:21,outputPricePerMillion:168}}}]},"gpt-5.3-codex":{modelName:"gpt-5.3-codex",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:2.1,outputPricePerMillion:16.8}}}]}};var Pi="openai",K=class{constructor(){this.version="v1";this.name=Pi;this.chatModelFactories={[Ee]:{model:ke,modelOptions:Wn,modelSchema:_t},[Ie]:{model:Re,modelOptions:Jn,modelSchema:ut},[Ae]:{model:Ge,modelOptions:Kn,modelSchema:ft},[we]:{model:ve,modelOptions:Yn,modelSchema:gt},[Le]:{model:De,modelOptions:Qn,modelSchema:Tt},[Ne]:{model:qe,modelOptions:Xn,modelSchema:yt},[ze]:{model:Be,modelOptions:Zn,modelSchema:Mt},[Ue]:{model:je,modelOptions:es,modelSchema:Ct},[$e]:{model:Fe,modelOptions:os,modelSchema:Ot},[no]:{model:so,modelOptions:ls,modelSchema:At},[He]:{model:Ve,modelOptions:ts,modelSchema:Pt},[Je]:{model:Ke,modelOptions:ns,modelSchema:bt},[Qe]:{model:Xe,modelOptions:is,modelSchema:St},[ct]:{model:Se,modelOptions:Vn,modelSchema:ht},[Ze]:{model:eo,modelOptions:as,modelSchema:It},[We]:{model:Ye,modelOptions:ss,modelSchema:xt},[oo]:{model:to,modelOptions:rs,modelSchema:Rt},[io]:{model:ao,modelOptions:ps,modelSchema:Gt},[ro]:{model:lo,modelOptions:ms,modelSchema:Et},[po]:{model:mo,modelOptions:ds,modelSchema:kt},[co]:{model:ho,modelOptions:cs,modelSchema:wt},[uo]:{model:fo,modelOptions:hs,modelSchema:vt},[_o]:{model:go,modelOptions:us,modelSchema:Lt},[To]:{model:yo,modelOptions:fs,modelSchema:Dt},[Oo]:{model:Po,modelOptions:gs,modelSchema:qt},[So]:{model:Io,modelOptions:ys,modelSchema:Bt},[Ro]:{model:Ao,modelOptions:Ms,modelSchema:Ut},[Go]:{model:Eo,modelOptions:Cs,modelSchema:jt},[bo]:{model:xo,modelOptions:Ts,modelSchema:zt},[Mo]:{model:Co,modelOptions:_s,modelSchema:Nt},[vo]:{model:Lo,modelOptions:Ps,modelSchema:Ft},[ko]:{model:wo,modelOptions:Os,modelSchema:$t},[Qt]:{model:zo,modelOptions:Is,modelSchema:Xt},[Wt]:{model:qo,modelOptions:Ss,modelSchema:Yt},[Ht]:{model:Do,modelOptions:bs,modelSchema:Vt},[Jt]:{model:No,modelOptions:xs,modelSchema:Kt},[Zt]:{model:Bo,modelOptions:Rs,modelSchema:en},[on]:{model:Uo,modelOptions:As,modelSchema:tn}};this.embeddingModelFactories={[nn]:{model:jo,modelOptions:Gs,modelSchema:sn},[an]:{model:$o,modelOptions:Es,modelSchema:rn},[ln]:{model:Fo,modelOptions:ks,modelSchema:pn}};}chatModelLiterals(){return Object.keys(this.chatModelFactories)}chatModelSchemas(){return Object.keys(this.chatModelFactories).reduce((e,s)=>(e[s]=this.chatModelFactories[s].modelSchema,e),{})}chatModel(e){let s=e.modelName;if(!(s in this.chatModelFactories))throw new ProviderError({info:`OpenAI chat model: ${s} not found`,cause:new Error(`OpenAI chat model: ${s} not found, available chat models:
6
6
  [${this.chatModelLiterals().join(", ")}]`)});let o=this.chatModelFactories[s].model,t=this.chatModelFactories[s].modelOptions.parse(e);return new o(t)}embeddingModelLiterals(){return Object.keys(this.embeddingModelFactories)}embeddingModelSchemas(){return Object.keys(this.embeddingModelFactories).reduce((e,s)=>(e[s]=this.embeddingModelFactories[s].modelSchema,e),{})}embeddingModel(e){let s=e.modelName;if(!(s in this.embeddingModelFactories))throw new ProviderError({info:`OpenAI embedding model: ${s} not found`,cause:new Error(`OpenAI embedding model: ${s} not found, available embedding models:
7
- [${this.embeddingModelLiterals().join(", ")}]`)});let o=this.embeddingModelFactories[s].model,t=this.embeddingModelFactories[s].modelOptions.parse(e);return new o(t)}};K.baseUrl="https://api.openai.com/v1";var m=z.enum([SystemRoleLiteral,UserRoleLiteral,AssistantRoleLiteral,ToolRoleLiteral]),d={system:SystemRoleLiteral,user:UserRoleLiteral,assistant:AssistantRoleLiteral,tool:ToolRoleLiteral};var y=[TextModalityLiteral,ImageModalityLiteral,ToolCallModalityLiteral,ToolResponseModalityLiteral],M=z.enum([TextModalityLiteral,ImageModalityLiteral,ToolCallModalityLiteral,ToolResponseModalityLiteral]),Jl=[TextModalityLiteral],Kl=z.enum([TextModalityLiteral]),w=[TextModalityLiteral,ToolCallModalityLiteral,ToolResponseModalityLiteral],v=z.enum([TextModalityLiteral,ToolCallModalityLiteral,ToolResponseModalityLiteral]);var Jo=z.object({token:z.string(),logprob:z.number(),bytes:z.array(z.number()).nullable()}),qs=z.object({content:z.array(Jo.extend({top_logprobs:z.array(Jo)})).nullable().optional(),refusal:z.array(Jo.extend({top_logprobs:z.array(Jo)})).nullable().optional()}).nullable(),xi=z.array(z.object({id:z.string().min(1),type:z.enum(["function"]),function:z.object({name:z.string(),arguments:z.string()})})),zs=z.object({id:z.string(),object:z.literal("chat.completion"),created:z.number(),model:z.string(),system_fingerprint:z.string().nullable(),choices:z.array(z.object({index:z.number(),message:z.object({role:z.string(),content:z.string().nullable().optional(),tool_calls:xi.optional(),refusal:z.string().nullable().optional()}),logprobs:qs.optional(),finish_reason:z.string()})),usage:z.object({prompt_tokens:z.number(),completion_tokens:z.number(),total_tokens:z.number()})}),Si=z.array(z.object({index:z.number().int(),id:z.string().min(1).optional(),type:z.enum(["function"]).optional(),function:z.object({name:z.string().min(1).optional(),arguments:z.string().optional()}).optional()})),Bs=z.object({id:z.string(),object:z.string(),created:z.number(),model:z.string(),system_fingerprint:z.string().nullable().optional(),choices:z.array(z.object({index:z.number(),delta:z.object({content:z.string().nullable().optional(),tool_calls:Si.optional(),refusal:z.string().nullable().optional()}).or(z.object({})),logprobs:qs.optional(),finish_reason:z.string().nullable()})),usage:z.object({prompt_tokens:z.number(),completion_tokens:z.number(),total_tokens:z.number()}).nullable().optional()});var Ii=z.object({type:z.literal("function"),function:z.object({name:z.string().min(1),description:z.string().min(1).optional(),strict:z.boolean().optional(),parameters:z.any()})}),Ri=z.enum(["none","auto","required"]),Ai=z.object({type:z.literal("function"),function:z.object({name:z.string().min(1)})}),Gi=z.object({type:z.enum(["text","json_object"])}).or(z.object({type:z.literal("json_schema"),json_schema:z.object({name:z.string().min(1),description:z.string().min(1).optional(),strict:z.boolean().optional(),schema:z.any()})})),dn=z.object({text:z.string().min(1),type:z.literal("text")}),Ei=z.object({type:z.literal("image_url"),image_url:z.object({url:z.string().url().min(1),detail:z.enum(["low","high","auto"]).optional()})}),ki=z.object({id:z.string().min(1),type:z.literal("function"),function:z.object({name:z.string().min(1),arguments:z.string().min(1)})}),wi=z.object({role:z.literal("system"),content:z.string().min(1).or(z.array(dn).min(1))}),vi=z.object({role:z.literal("user"),content:z.string().min(1).or(z.array(z.union([dn,Ei])).min(1))}),Li=z.object({role:z.literal("assistant"),content:z.string().min(1).or(z.array(dn).min(1)).optional(),tool_calls:z.array(ki).min(1).optional()}),Di=z.object({role:z.literal("tool"),tool_call_id:z.string().min(1),content:z.string().min(1)}),Ni=z.union([wi,vi,Li,Di]),Us=z.object({model:z.string().min(1).optional(),messages:z.array(Ni).min(1),frequency_penalty:z.number().min(-2).max(2).nullable().optional(),logprobs:z.boolean().nullable().optional(),top_logprobs:z.number().min(0).max(20).nullable().optional(),max_completion_tokens:z.number().min(0).nullable().optional(),presence_penalty:z.number().min(-2).max(2).nullable().optional(),response_format:Gi.optional(),seed:z.number().nullable().optional(),stop:z.string().or(z.array(z.string()).max(4)).nullable().optional(),temperature:z.number().min(0).max(2).nullable().optional(),top_p:z.number().min(0).max(1).nullable().optional(),tools:z.array(Ii).optional(),tool_choice:Ri.or(Ai).optional(),reasoning_effort:z.enum(["minimal","low","medium","high"]).optional(),verbosity:z.enum(["low","medium","high"]).optional()});var h=z.object({modelName:z.string(),apiKey:z.string(),baseUrl:z.string().url().optional(),completeChatUrl:z.string().url().optional(),streamChatUrl:z.string().url().optional(),organization:z.string().optional()}),c=class{constructor(e,s){this.version="v1";let o=h.parse(s);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=urlWithoutTrailingSlash(o.baseUrl||K.baseUrl),this.streamChatUrl=urlWithoutTrailingSlash(o.streamChatUrl||`${this.baseUrl}/chat/completions`),this.completeChatUrl=urlWithoutTrailingSlash(o.completeChatUrl||`${this.baseUrl}/chat/completions`),this.organization=o.organization;}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return b({Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},this.organization?{"OpenAI-Organization":this.organization}:{})}getDefaultParams(){return {model:this.modelName}}getRetryDelay(e,s){let o=p=>{let _=/(\d+)(h|m|s|ms)/g,T={h:36e5,m:6e4,s:1e3,ms:1},x,O=0;for(;(x=_.exec(p))!==null;){let I=parseInt(x[1]),R=x[2];O+=I*T[R];}return O},t=0,n=0,r=!0;e["x-ratelimit-reset-requests"]&&(t=o(e["x-ratelimit-reset-requests"])),e["x-ratelimit-reset-tokens"]&&(n=o(e["x-ratelimit-reset-tokens"]));let l=Math.max(t,n);return {shouldRetry:r,delayMs:l}}getTokenCount(e){return e.reduce((s,o)=>s+o.content.map(t=>t.modality==="text"?t.value:"").join(" ").length,0)}transformModelRequest(e){let s=Us.safeParse(e);if(!s.success)throw new InvalidModelRequestError({info:"Invalid model request",cause:s.error});let o=s.data,t=o.model;if(o.tool_choice&&(!o.tools||o.tools.length===0))throw new InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let n={};o.response_format&&(n.responseFormat=o.response_format.type,o.response_format.type==="json_schema"&&(n.responseSchema={name:o.response_format.json_schema.name,description:o.response_format.json_schema.description||"",strict:o.response_format.json_schema.strict,schema:o.response_format.json_schema.schema})),o.tool_choice&&(typeof o.tool_choice=="string"?n.toolChoice=o.tool_choice:n.toolChoice=o.tool_choice.function.name),n.seed=o.seed,n.maxTokens=o.max_completion_tokens,n.temperature=o.temperature,n.topP=o.top_p,n.presencePenalty=o.presence_penalty,n.frequencyPenalty=o.frequency_penalty,n.stop=o.stop,n.logProbs=o.logprobs,n.topLogProbs=o.top_logprobs,n.reasoningEffort=o.reasoning_effort,n.verbosity=o.verbosity;let r=Config().parse(removeUndefinedEntries(n)),l=[],p={};o.messages.forEach(T=>{let x=T.role;switch(x){case"system":{let O=T.content;if(typeof O=="string")l.push({role:x,content:[{modality:TextModalityLiteral,value:O}]});else {let I=O.map(R=>({modality:TextModalityLiteral,value:R.text}));l.push({role:x,content:I});}}break;case"user":{let O=T.content;if(typeof O=="string")l.push({role:x,content:[{modality:TextModalityLiteral,value:O}]});else {let I=O.map(R=>R.type==="text"?{modality:TextModalityLiteral,value:R.text}:R.image_url.url.startsWith("data:")?{modality:ImageModalityLiteral,detail:R.image_url.detail||"auto",value:{type:Base64ImageContentTypeLiteral,base64:R.image_url.url,mediaType:getMimeTypeFromBase64(R.image_url.url)}}:{modality:ImageModalityLiteral,detail:R.image_url.detail||"auto",value:{type:UrlImageContentTypeLiteral,url:R.image_url.url}});l.push({role:x,content:I});}}break;case"assistant":{let O=[];if(!T.content&&!T.tool_calls)throw new InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("one of'content' or 'tool_calls' must be provided")});if(T.content){let I=T.content;typeof I=="string"?O.push({modality:TextModalityLiteral,value:I}):I.forEach(R=>{O.push({modality:TextModalityLiteral,value:R.text});});}T.tool_calls&&T.tool_calls.forEach((R,L)=>{let S={modality:ToolCallModalityLiteral,id:R.id,index:L,name:R.function.name,arguments:R.function.arguments};O.push(S),p[S.id]=S;}),l.push({role:x,content:O});}break;case"tool":{let O=T;l.push({role:x,content:[{modality:ToolResponseModalityLiteral,id:O.tool_call_id,index:p[O.tool_call_id].index,name:p[O.tool_call_id].name,data:O.content}]});}break}});let _=[];return o.tools&&o.tools.forEach(T=>{_.push({type:"function",definition:{schema:{name:T.function.name,description:T.function.description||"",strict:T.function.strict,parameters:T.function.parameters}}});}),{modelName:t,config:r,messages:l,tools:_.length>0?_:void 0}}transformConfig(e,s,o){let t=e.toolChoice;delete e.toolChoice;let n=this.modelSchema.config.schema.safeParse(e);if(!n.success)throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:n.error});let r=n.data;t!==void 0&&(r.toolChoice=t),Object.keys(r).forEach(p=>{if(!(p in this.modelSchema.config.def))throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${p}',
7
+ [${this.embeddingModelLiterals().join(", ")}]`)});let o=this.embeddingModelFactories[s].model,t=this.embeddingModelFactories[s].modelOptions.parse(e);return new o(t)}};K.baseUrl="https://api.openai.com/v1";var m=z.enum([SystemRoleLiteral,UserRoleLiteral,AssistantRoleLiteral,ToolRoleLiteral]),d={system:SystemRoleLiteral,user:UserRoleLiteral,assistant:AssistantRoleLiteral,tool:ToolRoleLiteral};var y=[TextModalityLiteral,ImageModalityLiteral,ToolCallModalityLiteral,ToolResponseModalityLiteral],M=z.enum([TextModalityLiteral,ImageModalityLiteral,ToolCallModalityLiteral,ToolResponseModalityLiteral]),Jl=[TextModalityLiteral],Kl=z.enum([TextModalityLiteral]),w=[TextModalityLiteral,ToolCallModalityLiteral,ToolResponseModalityLiteral],v=z.enum([TextModalityLiteral,ToolCallModalityLiteral,ToolResponseModalityLiteral]);var Jo=z.object({token:z.string(),logprob:z.number(),bytes:z.array(z.number()).nullable()}),qs=z.object({content:z.array(Jo.extend({top_logprobs:z.array(Jo)})).nullable().optional(),refusal:z.array(Jo.extend({top_logprobs:z.array(Jo)})).nullable().optional()}).nullable(),xi=z.array(z.object({id:z.string().min(1),type:z.enum(["function"]),function:z.object({name:z.string(),arguments:z.string()})})),zs=z.object({id:z.string(),object:z.literal("chat.completion"),created:z.number(),model:z.string(),system_fingerprint:z.string().nullable(),choices:z.array(z.object({index:z.number(),message:z.object({role:z.string(),content:z.string().nullable().optional(),tool_calls:xi.optional(),refusal:z.string().nullable().optional()}),logprobs:qs.optional(),finish_reason:z.string()})),usage:z.object({prompt_tokens:z.number(),completion_tokens:z.number(),total_tokens:z.number()})}),Si=z.array(z.object({index:z.number().int(),id:z.string().min(1).optional(),type:z.enum(["function"]).optional(),function:z.object({name:z.string().min(1).optional(),arguments:z.string().optional()}).optional()})),Bs=z.object({id:z.string(),object:z.string(),created:z.number(),model:z.string(),system_fingerprint:z.string().nullable().optional(),choices:z.array(z.object({index:z.number(),delta:z.object({content:z.string().nullable().optional(),tool_calls:Si.optional(),refusal:z.string().nullable().optional()}).or(z.object({})),logprobs:qs.optional(),finish_reason:z.string().nullable()})),usage:z.object({prompt_tokens:z.number(),completion_tokens:z.number(),total_tokens:z.number()}).nullable().optional()});var Ii=z.object({type:z.literal("function"),function:z.object({name:z.string().min(1),description:z.string().min(1).optional(),strict:z.boolean().optional(),parameters:z.any()})}),Ri=z.enum(["none","auto","required"]),Ai=z.object({type:z.literal("function"),function:z.object({name:z.string().min(1)})}),Gi=z.object({type:z.enum(["text","json_object"])}).or(z.object({type:z.literal("json_schema"),json_schema:z.object({name:z.string().min(1),description:z.string().min(1).optional(),strict:z.boolean().optional(),schema:z.any()})})),dn=z.object({text:z.string().min(1),type:z.literal("text")}),Ei=z.object({type:z.literal("image_url"),image_url:z.object({url:z.string().url().min(1),detail:z.enum(["low","high","auto"]).optional()})}),ki=z.object({id:z.string().min(1),type:z.literal("function"),function:z.object({name:z.string().min(1),arguments:z.string().min(1)})}),wi=z.object({role:z.literal("system"),content:z.string().min(1).or(z.array(dn).min(1))}),vi=z.object({role:z.literal("user"),content:z.string().min(1).or(z.array(z.union([dn,Ei])).min(1))}),Li=z.object({role:z.literal("assistant"),content:z.string().min(1).or(z.array(dn).min(1)).optional(),tool_calls:z.array(ki).min(1).optional()}),Di=z.object({role:z.literal("tool"),tool_call_id:z.string().min(1),content:z.string().min(1)}),Ni=z.union([wi,vi,Li,Di]),Us=z.object({model:z.string().min(1).optional(),messages:z.array(Ni).min(1),frequency_penalty:z.number().min(-2).max(2).nullable().optional(),logprobs:z.boolean().nullable().optional(),top_logprobs:z.number().min(0).max(20).nullable().optional(),max_completion_tokens:z.number().min(0).nullable().optional(),presence_penalty:z.number().min(-2).max(2).nullable().optional(),response_format:Gi.optional(),seed:z.number().nullable().optional(),stop:z.string().or(z.array(z.string()).max(4)).nullable().optional(),temperature:z.number().min(0).max(2).nullable().optional(),top_p:z.number().min(0).max(1).nullable().optional(),tools:z.array(Ii).optional(),tool_choice:Ri.or(Ai).optional(),reasoning_effort:z.enum(["minimal","low","medium","high"]).optional(),verbosity:z.enum(["low","medium","high"]).optional()});var h=z.object({modelName:z.string(),apiKey:z.string(),baseUrl:z.string().url().optional(),completeChatUrl:z.string().url().optional(),streamChatUrl:z.string().url().optional(),organization:z.string().optional()}),c=class{constructor(e,s){this.version="v1";let o=h.parse(s);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=urlWithoutTrailingSlash(o.baseUrl||K.baseUrl),this.streamChatUrl=urlWithoutTrailingSlash(o.streamChatUrl||`${this.baseUrl}/chat/completions`),this.completeChatUrl=urlWithoutTrailingSlash(o.completeChatUrl||`${this.baseUrl}/chat/completions`),this.organization=o.organization;}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return b({Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},this.organization?{"OpenAI-Organization":this.organization}:{})}getDefaultParams(){return {model:this.modelName}}getRetryDelay(e,s){let o=p=>{let _=/(\d+)(h|m|s|ms)/g,T={h:36e5,m:6e4,s:1e3,ms:1},x,O=0;for(;(x=_.exec(p))!==null;){let I=parseInt(x[1]),R=x[2];O+=I*T[R];}return O},t=0,n=0,r=true;e["x-ratelimit-reset-requests"]&&(t=o(e["x-ratelimit-reset-requests"])),e["x-ratelimit-reset-tokens"]&&(n=o(e["x-ratelimit-reset-tokens"]));let l=Math.max(t,n);return {shouldRetry:r,delayMs:l}}getTokenCount(e){return e.reduce((s,o)=>s+o.content.map(t=>t.modality==="text"?t.value:"").join(" ").length,0)}transformModelRequest(e){let s=Us.safeParse(e);if(!s.success)throw new InvalidModelRequestError({info:"Invalid model request",cause:s.error});let o=s.data,t=o.model;if(o.tool_choice&&(!o.tools||o.tools.length===0))throw new InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let n={};o.response_format&&(n.responseFormat=o.response_format.type,o.response_format.type==="json_schema"&&(n.responseSchema={name:o.response_format.json_schema.name,description:o.response_format.json_schema.description||"",strict:o.response_format.json_schema.strict,schema:o.response_format.json_schema.schema})),o.tool_choice&&(typeof o.tool_choice=="string"?n.toolChoice=o.tool_choice:n.toolChoice=o.tool_choice.function.name),n.seed=o.seed,n.maxTokens=o.max_completion_tokens,n.temperature=o.temperature,n.topP=o.top_p,n.presencePenalty=o.presence_penalty,n.frequencyPenalty=o.frequency_penalty,n.stop=o.stop,n.logProbs=o.logprobs,n.topLogProbs=o.top_logprobs,n.reasoningEffort=o.reasoning_effort,n.verbosity=o.verbosity;let r=Config().parse(removeUndefinedEntries(n)),l=[],p={};o.messages.forEach(T=>{let x=T.role;switch(x){case "system":{let O=T.content;if(typeof O=="string")l.push({role:x,content:[{modality:TextModalityLiteral,value:O}]});else {let I=O.map(R=>({modality:TextModalityLiteral,value:R.text}));l.push({role:x,content:I});}}break;case "user":{let O=T.content;if(typeof O=="string")l.push({role:x,content:[{modality:TextModalityLiteral,value:O}]});else {let I=O.map(R=>R.type==="text"?{modality:TextModalityLiteral,value:R.text}:R.image_url.url.startsWith("data:")?{modality:ImageModalityLiteral,detail:R.image_url.detail||"auto",value:{type:Base64ImageContentTypeLiteral,base64:R.image_url.url,mediaType:getMimeTypeFromBase64(R.image_url.url)}}:{modality:ImageModalityLiteral,detail:R.image_url.detail||"auto",value:{type:UrlImageContentTypeLiteral,url:R.image_url.url}});l.push({role:x,content:I});}}break;case "assistant":{let O=[];if(!T.content&&!T.tool_calls)throw new InvalidModelRequestError({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("one of'content' or 'tool_calls' must be provided")});if(T.content){let I=T.content;typeof I=="string"?O.push({modality:TextModalityLiteral,value:I}):I.forEach(R=>{O.push({modality:TextModalityLiteral,value:R.text});});}T.tool_calls&&T.tool_calls.forEach((R,L)=>{let S={modality:ToolCallModalityLiteral,id:R.id,index:L,name:R.function.name,arguments:R.function.arguments};O.push(S),p[S.id]=S;}),l.push({role:x,content:O});}break;case "tool":{let O=T;l.push({role:x,content:[{modality:ToolResponseModalityLiteral,id:O.tool_call_id,index:p[O.tool_call_id].index,name:p[O.tool_call_id].name,data:O.content}]});}break}});let _=[];return o.tools&&o.tools.forEach(T=>{_.push({type:"function",definition:{schema:{name:T.function.name,description:T.function.description||"",strict:T.function.strict,parameters:T.function.parameters}}});}),{modelName:t,config:r,messages:l,tools:_.length>0?_:void 0}}transformConfig(e,s,o){let t=e.toolChoice;delete e.toolChoice;let n=this.modelSchema.config.schema.safeParse(e);if(!n.success)throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:n.error});let r=n.data;t!==void 0&&(r.toolChoice=t),Object.keys(r).forEach(p=>{if(!(p in this.modelSchema.config.def))throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${p}',
8
8
  available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let l=Object.keys(r).reduce((p,_)=>{let T=this.modelSchema.config.def[_],x=T.param,O=r[_];return x==="max_completion_tokens"&&T.type==="range"&&O===0?p[x]=T.max:p[x]=O,p},{});if(l.top_logprobs&&!l.logprobs)throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'logprobs' must be 'true' when 'top_logprobs' is specified")});if("tool_choice"in l&&l.tool_choice!==void 0){let p=l.tool_choice;if(!o||o&&o.length===0)throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(o&&o.length>0){let _=this.modelSchema.config.def.toolChoice;if(!_.choices.includes(p))if(o.map(T=>T.definition.schema.name).includes(p))l.tool_choice={type:"function",function:{name:p}};else throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`toolChoice : '${p}' is not part of provided 'tools' names or
9
9
  one of [${_.choices.join(", ")}]`)})}}if("response_format"in l&&l.response_format!==void 0){let p=l.response_format;if(p==="json_schema")if("response_schema"in l)l.response_format={type:"json_schema",json_schema:l.response_schema},delete l.response_schema;else throw new InvalidConfigError({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'responseSchema' is required in config when 'responseFormat' is 'json_schema'")});else l.response_format={type:p};}return l}transformMessages(e){if(!e||e&&e.length===0)return {messages:[]};let s=e.map(t=>{let n=Message().safeParse(t);if(!n.success)throw new InvalidMessagesError({info:"Invalid messages",cause:n.error});return n.data});return s.forEach(t=>{t.content.forEach(n=>{if(!this.modelSchema.modalities.includes(n.modality))throw new InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${n.modality}',
10
10
  available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),s.forEach(t=>{if(!Object.keys(this.modelSchema.roles).includes(t.role))throw new InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${t.role}',
11
11
  available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}),s.forEach(t=>{t.content=t.content.filter(n=>n.modality!=="error"&&n.modality!=="search-result");}),{messages:s.map(t=>{switch(t.role){case SystemRoleLiteral:{let n=[];return t.content.forEach(r=>{if(r.modality===TextModalityLiteral)n.push({type:"text",text:r.value});else throw new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${t.role}' cannot have content with modality : '${r.modality}'`)})}),{role:this.modelSchema.roles[t.role],content:n}}case AssistantRoleLiteral:{let n=[],r=[];return t.content.forEach(l=>{if(l.modality===TextModalityLiteral)n.push({type:"text",text:l.value});else if(l.modality===ToolCallModalityLiteral)r.push({id:l.id,type:"function",function:{name:l.name,arguments:l.arguments}});else throw new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${t.role}' cannot have content with modality : '${l.modality}'`)})}),b({role:this.modelSchema.roles[t.role],content:n},r.length>0?{tool_calls:r}:{})}case UserRoleLiteral:{let n=[],r=[];t.content.forEach(p=>{if(p.modality===TextModalityLiteral)n.push({type:"text",text:p.value});else if(p.modality===ImageModalityLiteral)r.push({type:"image_url",image_url:{url:p.value.type==="url"?p.value.url:p.value.base64,detail:p.detail}});else throw new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${t.role}' cannot have content with modality : '${p.modality}'`)})});let l=[...n,...r];return {role:this.modelSchema.roles[t.role],content:l}}case ToolRoleLiteral:{if(t.content.length!==1)throw new InvalidMessagesError({info:`Invalid message for role : '${t.role}'`,cause:new Error(`role : '${t.role}' must have exactly one content item`)});if(t.content[0].modality!==ToolResponseModalityLiteral)throw new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${t.role}' must have content with modality : '${ToolResponseModalityLiteral}'`)});let n=t.content[0];return {role:this.modelSchema.roles[t.role],tool_call_id:n.id,content:n.data}}default:throw new InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${t.role}' is not supported,
12
- available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}})}}transformTools(e){if(!this.modelSchema.modalities.includes(ToolCallModalityLiteral))throw new InvalidToolsError({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${ToolCallModalityLiteral}'`)});return !e||e&&e.length===0?{tools:[]}:{tools:e.map(t=>{let n=Tool().safeParse(t);if(!n.success)throw new InvalidToolsError({info:"Invalid tools",cause:n.error});return n.data}).map(t=>({type:"function",function:t.definition.schema}))}}getCompleteChatUrl(e,s,o){return k(this,null,function*(){return new Promise(t=>{t(this.completeChatUrl);})})}getCompleteChatHeaders(e,s,o){return k(this,null,function*(){return new Promise(t=>{t(this.getDefaultHeaders());})})}getCompleteChatData(e,s,o){return k(this,null,function*(){let t=this.transformConfig(e,s,o),n=this.transformMessages(s);if(n.messages&&n.messages.length===0)throw new InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let r=o?this.transformTools(o):{};return new Promise(l=>{l(b(b(b(b({},this.getDefaultParams()),t),n),r));})})}transformCompleteChatResponse(e){let s=zs.safeParse(e);if(s.success){if(s.data.choices.length===0)throw new ModelResponseError({info:"Invalid response from model",cause:new Error(`No choices in response : ${JSON.stringify(s.data)}`)});let o=s.data,t=[{role:AssistantRoleLiteral,content:[]}],n=o.choices[0].message;n.content&&t[0].content.push(createTextContent(n.content)),n.refusal&&t[0].content.push(createTextContent(n.refusal)),n.tool_calls&&n.tool_calls.forEach((_,T)=>{t[0].content.push(createToolCallContent(T,_.id,_.function.name,_.function.arguments));});let r={promptTokens:o.usage.prompt_tokens,completionTokens:o.usage.completion_tokens,totalTokens:o.usage.total_tokens},l=[],p=o.choices[0].logprobs;return p&&(p.content&&l.push(...p.content.map(_=>({token:_.token,logProb:_.logprob,bytes:_.bytes,topLogProbs:_.top_logprobs.map(T=>({token:T.token,logProb:T.logprob,bytes:T.bytes}))}))),p.refusal&&l.push(...p.refusal.map(_=>({token:_.token,logProb:_.logprob,bytes:_.bytes,topLogProbs:_.top_logprobs.map(T=>({token:T.token,logProb:T.logprob,bytes:T.bytes}))})))),{messages:t,usage:r,logProbs:l}}throw new ModelResponseError({info:"Invalid response from model",cause:s.error})}getStreamChatUrl(e,s,o){return k(this,null,function*(){return new Promise(t=>{t(this.streamChatUrl);})})}getStreamChatHeaders(e,s,o){return k(this,null,function*(){return new Promise(t=>{t(this.getDefaultHeaders());})})}getStreamChatData(e,s,o){return k(this,null,function*(){let t=this.transformConfig(e,s,o),n=this.transformMessages(s);if(n.messages&&n.messages.length===0)throw new InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let r=o?this.transformTools(o):{};return new Promise(l=>{l(b(b(b(b({stream:!0,stream_options:{include_usage:!0}},this.getDefaultParams()),t),n),r));})})}transformStreamChatResponseChunk(e,s){return ie(this,null,function*(){var l,p;let o=s+e,t=[],n="",r=0;for(;r<o.length;){let _=o.indexOf(`
13
- `,r);if(_===-1){n=o.substring(r);break}else {let T=o.substring(r,_).trim();T&&t.push(T),r=_+1;}}for(let _ of t){if(_==="data: [DONE]")return;if(_.startsWith("data: ")){let T=_.substring(6);try{let x=JSON.parse(T),O=Bs.safeParse(x);if(O.success){let I={partialMessages:[]},R=O.data;if(R.choices.length>0){let L=R.choices[0].delta;if(L!==void 0&&Object.keys(L).length!==0){if("content"in L&&L.content!==null)I.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,L.content));else if("refusal"in L&&L.refusal!==null)I.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,L.refusal));else if("tool_calls"in L&&L.tool_calls!==void 0){let S=L.tool_calls.at(0);I.partialMessages.push(createPartialToolCallMessage(AssistantRoleLiteral,S.index,S.id,(l=S.function)==null?void 0:l.name,(p=S.function)==null?void 0:p.arguments));}}}R.usage&&(I.usage={promptTokens:R.usage.prompt_tokens,completionTokens:R.usage.completion_tokens,totalTokens:R.usage.total_tokens}),yield {partialResponse:I,buffer:n};}else throw new ModelResponseError({info:"Invalid response from model",cause:O.error})}catch(x){throw new ModelResponseError({info:`Malformed JSON received in stream: ${T}`,cause:x})}}}yield {partialResponse:{partialMessages:[]},buffer:n};})}transformProxyStreamChatResponseChunk(e,s,o,t,n){return ie(this,null,function*(){yield*Me(this.transformStreamChatResponseChunk(e,s));})}getProxyStreamChatUrl(e,s,o){return k(this,null,function*(){return new Promise(t=>{t(this.streamChatUrl);})})}getProxyCompleteChatUrl(e,s,o){return k(this,null,function*(){return new Promise(t=>{t(this.completeChatUrl);})})}getProxyCompleteChatHeaders(e,s,o){return k(this,null,function*(){if(!s)return {};let t=b({},s);return delete t.host,delete t["content-length"],t})}getProxyStreamChatHeaders(e,s,o){return k(this,null,function*(){return yield this.getProxyCompleteChatHeaders(e,s,o)})}getModelPricing(){if(!(this.modelName in f))throw new ModelResponseError({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return f[this.modelName]}};var yn=z.object({modelName:z.string(),apiKey:z.string(),baseUrl:z.string().url().optional(),organization:z.string().optional()}),Yo=class{constructor(e,s){this.version="v1";let o=yn.parse(s);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=urlWithoutTrailingSlash(o.baseUrl||K.baseUrl),this.responsesUrl=`${this.baseUrl}/responses`,this.organization=o.organization;}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return b({Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},this.organization?{"OpenAI-Organization":this.organization}:{})}getDefaultParams(){return {model:this.modelName}}getRetryDelay(e,s){let o=p=>{let _=/(\d+)(h|m|s|ms)/g,T={h:36e5,m:6e4,s:1e3,ms:1},x,O=0;for(;(x=_.exec(p))!==null;){let I=parseInt(x[1]),R=x[2];O+=I*T[R];}return O},t=0,n=0,r=!0;e["x-ratelimit-reset-requests"]&&(t=o(e["x-ratelimit-reset-requests"])),e["x-ratelimit-reset-tokens"]&&(n=o(e["x-ratelimit-reset-tokens"]));let l=Math.max(t,n);return {shouldRetry:r,delayMs:l}}getTokenCount(e){return e.reduce((s,o)=>s+o.content.map(t=>t.modality==="text"?t.value:"").join(" ").length,0)}transformModelRequest(e){throw new ModelResponseError({info:"transformModelRequest not supported for Responses API models",cause:new Error("Use the standard gateway interface with config, messages, and tools parameters")})}transformConfig(e,s,o){let t=Config().parse(e),n={};for(let p of Object.keys(this.modelSchema.config.def)){let _=this.modelSchema.config.def[p],T=_==null?void 0:_.param;T&&t[p]!==void 0&&(n[T]=t[p]);}let r=t.toolChoice;if(r!==void 0)if(o&&o.length>0){let p=r,_=o.map(T=>T.definition.schema.name);if(["none","auto","required"].includes(p))n.tool_choice=p;else if(_.includes(p))n.tool_choice={type:"function",function:{name:p}};else throw new InvalidConfigError({info:`Invalid tool choice for model : '${this.modelName}'`,cause:new Error(`Tool with name '${p}' not found in tools`)})}else throw new InvalidConfigError({info:`Invalid tool choice for model : '${this.modelName}'`,cause:new Error("Tools are required when tool_choice is specified")});let l=t.responseFormat;if(l!==void 0)if(l==="json_schema"){if(!t.responseSchema)throw new InvalidConfigError({info:`Invalid response schema for model : '${this.modelName}'`,cause:new Error("Response schema is required when response format is 'json_schema'")});n.response_format={type:l,json_schema:n.response_schema},delete n.response_schema;}else n.response_format={type:l};return "reasoning_effort"in n&&n.reasoning_effort!==void 0&&(n.reasoning={effort:n.reasoning_effort},delete n.reasoning_effort),"verbosity"in n&&n.verbosity!==void 0&&(n.text={verbosity:n.verbosity},delete n.verbosity),n}transformMessages(e){if(!e||e.length===0)return {messages:[]};let s=e.map(t=>{let n=Message().safeParse(t);if(!n.success)throw new InvalidMessagesError({info:"Invalid messages",cause:n.error});return n.data});return s.forEach(t=>{t.content.forEach(n=>{if(!this.modelSchema.modalities.includes(n.modality))throw new InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${n.modality}'`)})});}),s.forEach(t=>{if(!Object.keys(this.modelSchema.roles).includes(t.role))throw new InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${t.role}'`)})}),s.forEach(t=>{t.content=t.content.filter(n=>n.modality!=="error"&&n.modality!=="search-result");}),{messages:s.map(t=>{switch(t.role){case SystemRoleLiteral:{let n=[];return t.content.forEach(r=>{if(r.modality===TextModalityLiteral)n.push({type:"input_text",text:r.value});else throw new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${t.role}' cannot have content with modality : '${r.modality}'`)})}),{role:this.modelSchema.roles[t.role],content:n}}case AssistantRoleLiteral:{let n=[];return t.content.forEach(r=>{if(r.modality===TextModalityLiteral)n.push({type:"output_text",text:r.value});else throw r.modality===ToolCallModalityLiteral?new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error("tool calls in message history are not supported for Responses API")}):new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${t.role}' cannot have content with modality : '${r.modality}'`)})}),{role:this.modelSchema.roles[t.role],content:n}}case UserRoleLiteral:{let n=[];return t.content.forEach(r=>{if(r.modality===TextModalityLiteral)n.push({type:"input_text",text:r.value});else if(r.modality===ImageModalityLiteral){let l=r.value,p=l.type==="url"?l.url:l.base64;n.push({type:"image_url",image_url:{url:p,detail:r.detail}});}else throw new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${t.role}' cannot have content with modality : '${r.modality}'`)})}),{role:this.modelSchema.roles[t.role],content:n}}case ToolRoleLiteral:{if(t.content.length!==1)throw new InvalidMessagesError({info:`Invalid message for role : '${t.role}'`,cause:new Error(`role : '${t.role}' must have exactly one content item`)});if(t.content[0].modality!==ToolResponseModalityLiteral)throw new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${t.role}' must have content with modality : '${ToolResponseModalityLiteral}'`)});let n=t.content[0];return {role:this.modelSchema.roles[t.role],tool_call_id:n.id,content:n.data}}default:throw new InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${t.role}' is not supported`)})}})}}transformTools(e){if(!e||e.length===0)return {tools:[]};if(!this.modelSchema.modalities.includes(ToolCallModalityLiteral))throw new InvalidToolsError({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality`)});return {tools:e.map(t=>{let n=Tool().safeParse(t);if(!n.success)throw new InvalidToolsError({info:"Invalid tools",cause:n.error});return n.data}).map(t=>({type:"function",function:t.definition.schema}))}}getCompleteChatUrl(e,s,o){return k(this,null,function*(){return Promise.resolve(this.responsesUrl)})}getCompleteChatHeaders(e,s,o){return k(this,null,function*(){return Promise.resolve(this.getDefaultHeaders())})}getCompleteChatData(e,s,o){return k(this,null,function*(){let t=this.transformConfig(e,s,o),n=this.transformMessages(s);if(n.messages&&n.messages.length===0)throw new InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let r=o?this.transformTools(o):{};return Promise.resolve(q(b(b(b({},this.getDefaultParams()),t),r),{input:n.messages}))})}transformCompleteChatResponse(e){var n,r,l,p,_,T,x,O,I,R,L;let s=(e==null?void 0:e.output)||(e==null?void 0:e.outputs);if(!s||!Array.isArray(s)||s.length===0)throw new ModelResponseError({info:"Invalid response from model",cause:new Error(`No output in response : ${JSON.stringify(e)}`)});let o=[{role:AssistantRoleLiteral,content:[]}];for(let S of s)if((S==null?void 0:S.type)==="message"&&Array.isArray(S.content))S.content.forEach(A=>{var U,C,D,H,E,P;if((A==null?void 0:A.type)==="text"||(A==null?void 0:A.type)==="output_text")A.text&&o[0].content.push(createTextContent(A.text));else if((A==null?void 0:A.type)==="tool_call"&&A.tool_call){let V=A.tool_call;o[0].content.push(createToolCallContent((U=V.index)!=null?U:0,(C=V.id)!=null?C:"",(H=(D=V.function)==null?void 0:D.name)!=null?H:"",(P=(E=V.function)==null?void 0:E.arguments)!=null?P:""));}});else if(((S==null?void 0:S.type)==="text"||(S==null?void 0:S.type)==="output_text")&&(S!=null&&S.text))o[0].content.push(createTextContent(S.text));else if((S==null?void 0:S.type)==="tool_call"&&S.tool_call){let A=S.tool_call;o[0].content.push(createToolCallContent((n=A.index)!=null?n:0,(r=A.id)!=null?r:"",(p=(l=A.function)==null?void 0:l.name)!=null?p:"",(T=(_=A.function)==null?void 0:_.arguments)!=null?T:""));}if(o[0].content.length===0){let S=s[0],A=(S==null?void 0:S.content)||[],U=[];if(A.forEach(C=>{((C==null?void 0:C.type)==="text"||(C==null?void 0:C.type)==="output_text")&&(C!=null&&C.text)&&U.push(C.text);}),U.length>0)o[0].content.push(createTextContent(U.join(`
14
- `)));else throw new ModelResponseError({info:"Invalid response from model",cause:new Error(`No text content found in response : ${JSON.stringify(e)}`)})}let t=e.usage||{};return {messages:o,usage:{promptTokens:(O=(x=t.input_tokens)!=null?x:t.prompt_tokens)!=null?O:0,completionTokens:(R=(I=t.output_tokens)!=null?I:t.completion_tokens)!=null?R:0,totalTokens:(L=t.total_tokens)!=null?L:(t.input_tokens||0)+(t.output_tokens||0)}}}getStreamChatUrl(e,s,o){return k(this,null,function*(){return Promise.resolve(this.responsesUrl)})}getStreamChatHeaders(e,s,o){return k(this,null,function*(){return Promise.resolve(q(b({},this.getDefaultHeaders()),{Accept:"text/event-stream"}))})}getStreamChatData(e,s,o){return k(this,null,function*(){let t=this.transformConfig(e,s,o),n=this.transformMessages(s);if(n.messages&&n.messages.length===0)throw new InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let r=o?this.transformTools(o):{};return Promise.resolve(q(b(b(b({},this.getDefaultParams()),t),r),{input:n.messages,stream:!0}))})}transformStreamChatResponseChunk(e,s){return ie(this,null,function*(){var l,p,_,T,x,O,I,R,L,S;let o=s+e,t=[],n="",r=0;for(;r<o.length;){let A=o.indexOf(`
15
- `,r);if(A===-1){n=o.substring(r);break}else {let U=o.substring(r,A).trim();U&&t.push(U),r=A+1;}}for(let A of t){if(A==="data: [DONE]")return;if(A.startsWith("data: ")){let U=A.substring(6);try{let C=JSON.parse(U),D={partialMessages:[]},H=!1;if((C.type==="response.output_text.delta"||C.type==="output_text.delta")&&typeof C.delta=="string"&&C.delta.length>0&&(D.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,C.delta)),H=!0),C.type==="response.content_part.added"&&C.part){let E=C.part;E.type==="output_text"&&typeof E.text=="string"&&E.text.length>0&&(D.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,E.text)),H=!0);}if(!H&&C.delta){let E=C.delta;typeof E=="string"&&E.length>0?(D.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,E)),H=!0):E&&typeof E=="object"&&E.text!==void 0&&E.text!==null?(D.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,E.text)),H=!0):Array.isArray(E.content)&&E.content.forEach(P=>{var V,me,de,ce;if((P==null?void 0:P.type)==="output_text"&&(P!=null&&P.text))D.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,P.text)),H=!0;else if((P==null?void 0:P.type)==="tool_call"&&(P!=null&&P.tool_call)){let G=P.tool_call;D.partialMessages.push(createPartialToolCallMessage(AssistantRoleLiteral,(V=G.index)!=null?V:0,(me=G.id)!=null?me:"",(de=G.function)==null?void 0:de.name,(ce=G.function)==null?void 0:ce.arguments)),H=!0;}});}if((C.type==="tool_call"||C.type==="tool_call.delta"||C.type==="response.tool_call.delta")&&(l=C.delta)!=null&&l.tool_call){let E=C.delta.tool_call;D.partialMessages.push(createPartialToolCallMessage(AssistantRoleLiteral,(p=E.index)!=null?p:0,(_=E.id)!=null?_:"",(T=E.function)==null?void 0:T.name,(x=E.function)==null?void 0:x.arguments));}if(!C.delta&&(C.output||C.outputs)){let E=C.output||C.outputs;Array.isArray(E)&&E.forEach(P=>{var V,me,de,ce;if((P==null?void 0:P.type)==="message"&&Array.isArray(P.content))P.content.forEach(G=>{var Cn,On,Pn,bn;if(((G==null?void 0:G.type)==="text"||(G==null?void 0:G.type)==="output_text")&&(G!=null&&G.text))D.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,G.text));else if((G==null?void 0:G.type)==="tool_call"&&(G!=null&&G.tool_call)){let Te=G.tool_call;D.partialMessages.push(createPartialToolCallMessage(AssistantRoleLiteral,(Cn=Te.index)!=null?Cn:0,(On=Te.id)!=null?On:"",(Pn=Te.function)==null?void 0:Pn.name,(bn=Te.function)==null?void 0:bn.arguments));}});else if(((P==null?void 0:P.type)==="text"||(P==null?void 0:P.type)==="output_text")&&(P!=null&&P.text))D.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,P.text));else if((P==null?void 0:P.type)==="tool_call"&&(P!=null&&P.tool_call)){let G=P.tool_call;D.partialMessages.push(createPartialToolCallMessage(AssistantRoleLiteral,(V=G.index)!=null?V:0,(me=G.id)!=null?me:"",(de=G.function)==null?void 0:de.name,(ce=G.function)==null?void 0:ce.arguments));}});}C.usage&&(D.usage={promptTokens:(I=(O=C.usage.input_tokens)!=null?O:C.usage.prompt_tokens)!=null?I:0,completionTokens:(L=(R=C.usage.output_tokens)!=null?R:C.usage.completion_tokens)!=null?L:0,totalTokens:(S=C.usage.total_tokens)!=null?S:(C.usage.input_tokens||0)+(C.usage.output_tokens||0)}),(D.partialMessages.length>0||D.usage)&&(yield {partialResponse:D,buffer:n});}catch(C){throw new ModelResponseError({info:`Malformed JSON received in stream: ${U}`,cause:C})}}}})}transformProxyStreamChatResponseChunk(e,s,o,t,n){return ie(this,null,function*(){yield*Me(this.transformStreamChatResponseChunk(e,s));})}getProxyStreamChatUrl(e,s,o){return k(this,null,function*(){return Promise.resolve(this.responsesUrl)})}getProxyCompleteChatUrl(e,s,o){return k(this,null,function*(){return Promise.resolve(this.responsesUrl)})}getProxyCompleteChatHeaders(e,s,o){return k(this,null,function*(){if(!s)return {};let t=b({},s);return delete t.host,delete t["content-length"],t})}getProxyStreamChatHeaders(e,s,o){return k(this,null,function*(){let t=yield this.getProxyCompleteChatHeaders(e,s,o);return q(b({},t),{Accept:"text/event-stream"})})}getModelPricing(){if(!(this.modelName in f))throw new ModelResponseError({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return f[this.modelName]}};var ct="chatgpt-5.2",ia="ChatGPT-5.2 model optimized for conversational workloads with tool/function calling support. Training data up to January 2025.",ht=ChatModelSchema(m,M).parse({name:ct,description:ia,maxInputTokens:4e5,maxOutputTokens:131072,roles:d,modalities:y,config:{def:a.gpt5(131072,4).def,schema:a.gpt5(131072,4).schema},price:f["gpt-5.2"]}),Vn=h,Se=class extends c{constructor(e){super(ht,e);}};var Ie="gpt-3.5-turbo-0125",ra="The latest GPT-3.5 Turbo model with higher accuracy at responding in requested formats and a fix for a bug which caused a text encoding issue for non-English language function calls. Training data up to Sept 2021.",ut=ChatModelSchema(m,v).parse({name:Ie,description:ra,maxInputTokens:4092,maxOutputTokens:4092,roles:d,modalities:w,config:{def:a.responseFormat(4092,4).def,schema:a.responseFormat(4092,4).schema},price:f[Ie]}),Jn=h,Re=class extends c{constructor(e){super(ut,e);}};var Ae="gpt-3.5-turbo-1106",pa="The latest GPT-3.5 Turbo model with improved instruction following, JSON mode, reproducible outputs, parallel function calling, and more. Returns a maximum of 4,096 output tokens. Training data up to Sept 2021.",ft=ChatModelSchema(m,v).parse({name:Ae,description:pa,maxInputTokens:4092,maxOutputTokens:16385,roles:d,modalities:w,config:{def:a.responseFormat(16385,4).def,schema:a.responseFormat(16385,4).schema},price:f[Ae]}),Kn=h,Ge=class extends c{constructor(e){super(ft,e);}};var Ee="gpt-3.5-turbo",da="Currently points to gpt-3.5-turbo-0125. Training data up to Sept 2021.",_t=ChatModelSchema(m,v).parse({name:Ee,description:da,maxInputTokens:4092,maxOutputTokens:4092,roles:d,modalities:w,config:{def:a.responseFormat(4092,4).def,schema:a.responseFormat(4092,4).schema},price:f[Ee]}),Wn=h,ke=class extends c{constructor(e){super(_t,e);}};var we="gpt-4-0125-preview",ha="The latest GPT-4 model intended to reduce cases of \u201Claziness\u201D where the model doesn\u2019t complete a task. Training data up to Apr 2023.",gt=ChatModelSchema(m,v).parse({name:we,description:ha,maxInputTokens:128e3,maxOutputTokens:4092,roles:d,modalities:w,config:{def:a.base(4092,4).def,schema:a.base(4092,4).schema},price:f[we]}),Yn=h,ve=class extends c{constructor(e){super(gt,e);}};var Le="gpt-4-0613",fa="Snapshot of gpt-4 from June 13th 2023 with improved function calling support. Training data up to Sept 2021.",Tt=ChatModelSchema(m,v).parse({name:Le,description:fa,maxInputTokens:8192,maxOutputTokens:4092,roles:d,modalities:w,config:{def:a.base(4092,4).def,schema:a.base(4092,4).schema},price:f[Le]}),Qn=h,De=class extends c{constructor(e){super(Tt,e);}};var Ne="gpt-4-1106-preview",ga="GPT-4 Turbo model featuring improved instruction following, JSON mode, reproducible outputs, parallel function calling, and more. Returns a maximum of 4,096 output tokens. This preview model is not yet suited for production traffic. Training data up to Apr 2023.",yt=ChatModelSchema(m,v).parse({name:Ne,description:ga,maxInputTokens:128e3,maxOutputTokens:4092,roles:d,modalities:w,config:{def:a.base(4092,4).def,schema:a.base(4092,4).schema},price:f[Ne]}),Xn=h,qe=class extends c{constructor(e){super(yt,e);}};var ze="gpt-4.1",ya="Flagship model for complex tasks. It is well suited for problem solving across domains. Training data up to May 2024.",Mt=ChatModelSchema(m,M).parse({name:ze,description:ya,maxInputTokens:1047576,maxOutputTokens:32768,roles:d,modalities:y,config:{def:a.responseSchema(32768,4).def,schema:a.responseSchema(32768,4).schema},price:f[ze]}),Zn=h,Be=class extends c{constructor(e){super(Mt,e);}};var Ue="gpt-4.1-mini",Ca="Provides a balance between intelligence, speed, and cost that makes it an attractive model for many use cases. Training data up to May 2024.",Ct=ChatModelSchema(m,M).parse({name:Ue,description:Ca,maxInputTokens:1047576,maxOutputTokens:32768,roles:d,modalities:y,config:{def:a.responseSchema(32768,4).def,schema:a.responseSchema(32768,4).schema},price:f[Ue]}),es=h,je=class extends c{constructor(e){super(Ct,e);}};var $e="gpt-4.1-nano",Pa="Fastest, most cost-effective GPT-4.1 model. Training data up to May 2024.",Ot=ChatModelSchema(m,M).parse({name:$e,description:Pa,maxInputTokens:1047576,maxOutputTokens:32768,roles:d,modalities:y,config:{def:a.responseSchema(32768,4).def,schema:a.responseSchema(32768,4).schema},price:f[$e]}),os=h,Fe=class extends c{constructor(e){super(Ot,e);}};var He="gpt-5.1",xa="Flagship GPT-5.1 model for coding and agentic tasks with configurable reasoning effort. Training data up to September 2024.",Pt=ChatModelSchema(m,M).parse({name:He,description:xa,maxInputTokens:4e5,maxOutputTokens:128e3,roles:d,modalities:y,config:{def:a.gpt5(128e3,4).def,schema:a.gpt5(128e3,4).schema},price:f[He]}),ts=h,Ve=class extends c{constructor(e){super(Pt,e);}};var Je="gpt-5.2",Ia="Flagship GPT-5.2 model with enhanced reasoning controls and extended knowledge coverage. Training data up to January 2025.",bt=ChatModelSchema(m,M).parse({name:Je,description:Ia,maxInputTokens:4e5,maxOutputTokens:131072,roles:d,modalities:y,config:{def:a.gpt5(131072,4).def,schema:a.gpt5(131072,4).schema},price:f[Je]}),ns=h,Ke=class extends c{constructor(e){super(bt,e);}};var We="gpt-5.2-chat-latest",Aa="Latest GPT-5.2 chat-optimized model for conversational workloads with tool/function calling support. Training data up to January 2025.",Ga=y,Ea=M,xt=ChatModelSchema(m,Ea).parse({name:We,description:Aa,maxInputTokens:4e5,maxOutputTokens:131072,roles:d,modalities:Ga,config:{def:a.gpt5(131072,4).def,schema:a.gpt5(131072,4).schema},price:f[We]}),ss=h,Ye=class extends c{constructor(e){super(xt,e);}};var Qe="gpt-5.2-codex",wa="Coding-optimized GPT-5.2 Codex model for software engineering, debugging, and autonomous coding workflows.",St=ChatModelSchema(m,M).parse({name:Qe,description:wa,maxInputTokens:4e5,maxOutputTokens:131072,roles:d,modalities:y,config:{def:a.gpt5(131072,4).def,schema:a.gpt5(131072,4).schema},price:f[Qe]}),is=h,Xe=class extends c{constructor(e){super(St,e);}};var Ze="gpt-5.2-pro",La="GPT-5.2 Pro available via the OpenAI Responses API for advanced reasoning and agentic workflows. Training data up to January 2025.",It=ChatModelSchema(m,M).parse({name:Ze,description:La,maxInputTokens:4e5,maxOutputTokens:131072,roles:d,modalities:y,config:{def:a.gpt5(131072,4).def,schema:a.gpt5(131072,4).schema},price:f[Ze]}),as=yn,eo=class extends Yo{constructor(e){super(It,e);}};var oo="gpt-5.3-codex",Na="Latest coding-optimized GPT-5.3 Codex model for high-reliability code generation, edits, and agentic software tasks.",Rt=ChatModelSchema(m,M).parse({name:oo,description:Na,maxInputTokens:4e5,maxOutputTokens:131072,roles:d,modalities:y,config:{def:a.gpt5(131072,4).def,schema:a.gpt5(131072,4).schema},price:f[oo]}),rs=h,to=class extends c{constructor(e){super(Rt,e);}};var no="gpt-5",za="Most advanced GPT-5 model for complex reasoning and problem-solving tasks. Training data up to October 2024.",At=ChatModelSchema(m,M).parse({name:no,description:za,maxInputTokens:4e5,maxOutputTokens:131072,roles:d,modalities:y,config:{def:a.gpt5(131072,4).def,schema:a.gpt5(131072,4).schema},price:f[no]}),ls=h,so=class extends c{constructor(e){super(At,e);}};var io="gpt-5-mini",Ua="Faster, more cost-effective GPT-5 model that balances intelligence and efficiency. Training data up to October 2024.",Gt=ChatModelSchema(m,M).parse({name:io,description:Ua,maxInputTokens:4e5,maxOutputTokens:131072,roles:d,modalities:y,config:{def:a.gpt5(131072,4).def,schema:a.gpt5(131072,4).schema},price:f[io]}),ps=h,ao=class extends c{constructor(e){super(Gt,e);}};var ro="gpt-5-nano",$a="Most cost-effective GPT-5 model optimized for speed and efficiency. Training data up to October 2024.",Et=ChatModelSchema(m,M).parse({name:ro,description:$a,maxInputTokens:4e5,maxOutputTokens:131072,roles:d,modalities:y,config:{def:a.gpt5(131072,4).def,schema:a.gpt5(131072,4).schema},price:f[ro]}),ms=h,lo=class extends c{constructor(e){super(Et,e);}};var po="gpt-5-chat-latest",Va="Latest GPT-5 model optimized for conversational use. Does not support function calling or structured outputs. Training data up to October 2024.",Ja=[TextModalityLiteral,ImageModalityLiteral],Ka=z.enum([TextModalityLiteral,ImageModalityLiteral]),kt=ChatModelSchema(m,Ka).parse({name:po,description:Va,maxInputTokens:4e5,maxOutputTokens:131072,roles:d,modalities:Ja,config:{def:a.gpt5(131072,4).def,schema:a.gpt5(131072,4).schema},price:f[po]}),ds=h,mo=class extends c{constructor(e){super(kt,e);}};var co="gpt-4-turbo-2024-04-09",Ya="GPT-4 Turbo with Vision model. Vision requests can now use JSON mode and function calling. gpt-4-turbo currently points to this version. Training data up to Dec 2023.",wt=ChatModelSchema(m,M).parse({name:co,description:Ya,maxInputTokens:128e3,maxOutputTokens:4096,roles:d,modalities:y,config:{def:a.responseFormat(4096,4).def,schema:a.responseFormat(4096,4).schema},price:f[co]}),cs=h,ho=class extends c{constructor(e){super(wt,e);}};var uo="gpt-4-turbo-preview",Xa="Currently points to gpt-4-0125-preview. Training data up to Apr 2023.",vt=ChatModelSchema(m,v).parse({name:uo,description:Xa,maxInputTokens:128e3,maxOutputTokens:4092,roles:d,modalities:w,config:{def:a.responseFormat(4092,4).def,schema:a.responseFormat(4092,4).schema},price:f[uo]}),hs=h,fo=class extends c{constructor(e){super(vt,e);}};var _o="gpt-4-turbo",er="The latest GPT-4 Turbo model with vision capabilities. Vision requests can now use JSON mode and function calling. Currently points to gpt-4-turbo-2024-04-09. Training data up to Dec 2023.",Lt=ChatModelSchema(m,M).parse({name:_o,description:er,maxInputTokens:128e3,maxOutputTokens:4092,roles:d,modalities:y,config:{def:a.responseFormat(4092,4).def,schema:a.responseFormat(4092,4).schema},price:f[_o]}),us=h,go=class extends c{constructor(e){super(Lt,e);}};var To="gpt-4",tr="Currently points to gpt-4-0613. Training data up to Sept 2021.",Dt=ChatModelSchema(m,v).parse({name:To,description:tr,maxInputTokens:8192,maxOutputTokens:4092,roles:d,modalities:w,config:{def:a.base(4092,4).def,schema:a.base(4092,4).schema},price:f[To]}),fs=h,yo=class extends c{constructor(e){super(Dt,e);}};var Mo="gpt-4o-2024-05-13",sr="Latest snapshot of gpt-4o that supports Structured Outputs. Training data up to Oct 2023.",Nt=ChatModelSchema(m,M).parse({name:Mo,description:sr,maxInputTokens:128e3,maxOutputTokens:4092,roles:d,modalities:y,config:{def:a.responseSchema(4092,4).def,schema:a.responseSchema(4092,4).schema},price:f[Mo]}),_s=h,Co=class extends c{constructor(e){super(Nt,e);}};var Oo="gpt-4o-2024-08-06",ar="Latest snapshot of gpt-4o that supports Structured Outputs. Training data up to Oct 2023.",qt=ChatModelSchema(m,M).parse({name:Oo,description:ar,maxInputTokens:128e3,maxOutputTokens:4092,roles:d,modalities:y,config:{def:a.responseSchema(4092,4).def,schema:a.responseSchema(4092,4).schema},price:f[Oo]}),gs=h,Po=class extends c{constructor(e){super(qt,e);}};var bo="gpt-4o-mini-2024-07-18",lr="Most advanced, multimodal flagship model that is cheaper and faster than GPT-4 Turbo. Currently points to gpt-4o-2024-05-13. Training data up to Oct 2023.",zt=ChatModelSchema(m,M).parse({name:bo,description:lr,maxInputTokens:128e3,maxOutputTokens:4092,roles:d,modalities:y,config:{def:a.responseSchema(4092,4).def,schema:a.responseSchema(4092,4).schema},price:f[bo]}),Ts=h,xo=class extends c{constructor(e){super(zt,e);}};var So="gpt-4o-mini",mr="Most advanced, multimodal flagship model that is cheaper and faster than GPT-4 Turbo. Currently points to gpt-4o-2024-05-13. Training data up to Oct 2023.",Bt=ChatModelSchema(m,M).parse({name:So,description:mr,maxInputTokens:128e3,maxOutputTokens:4092,roles:d,modalities:y,config:{def:a.responseSchema(4092,4).def,schema:a.responseSchema(4092,4).schema},price:f[So]}),ys=h,Io=class extends c{constructor(e){super(Bt,e);}};var Ro="gpt-4o",cr="Most advanced, multimodal flagship model that is cheaper and faster than GPT-4 Turbo. Currently points to gpt-4o-2024-05-13. Training data up to Oct 2023.",Ut=ChatModelSchema(m,M).parse({name:Ro,description:cr,maxInputTokens:128e3,maxOutputTokens:4092,roles:d,modalities:y,config:{def:a.responseSchema(4092,4).def,schema:a.responseSchema(4092,4).schema},price:f[Ro]}),Ms=h,Ao=class extends c{constructor(e){super(Ut,e);}};var Go="chatgpt-4o-latest",fr="Latest ChatGPT-4o chat model optimized for conversational quality. Does not support function calling or structured outputs.",_r=[TextModalityLiteral,ImageModalityLiteral],gr=z.enum([TextModalityLiteral,ImageModalityLiteral]),jt=ChatModelSchema(m,gr).parse({name:Go,description:fr,maxInputTokens:128e3,maxOutputTokens:16384,roles:d,modalities:_r,config:{def:a.responseFormat(16384,4).def,schema:a.responseFormat(16384,4).schema},price:f[Go]}),Cs=h,Eo=class extends c{constructor(e){super(jt,e);}};var ko="o1-2024-12-17",yr="A stable release model for production use, offering robust performance and advanced features. Training data up to December 2024.",$t=ChatModelSchema(m,M).parse({name:ko,description:yr,maxInputTokens:2e5,maxOutputTokens:1e5,roles:d,modalities:y,config:{def:a.o1Series(1e5,4).def,schema:a.o1Series(1e5,4).schema},price:f[ko]}),Os=h,wo=class extends c{constructor(e){super($t,e);}};var vo="o1",Cr="Highly capable general-purpose reasoning model with advanced capabilities in language, coding, and reasoning. Training data up to Oct 2023.",Ft=ChatModelSchema(m,M).parse({name:vo,description:Cr,maxInputTokens:2e5,maxOutputTokens:1e5,roles:d,modalities:y,config:{def:a.o1Series(1e5,4).def,schema:a.o1Series(1e5,4).schema},price:f[vo]}),Ps=h,Lo=class extends c{constructor(e){super(Ft,e);}};var Ht="o3-2025-04-16",Pr="A new standard for math, science, coding, and visual reasoning tasks. Training data up to Jun 2024.",Vt=ChatModelSchema(m,M).parse({name:Ht,description:Pr,maxInputTokens:2e5,maxOutputTokens:1e5,roles:d,modalities:y,config:{def:a.oSeries(1e5,4).def,schema:a.oSeries(1e5,4).schema}}),bs=h,Do=class extends c{constructor(e){super(Vt,e);}};var Jt="o3",xr="A new standard for math, science, coding, and visual reasoning tasks. Training data up to Jun 2024.",Kt=ChatModelSchema(m,M).parse({name:Jt,description:xr,maxInputTokens:2e5,maxOutputTokens:1e5,roles:d,modalities:y,config:{def:a.oSeries(1e5,4).def,schema:a.oSeries(1e5,4).schema}}),xs=h,No=class extends c{constructor(e){super(Kt,e);}};var Wt="o3-mini",Ir="o3-mini is the newest small reasoning model, providing high intelligence at the same cost and latency targets of o1-mini. Training data up to Sep 2023.",Yt=ChatModelSchema(m,v).parse({name:Wt,description:Ir,maxInputTokens:2e5,maxOutputTokens:1e5,roles:d,modalities:w,config:{def:a.oSeries(1e5,4).def,schema:a.oSeries(1e5,4).schema}}),Ss=h,qo=class extends c{constructor(e){super(Yt,e);}};var Qt="o3-mini-2025-01-31",Ar="o3-mini is the newest small reasoning model, providing high intelligence at the same cost and latency targets of o1-mini. Training data up to Sep 2023.",Xt=ChatModelSchema(m,v).parse({name:Qt,description:Ar,maxInputTokens:2e5,maxOutputTokens:1e5,roles:d,modalities:w,config:{def:a.oSeries(1e5,4).def,schema:a.oSeries(1e5,4).schema}}),Is=h,zo=class extends c{constructor(e){super(Xt,e);}};var Zt="o4-mini-2025-04-16",Er="Optimized for fast, effective reasoning with exceptionally efficient performance in coding and visual tasks. Training data up to Jun 2024.",en=ChatModelSchema(m,M).parse({name:Zt,description:Er,maxInputTokens:2e5,maxOutputTokens:1e5,roles:d,modalities:y,config:{def:a.oSeries(1e5,4).def,schema:a.oSeries(1e5,4).schema}}),Rs=h,Bo=class extends c{constructor(e){super(en,e);}};var on="o4-mini",wr="Optimized for fast, effective reasoning with exceptionally efficient performance in coding and visual tasks. Training data up to Jun 2024.",tn=ChatModelSchema(m,M).parse({name:on,description:wr,maxInputTokens:2e5,maxOutputTokens:1e5,roles:d,modalities:y,config:{def:a.oSeries(1e5,4).def,schema:a.oSeries(1e5,4).schema}}),As=h,Uo=class extends c{constructor(e){super(tn,e);}};var le=[EmbeddingTextModalityLiteral,EmbeddingTokenModalityLiteral],pe=z.enum([EmbeddingTextModalityLiteral,EmbeddingTokenModalityLiteral]);var oi=z.object({object:z.literal("list"),model:z.string(),data:z.array(z.object({index:z.number(),object:z.literal("embedding"),embedding:z.array(z.number()).or(z.string().base64())})),usage:z.object({prompt_tokens:z.number().nonnegative(),total_tokens:z.number().nonnegative()})});var Lr=z.string().min(1).or(z.array(z.string().min(1)).min(1)).or(z.array(z.number().int().nonnegative()).min(1)).or(z.array(z.array(z.number().int().nonnegative()).min(1)).min(1)),ti=z.object({model:z.string().min(1).optional(),input:Lr,encoding_format:z.enum(["float","base64"]).optional(),dimensions:z.number().int().min(1).optional()});var se=z.object({modelName:z.string(),apiKey:z.string(),baseUrl:z.string().url().optional(),getEmbeddingsUrl:z.string().url().optional()}),ee=class{constructor(e,s){this.version="v1";let o=se.parse(s);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=urlWithoutTrailingSlash(o.baseUrl||K.baseUrl),this.getEmbeddingsUrl=urlWithoutTrailingSlash(o.getEmbeddingsUrl||`${this.baseUrl}/embeddings`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"}}getDefaultParams(){return {model:this.modelSchema.name}}getRetryDelay(e,s){let o=p=>{let _=/(\d+)(h|m|s|ms)/g,T={h:36e5,m:6e4,s:1e3,ms:1},x,O=0;for(;(x=_.exec(p))!==null;){let I=parseInt(x[1]),R=x[2];O+=I*T[R];}return O},t=0,n=0,r=!0;e["x-ratelimit-reset-requests"]&&(t=o(e["x-ratelimit-reset-requests"])),e["x-ratelimit-reset-tokens"]&&(n=o(e["x-ratelimit-reset-tokens"]));let l=Math.max(t,n);return {shouldRetry:r,delayMs:l}}getTokenCount(e){return e.requests.reduce((s,o)=>s+o.length,0)}transformModelRequest(e){let s=ti.safeParse(e);if(!s.success)throw new InvalidModelRequestError({info:"Invalid model request",cause:s.error});let o=s.data,t=o.model,n={encodingFormat:o.encoding_format,dimensions:o.dimensions},r=Config().parse(removeUndefinedEntries(n)),l,p;return typeof o.input=="string"?p=EmbeddingTextModalityLiteral:typeof o.input[0]=="string"?p=EmbeddingTextModalityLiteral:p=EmbeddingTokenModalityLiteral,p===EmbeddingTextModalityLiteral?typeof o.input=="string"?l={modality:p,requests:[o.input]}:l={modality:p,requests:o.input}:typeof o.input[0]=="number"?l={modality:p,requests:[o.input]}:l={modality:p,requests:o.input},{modelName:t,config:r,embeddingRequests:l}}transformConfig(e,s){let o=this.modelSchema.config.schema.safeParse(e);if(!o.success)throw new InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:o.error});let t=o.data;return Object.keys(t).forEach(r=>{if(!this.modelSchema.config.def[r])throw new InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error(`Invalid config key : '${r}',
12
+ available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}})}}transformTools(e){if(!this.modelSchema.modalities.includes(ToolCallModalityLiteral))throw new InvalidToolsError({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${ToolCallModalityLiteral}'`)});return !e||e&&e.length===0?{tools:[]}:{tools:e.map(t=>{let n=Tool().safeParse(t);if(!n.success)throw new InvalidToolsError({info:"Invalid tools",cause:n.error});return n.data}).map(t=>({type:"function",function:t.definition.schema}))}}getCompleteChatUrl(e,s,o){return k(this,null,function*(){return new Promise(t=>{t(this.completeChatUrl);})})}getCompleteChatHeaders(e,s,o){return k(this,null,function*(){return new Promise(t=>{t(this.getDefaultHeaders());})})}getCompleteChatData(e,s,o){return k(this,null,function*(){let t=this.transformConfig(e,s,o),n=this.transformMessages(s);if(n.messages&&n.messages.length===0)throw new InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let r=o?this.transformTools(o):{};return new Promise(l=>{l(b(b(b(b({},this.getDefaultParams()),t),n),r));})})}transformCompleteChatResponse(e){let s=zs.safeParse(e);if(s.success){if(s.data.choices.length===0)throw new ModelResponseError({info:"Invalid response from model",cause:new Error(`No choices in response : ${JSON.stringify(s.data)}`)});let o=s.data,t=[{role:AssistantRoleLiteral,content:[]}],n=o.choices[0].message;n.content&&t[0].content.push(createTextContent(n.content)),n.refusal&&t[0].content.push(createTextContent(n.refusal)),n.tool_calls&&n.tool_calls.forEach((_,T)=>{t[0].content.push(createToolCallContent(T,_.id,_.function.name,_.function.arguments));});let r={promptTokens:o.usage.prompt_tokens,completionTokens:o.usage.completion_tokens,totalTokens:o.usage.total_tokens},l=[],p=o.choices[0].logprobs;return p&&(p.content&&l.push(...p.content.map(_=>({token:_.token,logProb:_.logprob,bytes:_.bytes,topLogProbs:_.top_logprobs.map(T=>({token:T.token,logProb:T.logprob,bytes:T.bytes}))}))),p.refusal&&l.push(...p.refusal.map(_=>({token:_.token,logProb:_.logprob,bytes:_.bytes,topLogProbs:_.top_logprobs.map(T=>({token:T.token,logProb:T.logprob,bytes:T.bytes}))})))),{messages:t,usage:r,logProbs:l}}throw new ModelResponseError({info:"Invalid response from model",cause:s.error})}getStreamChatUrl(e,s,o){return k(this,null,function*(){return new Promise(t=>{t(this.streamChatUrl);})})}getStreamChatHeaders(e,s,o){return k(this,null,function*(){return new Promise(t=>{t(this.getDefaultHeaders());})})}getStreamChatData(e,s,o){return k(this,null,function*(){let t=this.transformConfig(e,s,o),n=this.transformMessages(s);if(n.messages&&n.messages.length===0)throw new InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let r=o?this.transformTools(o):{};return new Promise(l=>{l(b(b(b(b({stream:true,stream_options:{include_usage:true}},this.getDefaultParams()),t),n),r));})})}transformStreamChatResponseChunk(e,s){return ie(this,null,function*(){var l,p;let o=s+e,t=[],n="",r=0;for(;r<o.length;){let _=o.indexOf(`
13
+ `,r);if(_===-1){n=o.substring(r);break}else {let T=o.substring(r,_).trim();T&&t.push(T),r=_+1;}}for(let _ of t){if(_==="data: [DONE]")return;if(_.startsWith("data: ")){let T=_.substring(6);try{let x=JSON.parse(T),O=Bs.safeParse(x);if(O.success){let I={partialMessages:[]},R=O.data;if(R.choices.length>0){let L=R.choices[0].delta;if(L!==void 0&&Object.keys(L).length!==0){if("content"in L&&L.content!==null)I.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,L.content));else if("refusal"in L&&L.refusal!==null)I.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,L.refusal));else if("tool_calls"in L&&L.tool_calls!==void 0){let S=L.tool_calls.at(0);I.partialMessages.push(createPartialToolCallMessage(AssistantRoleLiteral,S.index,S.id,(l=S.function)==null?void 0:l.name,(p=S.function)==null?void 0:p.arguments));}}}R.usage&&(I.usage={promptTokens:R.usage.prompt_tokens,completionTokens:R.usage.completion_tokens,totalTokens:R.usage.total_tokens}),yield {partialResponse:I,buffer:n};}else throw new ModelResponseError({info:"Invalid response from model",cause:O.error})}catch(x){throw new ModelResponseError({info:`Malformed JSON received in stream: ${T}`,cause:x})}}}yield {partialResponse:{partialMessages:[]},buffer:n};})}transformProxyStreamChatResponseChunk(e,s,o,t,n){return ie(this,null,function*(){yield*Me(this.transformStreamChatResponseChunk(e,s));})}getProxyStreamChatUrl(e,s,o){return k(this,null,function*(){return new Promise(t=>{t(this.streamChatUrl);})})}getProxyCompleteChatUrl(e,s,o){return k(this,null,function*(){return new Promise(t=>{t(this.completeChatUrl);})})}getProxyCompleteChatHeaders(e,s,o){return k(this,null,function*(){if(!s)return {};let t=b({},s);return delete t.host,delete t["content-length"],t})}getProxyStreamChatHeaders(e,s,o){return k(this,null,function*(){return yield this.getProxyCompleteChatHeaders(e,s,o)})}getModelPricing(){if(!(this.modelName in f))throw new ModelResponseError({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return f[this.modelName]}};var yn=z.object({modelName:z.string(),apiKey:z.string(),baseUrl:z.string().url().optional(),organization:z.string().optional()}),Yo=class{constructor(e,s){this.version="v1";let o=yn.parse(s);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=urlWithoutTrailingSlash(o.baseUrl||K.baseUrl),this.responsesUrl=`${this.baseUrl}/responses`,this.organization=o.organization;}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return b({Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"},this.organization?{"OpenAI-Organization":this.organization}:{})}getDefaultParams(){return {model:this.modelName}}getRetryDelay(e,s){let o=p=>{let _=/(\d+)(h|m|s|ms)/g,T={h:36e5,m:6e4,s:1e3,ms:1},x,O=0;for(;(x=_.exec(p))!==null;){let I=parseInt(x[1]),R=x[2];O+=I*T[R];}return O},t=0,n=0,r=true;e["x-ratelimit-reset-requests"]&&(t=o(e["x-ratelimit-reset-requests"])),e["x-ratelimit-reset-tokens"]&&(n=o(e["x-ratelimit-reset-tokens"]));let l=Math.max(t,n);return {shouldRetry:r,delayMs:l}}getTokenCount(e){return e.reduce((s,o)=>s+o.content.map(t=>t.modality==="text"?t.value:"").join(" ").length,0)}transformModelRequest(e){throw new ModelResponseError({info:"transformModelRequest not supported for Responses API models",cause:new Error("Use the standard gateway interface with config, messages, and tools parameters")})}transformConfig(e,s,o){let t=Config().parse(e),n={};for(let p of Object.keys(this.modelSchema.config.def)){let _=this.modelSchema.config.def[p],T=_==null?void 0:_.param;T&&t[p]!==void 0&&(n[T]=t[p]);}let r=t.toolChoice;if(r!==void 0)if(o&&o.length>0){let p=r,_=o.map(T=>T.definition.schema.name);if(["none","auto","required"].includes(p))n.tool_choice=p;else if(_.includes(p))n.tool_choice={type:"function",function:{name:p}};else throw new InvalidConfigError({info:`Invalid tool choice for model : '${this.modelName}'`,cause:new Error(`Tool with name '${p}' not found in tools`)})}else throw new InvalidConfigError({info:`Invalid tool choice for model : '${this.modelName}'`,cause:new Error("Tools are required when tool_choice is specified")});let l=t.responseFormat;if(l!==void 0)if(l==="json_schema"){if(!t.responseSchema)throw new InvalidConfigError({info:`Invalid response schema for model : '${this.modelName}'`,cause:new Error("Response schema is required when response format is 'json_schema'")});n.response_format={type:l,json_schema:n.response_schema},delete n.response_schema;}else n.response_format={type:l};return "reasoning_effort"in n&&n.reasoning_effort!==void 0&&(n.reasoning={effort:n.reasoning_effort},delete n.reasoning_effort),"verbosity"in n&&n.verbosity!==void 0&&(n.text={verbosity:n.verbosity},delete n.verbosity),n}transformMessages(e){if(!e||e.length===0)return {messages:[]};let s=e.map(t=>{let n=Message().safeParse(t);if(!n.success)throw new InvalidMessagesError({info:"Invalid messages",cause:n.error});return n.data});return s.forEach(t=>{t.content.forEach(n=>{if(!this.modelSchema.modalities.includes(n.modality))throw new InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${n.modality}'`)})});}),s.forEach(t=>{if(!Object.keys(this.modelSchema.roles).includes(t.role))throw new InvalidMessagesError({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${t.role}'`)})}),s.forEach(t=>{t.content=t.content.filter(n=>n.modality!=="error"&&n.modality!=="search-result");}),{messages:s.map(t=>{switch(t.role){case SystemRoleLiteral:{let n=[];return t.content.forEach(r=>{if(r.modality===TextModalityLiteral)n.push({type:"input_text",text:r.value});else throw new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${t.role}' cannot have content with modality : '${r.modality}'`)})}),{role:this.modelSchema.roles[t.role],content:n}}case AssistantRoleLiteral:{let n=[];return t.content.forEach(r=>{if(r.modality===TextModalityLiteral)n.push({type:"output_text",text:r.value});else throw r.modality===ToolCallModalityLiteral?new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error("tool calls in message history are not supported for Responses API")}):new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${t.role}' cannot have content with modality : '${r.modality}'`)})}),{role:this.modelSchema.roles[t.role],content:n}}case UserRoleLiteral:{let n=[];return t.content.forEach(r=>{if(r.modality===TextModalityLiteral)n.push({type:"input_text",text:r.value});else if(r.modality===ImageModalityLiteral){let l=r.value,p=l.type==="url"?l.url:l.base64;n.push({type:"image_url",image_url:{url:p,detail:r.detail}});}else throw new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${t.role}' cannot have content with modality : '${r.modality}'`)})}),{role:this.modelSchema.roles[t.role],content:n}}case ToolRoleLiteral:{if(t.content.length!==1)throw new InvalidMessagesError({info:`Invalid message for role : '${t.role}'`,cause:new Error(`role : '${t.role}' must have exactly one content item`)});if(t.content[0].modality!==ToolResponseModalityLiteral)throw new InvalidMessagesError({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${t.role}' must have content with modality : '${ToolResponseModalityLiteral}'`)});let n=t.content[0];return {role:this.modelSchema.roles[t.role],tool_call_id:n.id,content:n.data}}default:throw new InvalidMessagesError({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${t.role}' is not supported`)})}})}}transformTools(e){if(!e||e.length===0)return {tools:[]};if(!this.modelSchema.modalities.includes(ToolCallModalityLiteral))throw new InvalidToolsError({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality`)});return {tools:e.map(t=>{let n=Tool().safeParse(t);if(!n.success)throw new InvalidToolsError({info:"Invalid tools",cause:n.error});return n.data}).map(t=>({type:"function",function:t.definition.schema}))}}getCompleteChatUrl(e,s,o){return k(this,null,function*(){return Promise.resolve(this.responsesUrl)})}getCompleteChatHeaders(e,s,o){return k(this,null,function*(){return Promise.resolve(this.getDefaultHeaders())})}getCompleteChatData(e,s,o){return k(this,null,function*(){let t=this.transformConfig(e,s,o),n=this.transformMessages(s);if(n.messages&&n.messages.length===0)throw new InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let r=o?this.transformTools(o):{};return Promise.resolve(q(b(b(b({},this.getDefaultParams()),t),r),{input:n.messages}))})}transformCompleteChatResponse(e){var n,r,l,p,_,T,x,O,I,R,L;let s=(e==null?void 0:e.output)||(e==null?void 0:e.outputs);if(!s||!Array.isArray(s)||s.length===0)throw new ModelResponseError({info:"Invalid response from model",cause:new Error(`No output in response : ${JSON.stringify(e)}`)});let o=[{role:AssistantRoleLiteral,content:[]}];for(let S of s)if((S==null?void 0:S.type)==="message"&&Array.isArray(S.content))S.content.forEach(A=>{var U,C,D,H,E,P;if((A==null?void 0:A.type)==="text"||(A==null?void 0:A.type)==="output_text")A.text&&o[0].content.push(createTextContent(A.text));else if((A==null?void 0:A.type)==="tool_call"&&A.tool_call){let V=A.tool_call;o[0].content.push(createToolCallContent((U=V.index)!=null?U:0,(C=V.id)!=null?C:"",(H=(D=V.function)==null?void 0:D.name)!=null?H:"",(P=(E=V.function)==null?void 0:E.arguments)!=null?P:""));}});else if(((S==null?void 0:S.type)==="text"||(S==null?void 0:S.type)==="output_text")&&(S!=null&&S.text))o[0].content.push(createTextContent(S.text));else if((S==null?void 0:S.type)==="tool_call"&&S.tool_call){let A=S.tool_call;o[0].content.push(createToolCallContent((n=A.index)!=null?n:0,(r=A.id)!=null?r:"",(p=(l=A.function)==null?void 0:l.name)!=null?p:"",(T=(_=A.function)==null?void 0:_.arguments)!=null?T:""));}if(o[0].content.length===0){let S=s[0],A=(S==null?void 0:S.content)||[],U=[];if(A.forEach(C=>{((C==null?void 0:C.type)==="text"||(C==null?void 0:C.type)==="output_text")&&(C!=null&&C.text)&&U.push(C.text);}),U.length>0)o[0].content.push(createTextContent(U.join(`
14
+ `)));else throw new ModelResponseError({info:"Invalid response from model",cause:new Error(`No text content found in response : ${JSON.stringify(e)}`)})}let t=e.usage||{};return {messages:o,usage:{promptTokens:(O=(x=t.input_tokens)!=null?x:t.prompt_tokens)!=null?O:0,completionTokens:(R=(I=t.output_tokens)!=null?I:t.completion_tokens)!=null?R:0,totalTokens:(L=t.total_tokens)!=null?L:(t.input_tokens||0)+(t.output_tokens||0)}}}getStreamChatUrl(e,s,o){return k(this,null,function*(){return Promise.resolve(this.responsesUrl)})}getStreamChatHeaders(e,s,o){return k(this,null,function*(){return Promise.resolve(q(b({},this.getDefaultHeaders()),{Accept:"text/event-stream"}))})}getStreamChatData(e,s,o){return k(this,null,function*(){let t=this.transformConfig(e,s,o),n=this.transformMessages(s);if(n.messages&&n.messages.length===0)throw new InvalidMessagesError({info:"Messages are required",cause:new Error("Messages are required")});let r=o?this.transformTools(o):{};return Promise.resolve(q(b(b(b({},this.getDefaultParams()),t),r),{input:n.messages,stream:true}))})}transformStreamChatResponseChunk(e,s){return ie(this,null,function*(){var l,p,_,T,x,O,I,R,L,S;let o=s+e,t=[],n="",r=0;for(;r<o.length;){let A=o.indexOf(`
15
+ `,r);if(A===-1){n=o.substring(r);break}else {let U=o.substring(r,A).trim();U&&t.push(U),r=A+1;}}for(let A of t){if(A==="data: [DONE]")return;if(A.startsWith("data: ")){let U=A.substring(6);try{let C=JSON.parse(U),D={partialMessages:[]},H=!1;if((C.type==="response.output_text.delta"||C.type==="output_text.delta")&&typeof C.delta=="string"&&C.delta.length>0&&(D.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,C.delta)),H=!0),C.type==="response.content_part.added"&&C.part){let E=C.part;E.type==="output_text"&&typeof E.text=="string"&&E.text.length>0&&(D.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,E.text)),H=!0);}if(!H&&C.delta){let E=C.delta;typeof E=="string"&&E.length>0?(D.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,E)),H=!0):E&&typeof E=="object"&&E.text!==void 0&&E.text!==null?(D.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,E.text)),H=!0):Array.isArray(E.content)&&E.content.forEach(P=>{var V,me,de,ce;if((P==null?void 0:P.type)==="output_text"&&(P!=null&&P.text))D.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,P.text)),H=!0;else if((P==null?void 0:P.type)==="tool_call"&&(P!=null&&P.tool_call)){let G=P.tool_call;D.partialMessages.push(createPartialToolCallMessage(AssistantRoleLiteral,(V=G.index)!=null?V:0,(me=G.id)!=null?me:"",(de=G.function)==null?void 0:de.name,(ce=G.function)==null?void 0:ce.arguments)),H=!0;}});}if((C.type==="tool_call"||C.type==="tool_call.delta"||C.type==="response.tool_call.delta")&&(l=C.delta)!=null&&l.tool_call){let E=C.delta.tool_call;D.partialMessages.push(createPartialToolCallMessage(AssistantRoleLiteral,(p=E.index)!=null?p:0,(_=E.id)!=null?_:"",(T=E.function)==null?void 0:T.name,(x=E.function)==null?void 0:x.arguments));}if(!C.delta&&(C.output||C.outputs)){let E=C.output||C.outputs;Array.isArray(E)&&E.forEach(P=>{var V,me,de,ce;if((P==null?void 0:P.type)==="message"&&Array.isArray(P.content))P.content.forEach(G=>{var Cn,On,Pn,bn;if(((G==null?void 0:G.type)==="text"||(G==null?void 0:G.type)==="output_text")&&(G!=null&&G.text))D.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,G.text));else if((G==null?void 0:G.type)==="tool_call"&&(G!=null&&G.tool_call)){let Te=G.tool_call;D.partialMessages.push(createPartialToolCallMessage(AssistantRoleLiteral,(Cn=Te.index)!=null?Cn:0,(On=Te.id)!=null?On:"",(Pn=Te.function)==null?void 0:Pn.name,(bn=Te.function)==null?void 0:bn.arguments));}});else if(((P==null?void 0:P.type)==="text"||(P==null?void 0:P.type)==="output_text")&&(P!=null&&P.text))D.partialMessages.push(createPartialTextMessage(AssistantRoleLiteral,P.text));else if((P==null?void 0:P.type)==="tool_call"&&(P!=null&&P.tool_call)){let G=P.tool_call;D.partialMessages.push(createPartialToolCallMessage(AssistantRoleLiteral,(V=G.index)!=null?V:0,(me=G.id)!=null?me:"",(de=G.function)==null?void 0:de.name,(ce=G.function)==null?void 0:ce.arguments));}});}C.usage&&(D.usage={promptTokens:(I=(O=C.usage.input_tokens)!=null?O:C.usage.prompt_tokens)!=null?I:0,completionTokens:(L=(R=C.usage.output_tokens)!=null?R:C.usage.completion_tokens)!=null?L:0,totalTokens:(S=C.usage.total_tokens)!=null?S:(C.usage.input_tokens||0)+(C.usage.output_tokens||0)}),(D.partialMessages.length>0||D.usage)&&(yield {partialResponse:D,buffer:n});}catch(C){throw new ModelResponseError({info:`Malformed JSON received in stream: ${U}`,cause:C})}}}})}transformProxyStreamChatResponseChunk(e,s,o,t,n){return ie(this,null,function*(){yield*Me(this.transformStreamChatResponseChunk(e,s));})}getProxyStreamChatUrl(e,s,o){return k(this,null,function*(){return Promise.resolve(this.responsesUrl)})}getProxyCompleteChatUrl(e,s,o){return k(this,null,function*(){return Promise.resolve(this.responsesUrl)})}getProxyCompleteChatHeaders(e,s,o){return k(this,null,function*(){if(!s)return {};let t=b({},s);return delete t.host,delete t["content-length"],t})}getProxyStreamChatHeaders(e,s,o){return k(this,null,function*(){let t=yield this.getProxyCompleteChatHeaders(e,s,o);return q(b({},t),{Accept:"text/event-stream"})})}getModelPricing(){if(!(this.modelName in f))throw new ModelResponseError({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return f[this.modelName]}};var ct="chatgpt-5.2",ia="ChatGPT-5.2 model optimized for conversational workloads with tool/function calling support. Training data up to January 2025.",ht=ChatModelSchema(m,M).parse({name:ct,description:ia,maxInputTokens:4e5,maxOutputTokens:131072,roles:d,modalities:y,config:{def:a.gpt5(131072,4).def,schema:a.gpt5(131072,4).schema},price:f["gpt-5.2"]}),Vn=h,Se=class extends c{constructor(e){super(ht,e);}};var Ie="gpt-3.5-turbo-0125",ra="The latest GPT-3.5 Turbo model with higher accuracy at responding in requested formats and a fix for a bug which caused a text encoding issue for non-English language function calls. Training data up to Sept 2021.",ut=ChatModelSchema(m,v).parse({name:Ie,description:ra,maxInputTokens:4092,maxOutputTokens:4092,roles:d,modalities:w,config:{def:a.responseFormat(4092,4).def,schema:a.responseFormat(4092,4).schema},price:f[Ie]}),Jn=h,Re=class extends c{constructor(e){super(ut,e);}};var Ae="gpt-3.5-turbo-1106",pa="The latest GPT-3.5 Turbo model with improved instruction following, JSON mode, reproducible outputs, parallel function calling, and more. Returns a maximum of 4,096 output tokens. Training data up to Sept 2021.",ft=ChatModelSchema(m,v).parse({name:Ae,description:pa,maxInputTokens:4092,maxOutputTokens:16385,roles:d,modalities:w,config:{def:a.responseFormat(16385,4).def,schema:a.responseFormat(16385,4).schema},price:f[Ae]}),Kn=h,Ge=class extends c{constructor(e){super(ft,e);}};var Ee="gpt-3.5-turbo",da="Currently points to gpt-3.5-turbo-0125. Training data up to Sept 2021.",_t=ChatModelSchema(m,v).parse({name:Ee,description:da,maxInputTokens:4092,maxOutputTokens:4092,roles:d,modalities:w,config:{def:a.responseFormat(4092,4).def,schema:a.responseFormat(4092,4).schema},price:f[Ee]}),Wn=h,ke=class extends c{constructor(e){super(_t,e);}};var we="gpt-4-0125-preview",ha="The latest GPT-4 model intended to reduce cases of \u201Claziness\u201D where the model doesn\u2019t complete a task. Training data up to Apr 2023.",gt=ChatModelSchema(m,v).parse({name:we,description:ha,maxInputTokens:128e3,maxOutputTokens:4092,roles:d,modalities:w,config:{def:a.base(4092,4).def,schema:a.base(4092,4).schema},price:f[we]}),Yn=h,ve=class extends c{constructor(e){super(gt,e);}};var Le="gpt-4-0613",fa="Snapshot of gpt-4 from June 13th 2023 with improved function calling support. Training data up to Sept 2021.",Tt=ChatModelSchema(m,v).parse({name:Le,description:fa,maxInputTokens:8192,maxOutputTokens:4092,roles:d,modalities:w,config:{def:a.base(4092,4).def,schema:a.base(4092,4).schema},price:f[Le]}),Qn=h,De=class extends c{constructor(e){super(Tt,e);}};var Ne="gpt-4-1106-preview",ga="GPT-4 Turbo model featuring improved instruction following, JSON mode, reproducible outputs, parallel function calling, and more. Returns a maximum of 4,096 output tokens. This preview model is not yet suited for production traffic. Training data up to Apr 2023.",yt=ChatModelSchema(m,v).parse({name:Ne,description:ga,maxInputTokens:128e3,maxOutputTokens:4092,roles:d,modalities:w,config:{def:a.base(4092,4).def,schema:a.base(4092,4).schema},price:f[Ne]}),Xn=h,qe=class extends c{constructor(e){super(yt,e);}};var ze="gpt-4.1",ya="Flagship model for complex tasks. It is well suited for problem solving across domains. Training data up to May 2024.",Mt=ChatModelSchema(m,M).parse({name:ze,description:ya,maxInputTokens:1047576,maxOutputTokens:32768,roles:d,modalities:y,config:{def:a.responseSchema(32768,4).def,schema:a.responseSchema(32768,4).schema},price:f[ze]}),Zn=h,Be=class extends c{constructor(e){super(Mt,e);}};var Ue="gpt-4.1-mini",Ca="Provides a balance between intelligence, speed, and cost that makes it an attractive model for many use cases. Training data up to May 2024.",Ct=ChatModelSchema(m,M).parse({name:Ue,description:Ca,maxInputTokens:1047576,maxOutputTokens:32768,roles:d,modalities:y,config:{def:a.responseSchema(32768,4).def,schema:a.responseSchema(32768,4).schema},price:f[Ue]}),es=h,je=class extends c{constructor(e){super(Ct,e);}};var $e="gpt-4.1-nano",Pa="Fastest, most cost-effective GPT-4.1 model. Training data up to May 2024.",Ot=ChatModelSchema(m,M).parse({name:$e,description:Pa,maxInputTokens:1047576,maxOutputTokens:32768,roles:d,modalities:y,config:{def:a.responseSchema(32768,4).def,schema:a.responseSchema(32768,4).schema},price:f[$e]}),os=h,Fe=class extends c{constructor(e){super(Ot,e);}};var He="gpt-5.1",xa="Flagship GPT-5.1 model for coding and agentic tasks with configurable reasoning effort. Training data up to September 2024.",Pt=ChatModelSchema(m,M).parse({name:He,description:xa,maxInputTokens:4e5,maxOutputTokens:128e3,roles:d,modalities:y,config:{def:a.gpt5(128e3,4).def,schema:a.gpt5(128e3,4).schema},price:f[He]}),ts=h,Ve=class extends c{constructor(e){super(Pt,e);}};var Je="gpt-5.2",Ia="Flagship GPT-5.2 model with enhanced reasoning controls and extended knowledge coverage. Training data up to January 2025.",bt=ChatModelSchema(m,M).parse({name:Je,description:Ia,maxInputTokens:4e5,maxOutputTokens:131072,roles:d,modalities:y,config:{def:a.gpt5(131072,4).def,schema:a.gpt5(131072,4).schema},price:f[Je]}),ns=h,Ke=class extends c{constructor(e){super(bt,e);}};var We="gpt-5.2-chat-latest",Aa="Latest GPT-5.2 chat-optimized model for conversational workloads with tool/function calling support. Training data up to January 2025.",Ga=y,Ea=M,xt=ChatModelSchema(m,Ea).parse({name:We,description:Aa,maxInputTokens:4e5,maxOutputTokens:131072,roles:d,modalities:Ga,config:{def:a.gpt5(131072,4).def,schema:a.gpt5(131072,4).schema},price:f[We]}),ss=h,Ye=class extends c{constructor(e){super(xt,e);}};var Qe="gpt-5.2-codex",wa="Coding-optimized GPT-5.2 Codex model for software engineering, debugging, and autonomous coding workflows.",St=ChatModelSchema(m,M).parse({name:Qe,description:wa,maxInputTokens:4e5,maxOutputTokens:131072,roles:d,modalities:y,config:{def:a.gpt5(131072,4).def,schema:a.gpt5(131072,4).schema},price:f[Qe]}),is=h,Xe=class extends c{constructor(e){super(St,e);}};var Ze="gpt-5.2-pro",La="GPT-5.2 Pro available via the OpenAI Responses API for advanced reasoning and agentic workflows. Training data up to January 2025.",It=ChatModelSchema(m,M).parse({name:Ze,description:La,maxInputTokens:4e5,maxOutputTokens:131072,roles:d,modalities:y,config:{def:a.gpt5(131072,4).def,schema:a.gpt5(131072,4).schema},price:f[Ze]}),as=yn,eo=class extends Yo{constructor(e){super(It,e);}};var oo="gpt-5.3-codex",Na="Latest coding-optimized GPT-5.3 Codex model for high-reliability code generation, edits, and agentic software tasks.",Rt=ChatModelSchema(m,M).parse({name:oo,description:Na,maxInputTokens:4e5,maxOutputTokens:131072,roles:d,modalities:y,config:{def:a.gpt5(131072,4).def,schema:a.gpt5(131072,4).schema},price:f[oo]}),rs=h,to=class extends c{constructor(e){super(Rt,e);}};var no="gpt-5",za="Most advanced GPT-5 model for complex reasoning and problem-solving tasks. Training data up to October 2024.",At=ChatModelSchema(m,M).parse({name:no,description:za,maxInputTokens:4e5,maxOutputTokens:131072,roles:d,modalities:y,config:{def:a.gpt5(131072,4).def,schema:a.gpt5(131072,4).schema},price:f[no]}),ls=h,so=class extends c{constructor(e){super(At,e);}};var io="gpt-5-mini",Ua="Faster, more cost-effective GPT-5 model that balances intelligence and efficiency. Training data up to October 2024.",Gt=ChatModelSchema(m,M).parse({name:io,description:Ua,maxInputTokens:4e5,maxOutputTokens:131072,roles:d,modalities:y,config:{def:a.gpt5(131072,4).def,schema:a.gpt5(131072,4).schema},price:f[io]}),ps=h,ao=class extends c{constructor(e){super(Gt,e);}};var ro="gpt-5-nano",$a="Most cost-effective GPT-5 model optimized for speed and efficiency. Training data up to October 2024.",Et=ChatModelSchema(m,M).parse({name:ro,description:$a,maxInputTokens:4e5,maxOutputTokens:131072,roles:d,modalities:y,config:{def:a.gpt5(131072,4).def,schema:a.gpt5(131072,4).schema},price:f[ro]}),ms=h,lo=class extends c{constructor(e){super(Et,e);}};var po="gpt-5-chat-latest",Va="Latest GPT-5 model optimized for conversational use. Does not support function calling or structured outputs. Training data up to October 2024.",Ja=[TextModalityLiteral,ImageModalityLiteral],Ka=z.enum([TextModalityLiteral,ImageModalityLiteral]),kt=ChatModelSchema(m,Ka).parse({name:po,description:Va,maxInputTokens:4e5,maxOutputTokens:131072,roles:d,modalities:Ja,config:{def:a.gpt5(131072,4).def,schema:a.gpt5(131072,4).schema},price:f[po]}),ds=h,mo=class extends c{constructor(e){super(kt,e);}};var co="gpt-4-turbo-2024-04-09",Ya="GPT-4 Turbo with Vision model. Vision requests can now use JSON mode and function calling. gpt-4-turbo currently points to this version. Training data up to Dec 2023.",wt=ChatModelSchema(m,M).parse({name:co,description:Ya,maxInputTokens:128e3,maxOutputTokens:4096,roles:d,modalities:y,config:{def:a.responseFormat(4096,4).def,schema:a.responseFormat(4096,4).schema},price:f[co]}),cs=h,ho=class extends c{constructor(e){super(wt,e);}};var uo="gpt-4-turbo-preview",Xa="Currently points to gpt-4-0125-preview. Training data up to Apr 2023.",vt=ChatModelSchema(m,v).parse({name:uo,description:Xa,maxInputTokens:128e3,maxOutputTokens:4092,roles:d,modalities:w,config:{def:a.responseFormat(4092,4).def,schema:a.responseFormat(4092,4).schema},price:f[uo]}),hs=h,fo=class extends c{constructor(e){super(vt,e);}};var _o="gpt-4-turbo",er="The latest GPT-4 Turbo model with vision capabilities. Vision requests can now use JSON mode and function calling. Currently points to gpt-4-turbo-2024-04-09. Training data up to Dec 2023.",Lt=ChatModelSchema(m,M).parse({name:_o,description:er,maxInputTokens:128e3,maxOutputTokens:4092,roles:d,modalities:y,config:{def:a.responseFormat(4092,4).def,schema:a.responseFormat(4092,4).schema},price:f[_o]}),us=h,go=class extends c{constructor(e){super(Lt,e);}};var To="gpt-4",tr="Currently points to gpt-4-0613. Training data up to Sept 2021.",Dt=ChatModelSchema(m,v).parse({name:To,description:tr,maxInputTokens:8192,maxOutputTokens:4092,roles:d,modalities:w,config:{def:a.base(4092,4).def,schema:a.base(4092,4).schema},price:f[To]}),fs=h,yo=class extends c{constructor(e){super(Dt,e);}};var Mo="gpt-4o-2024-05-13",sr="Latest snapshot of gpt-4o that supports Structured Outputs. Training data up to Oct 2023.",Nt=ChatModelSchema(m,M).parse({name:Mo,description:sr,maxInputTokens:128e3,maxOutputTokens:4092,roles:d,modalities:y,config:{def:a.responseSchema(4092,4).def,schema:a.responseSchema(4092,4).schema},price:f[Mo]}),_s=h,Co=class extends c{constructor(e){super(Nt,e);}};var Oo="gpt-4o-2024-08-06",ar="Latest snapshot of gpt-4o that supports Structured Outputs. Training data up to Oct 2023.",qt=ChatModelSchema(m,M).parse({name:Oo,description:ar,maxInputTokens:128e3,maxOutputTokens:4092,roles:d,modalities:y,config:{def:a.responseSchema(4092,4).def,schema:a.responseSchema(4092,4).schema},price:f[Oo]}),gs=h,Po=class extends c{constructor(e){super(qt,e);}};var bo="gpt-4o-mini-2024-07-18",lr="Most advanced, multimodal flagship model that is cheaper and faster than GPT-4 Turbo. Currently points to gpt-4o-2024-05-13. Training data up to Oct 2023.",zt=ChatModelSchema(m,M).parse({name:bo,description:lr,maxInputTokens:128e3,maxOutputTokens:4092,roles:d,modalities:y,config:{def:a.responseSchema(4092,4).def,schema:a.responseSchema(4092,4).schema},price:f[bo]}),Ts=h,xo=class extends c{constructor(e){super(zt,e);}};var So="gpt-4o-mini",mr="Most advanced, multimodal flagship model that is cheaper and faster than GPT-4 Turbo. Currently points to gpt-4o-2024-05-13. Training data up to Oct 2023.",Bt=ChatModelSchema(m,M).parse({name:So,description:mr,maxInputTokens:128e3,maxOutputTokens:4092,roles:d,modalities:y,config:{def:a.responseSchema(4092,4).def,schema:a.responseSchema(4092,4).schema},price:f[So]}),ys=h,Io=class extends c{constructor(e){super(Bt,e);}};var Ro="gpt-4o",cr="Most advanced, multimodal flagship model that is cheaper and faster than GPT-4 Turbo. Currently points to gpt-4o-2024-05-13. Training data up to Oct 2023.",Ut=ChatModelSchema(m,M).parse({name:Ro,description:cr,maxInputTokens:128e3,maxOutputTokens:4092,roles:d,modalities:y,config:{def:a.responseSchema(4092,4).def,schema:a.responseSchema(4092,4).schema},price:f[Ro]}),Ms=h,Ao=class extends c{constructor(e){super(Ut,e);}};var Go="chatgpt-4o-latest",fr="Latest ChatGPT-4o chat model optimized for conversational quality. Does not support function calling or structured outputs.",_r=[TextModalityLiteral,ImageModalityLiteral],gr=z.enum([TextModalityLiteral,ImageModalityLiteral]),jt=ChatModelSchema(m,gr).parse({name:Go,description:fr,maxInputTokens:128e3,maxOutputTokens:16384,roles:d,modalities:_r,config:{def:a.responseFormat(16384,4).def,schema:a.responseFormat(16384,4).schema},price:f[Go]}),Cs=h,Eo=class extends c{constructor(e){super(jt,e);}};var ko="o1-2024-12-17",yr="A stable release model for production use, offering robust performance and advanced features. Training data up to December 2024.",$t=ChatModelSchema(m,M).parse({name:ko,description:yr,maxInputTokens:2e5,maxOutputTokens:1e5,roles:d,modalities:y,config:{def:a.o1Series(1e5,4).def,schema:a.o1Series(1e5,4).schema},price:f[ko]}),Os=h,wo=class extends c{constructor(e){super($t,e);}};var vo="o1",Cr="Highly capable general-purpose reasoning model with advanced capabilities in language, coding, and reasoning. Training data up to Oct 2023.",Ft=ChatModelSchema(m,M).parse({name:vo,description:Cr,maxInputTokens:2e5,maxOutputTokens:1e5,roles:d,modalities:y,config:{def:a.o1Series(1e5,4).def,schema:a.o1Series(1e5,4).schema},price:f[vo]}),Ps=h,Lo=class extends c{constructor(e){super(Ft,e);}};var Ht="o3-2025-04-16",Pr="A new standard for math, science, coding, and visual reasoning tasks. Training data up to Jun 2024.",Vt=ChatModelSchema(m,M).parse({name:Ht,description:Pr,maxInputTokens:2e5,maxOutputTokens:1e5,roles:d,modalities:y,config:{def:a.oSeries(1e5,4).def,schema:a.oSeries(1e5,4).schema}}),bs=h,Do=class extends c{constructor(e){super(Vt,e);}};var Jt="o3",xr="A new standard for math, science, coding, and visual reasoning tasks. Training data up to Jun 2024.",Kt=ChatModelSchema(m,M).parse({name:Jt,description:xr,maxInputTokens:2e5,maxOutputTokens:1e5,roles:d,modalities:y,config:{def:a.oSeries(1e5,4).def,schema:a.oSeries(1e5,4).schema}}),xs=h,No=class extends c{constructor(e){super(Kt,e);}};var Wt="o3-mini",Ir="o3-mini is the newest small reasoning model, providing high intelligence at the same cost and latency targets of o1-mini. Training data up to Sep 2023.",Yt=ChatModelSchema(m,v).parse({name:Wt,description:Ir,maxInputTokens:2e5,maxOutputTokens:1e5,roles:d,modalities:w,config:{def:a.oSeries(1e5,4).def,schema:a.oSeries(1e5,4).schema}}),Ss=h,qo=class extends c{constructor(e){super(Yt,e);}};var Qt="o3-mini-2025-01-31",Ar="o3-mini is the newest small reasoning model, providing high intelligence at the same cost and latency targets of o1-mini. Training data up to Sep 2023.",Xt=ChatModelSchema(m,v).parse({name:Qt,description:Ar,maxInputTokens:2e5,maxOutputTokens:1e5,roles:d,modalities:w,config:{def:a.oSeries(1e5,4).def,schema:a.oSeries(1e5,4).schema}}),Is=h,zo=class extends c{constructor(e){super(Xt,e);}};var Zt="o4-mini-2025-04-16",Er="Optimized for fast, effective reasoning with exceptionally efficient performance in coding and visual tasks. Training data up to Jun 2024.",en=ChatModelSchema(m,M).parse({name:Zt,description:Er,maxInputTokens:2e5,maxOutputTokens:1e5,roles:d,modalities:y,config:{def:a.oSeries(1e5,4).def,schema:a.oSeries(1e5,4).schema}}),Rs=h,Bo=class extends c{constructor(e){super(en,e);}};var on="o4-mini",wr="Optimized for fast, effective reasoning with exceptionally efficient performance in coding and visual tasks. Training data up to Jun 2024.",tn=ChatModelSchema(m,M).parse({name:on,description:wr,maxInputTokens:2e5,maxOutputTokens:1e5,roles:d,modalities:y,config:{def:a.oSeries(1e5,4).def,schema:a.oSeries(1e5,4).schema}}),As=h,Uo=class extends c{constructor(e){super(tn,e);}};var le=[EmbeddingTextModalityLiteral,EmbeddingTokenModalityLiteral],pe=z.enum([EmbeddingTextModalityLiteral,EmbeddingTokenModalityLiteral]);var oi=z.object({object:z.literal("list"),model:z.string(),data:z.array(z.object({index:z.number(),object:z.literal("embedding"),embedding:z.array(z.number()).or(z.string().base64())})),usage:z.object({prompt_tokens:z.number().nonnegative(),total_tokens:z.number().nonnegative()})});var Lr=z.string().min(1).or(z.array(z.string().min(1)).min(1)).or(z.array(z.number().int().nonnegative()).min(1)).or(z.array(z.array(z.number().int().nonnegative()).min(1)).min(1)),ti=z.object({model:z.string().min(1).optional(),input:Lr,encoding_format:z.enum(["float","base64"]).optional(),dimensions:z.number().int().min(1).optional()});var se=z.object({modelName:z.string(),apiKey:z.string(),baseUrl:z.string().url().optional(),getEmbeddingsUrl:z.string().url().optional()}),ee=class{constructor(e,s){this.version="v1";let o=se.parse(s);this.modelSchema=e,this.modelName=o.modelName,this.apiKey=o.apiKey,this.baseUrl=urlWithoutTrailingSlash(o.baseUrl||K.baseUrl),this.getEmbeddingsUrl=urlWithoutTrailingSlash(o.getEmbeddingsUrl||`${this.baseUrl}/embeddings`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"}}getDefaultParams(){return {model:this.modelSchema.name}}getRetryDelay(e,s){let o=p=>{let _=/(\d+)(h|m|s|ms)/g,T={h:36e5,m:6e4,s:1e3,ms:1},x,O=0;for(;(x=_.exec(p))!==null;){let I=parseInt(x[1]),R=x[2];O+=I*T[R];}return O},t=0,n=0,r=true;e["x-ratelimit-reset-requests"]&&(t=o(e["x-ratelimit-reset-requests"])),e["x-ratelimit-reset-tokens"]&&(n=o(e["x-ratelimit-reset-tokens"]));let l=Math.max(t,n);return {shouldRetry:r,delayMs:l}}getTokenCount(e){return e.requests.reduce((s,o)=>s+o.length,0)}transformModelRequest(e){let s=ti.safeParse(e);if(!s.success)throw new InvalidModelRequestError({info:"Invalid model request",cause:s.error});let o=s.data,t=o.model,n={encodingFormat:o.encoding_format,dimensions:o.dimensions},r=Config().parse(removeUndefinedEntries(n)),l,p;return typeof o.input=="string"?p=EmbeddingTextModalityLiteral:typeof o.input[0]=="string"?p=EmbeddingTextModalityLiteral:p=EmbeddingTokenModalityLiteral,p===EmbeddingTextModalityLiteral?typeof o.input=="string"?l={modality:p,requests:[o.input]}:l={modality:p,requests:o.input}:typeof o.input[0]=="number"?l={modality:p,requests:[o.input]}:l={modality:p,requests:o.input},{modelName:t,config:r,embeddingRequests:l}}transformConfig(e,s){let o=this.modelSchema.config.schema.safeParse(e);if(!o.success)throw new InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:o.error});let t=o.data;return Object.keys(t).forEach(r=>{if(!this.modelSchema.config.def[r])throw new InvalidConfigError({info:`Invalid config for model : '${this.modelSchema.name}'`,cause:new Error(`Invalid config key : '${r}',
16
16
  available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(t).reduce((r,l)=>{let _=this.modelSchema.config.def[l].param,T=t[l];return r[_]=T,r},{})}transformEmbeddingRequests(e){let s=EmbeddingRequests().safeParse(e);if(!s.success)throw new InvalidEmbeddingRequestsError({info:"Invalid embedding requests",cause:s.error});return {input:s.data.requests}}getGetEmbeddingsUrl(e,s){return k(this,null,function*(){return new Promise(o=>{o(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(e,s){return k(this,null,function*(){return new Promise(o=>{o(this.getDefaultHeaders());})})}getGetEmbeddingsData(e,s){return k(this,null,function*(){return new Promise(o=>{o(b(b(b({},this.getDefaultParams()),this.transformConfig(e,s)),this.transformEmbeddingRequests(s)));})})}transformGetEmbeddingsResponse(e){let s,o=oi.safeParse(e);if(o.success){let t=o.data;s=typeof t.data[0].embedding=="string"?Base64EmbeddingLiteral:FloatEmbeddingLiteral;let n=t.data.map(r=>typeof r.embedding=="string"?{index:r.index,embedding:r.embedding}:{index:r.index,embedding:r.embedding});return {encodingFormat:s,embeddings:n,usage:{totalTokens:t.usage.total_tokens}}}throw new ModelResponseError({info:"Invalid response from model",cause:o.error})}};var nn="text-embedding-ada-002",Vr="Most capable 2nd generation embedding model, replacing 16 first generation models",sn=EmbeddingModelSchema(pe).parse({name:nn,description:Vr,modalities:le,maxInputTokens:8192,maxOutputTokens:1536,config:{def:J.base().def,schema:J.base().schema}}),Gs=se,jo=class extends ee{constructor(e){super(sn,e);}};var an="text-embedding-3-small",Kr="Increased performance over 2nd generation ada embedding model",rn=EmbeddingModelSchema(pe).parse({name:an,description:Kr,modalities:le,maxInputTokens:8192,maxOutputTokens:1536,config:{def:J.dimensions(1536).def,schema:J.dimensions(1536).schema}}),Es=se,$o=class extends ee{constructor(e){super(rn,e);}};var ln="text-embedding-3-large",Yr="Most capable embedding model for both english and non-english tasks",pn=EmbeddingModelSchema(pe).parse({name:ln,description:Yr,modalities:le,maxInputTokens:8192,maxOutputTokens:3072,config:{def:J.dimensions(3072).def,schema:J.dimensions(3072).schema}}),ks=se,Fo=class extends ee{constructor(e){super(pn,e);}};
17
17
 
18
18
  export { c as BaseChatModel, h as BaseChatModelOptions, Yo as BaseChatModelResponsesApi, yn as BaseChatModelResponsesApiOptions, ee as BaseEmbeddingModel, se as BaseEmbeddingModelOptions, Eo as ChatGPT_4o_Latest, Go as ChatGPT_4o_LatestLiteral, Cs as ChatGPT_4o_LatestOptions, jt as ChatGPT_4o_LatestSchema, Se as ChatGPT_5_2, ct as ChatGPT_5_2Literal, Vn as ChatGPT_5_2Options, ht as ChatGPT_5_2Schema, Q as ChatModelBaseConfigDef, Y as ChatModelBaseConfigSchema, Gn as ChatModelGPT5ConfigDef, En as ChatModelGPT5ConfigSchema, Nn as ChatModelO1SeriesConfigDef, qn as ChatModelO1SeriesConfigSchema, Ln as ChatModelOSeriesConfigDef, Dn as ChatModelOSeriesConfigSchema, Un as ChatModelResponseFormatConfigDef, jn as ChatModelResponseFormatConfigSchema, X as ChatModelResponseSchemaConfigDef, Z as ChatModelResponseSchemaConfigSchema, xe as EmbeddingModelBaseConfigDef, be as EmbeddingModelBaseConfigSchema, Fn as EmbeddingModelDimensionsConfigDef, $n as EmbeddingModelDimensionsConfigSchema, ke as GPT_3_5_Turbo, Ee as GPT_3_5_TurboLiteral, Wn as GPT_3_5_TurboOptions, _t as GPT_3_5_TurboSchema, Re as GPT_3_5_Turbo_0125, Ie as GPT_3_5_Turbo_0125Literal, Jn as GPT_3_5_Turbo_0125Options, ut as GPT_3_5_Turbo_0125Schema, Ge as GPT_3_5_Turbo_1106, Ae as GPT_3_5_Turbo_1106Literal, Kn as GPT_3_5_Turbo_1106Options, ft as GPT_3_5_Turbo_1106Schema, yo as GPT_4, To as GPT_4Literal, fs as GPT_4Options, Dt as GPT_4Schema, ve as GPT_4_0125_Preview, we as GPT_4_0125_PreviewLiteral, Yn as GPT_4_0125_PreviewOptions, gt as GPT_4_0125_PreviewSchema, De as GPT_4_0613, Le as GPT_4_0613Literal, Qn as GPT_4_0613Options, Tt as GPT_4_0613Schema, Be as GPT_4_1, qe as GPT_4_1106_Preview, Ne as GPT_4_1106_PreviewLiteral, Xn as GPT_4_1106_PreviewOptions, yt as GPT_4_1106_PreviewSchema, ze as GPT_4_1Literal, Zn as GPT_4_1Options, Mt as GPT_4_1Schema, je as GPT_4_1_Mini, Ue as GPT_4_1_MiniLiteral, es as GPT_4_1_MiniOptions, Ct as GPT_4_1_MiniSchema, Fe as GPT_4_1_Nano, $e as GPT_4_1_NanoLiteral, os as GPT_4_1_NanoOptions, Ot as GPT_4_1_NanoSchema, go as GPT_4_Turbo, _o as GPT_4_TurboLiteral, us as GPT_4_TurboOptions, Lt as GPT_4_TurboSchema, ho as GPT_4_Turbo_2024_04_09, co as GPT_4_Turbo_2024_04_09Literal, cs as GPT_4_Turbo_2024_04_09Options, wt as GPT_4_Turbo_2024_04_09Schema, fo as GPT_4_Turbo_Preview, uo as GPT_4_Turbo_PreviewLiteral, hs as GPT_4_Turbo_PreviewOptions, vt as GPT_4_Turbo_PreviewSchema, Ao as GPT_4o, Ro as GPT_4oLiteral, Ms as GPT_4oOptions, Ut as GPT_4oSchema, Co as GPT_4o_2024_05_13, Mo as GPT_4o_2024_05_13Literal, _s as GPT_4o_2024_05_13Options, Nt as GPT_4o_2024_05_13Schema, Po as GPT_4o_2024_08_06, Oo as GPT_4o_2024_08_06Literal, gs as GPT_4o_2024_08_06Options, qt as GPT_4o_2024_08_06Schema, Io as GPT_4o_Mini, So as GPT_4o_MiniLiteral, ys as GPT_4o_MiniOptions, Bt as GPT_4o_MiniSchema, xo as GPT_4o_Mini_2024_07_18, bo as GPT_4o_Mini_2024_07_18Literal, Ts as GPT_4o_Mini_2024_07_18Options, zt as GPT_4o_Mini_2024_07_18Schema, so as GPT_5, no as GPT_5Literal, ls as GPT_5Options, At as GPT_5Schema, Ve as GPT_5_1, He as GPT_5_1Literal, ts as GPT_5_1Options, Pt as GPT_5_1Schema, Ke as GPT_5_2, Je as GPT_5_2Literal, ns as GPT_5_2Options, bt as GPT_5_2Schema, Ye as GPT_5_2_ChatLatest, We as GPT_5_2_ChatLatestLiteral, ss as GPT_5_2_ChatLatestOptions, xt as GPT_5_2_ChatLatestSchema, Xe as GPT_5_2_Codex, Qe as GPT_5_2_CodexLiteral, is as GPT_5_2_CodexOptions, St as GPT_5_2_CodexSchema, eo as GPT_5_2_Pro, Ze as GPT_5_2_ProLiteral, as as GPT_5_2_ProOptions, It as GPT_5_2_ProSchema, to as GPT_5_3_Codex, oo as GPT_5_3_CodexLiteral, rs as GPT_5_3_CodexOptions, Rt as GPT_5_3_CodexSchema, mo as GPT_5_ChatLatest, po as GPT_5_ChatLatestLiteral, ds as GPT_5_ChatLatestOptions, kt as GPT_5_ChatLatestSchema, ao as GPT_5_Mini, io as GPT_5_MiniLiteral, ps as GPT_5_MiniOptions, Gt as GPT_5_MiniSchema, lo as GPT_5_Nano, ro as GPT_5_NanoLiteral, ms as GPT_5_NanoOptions, Et as GPT_5_NanoSchema, Lo as O1, vo as O1Literal, Ps as O1Options, Ft as O1Schema, wo as O1_2024_12_17, ko as O1_2024_12_17Literal, Os as O1_2024_12_17Options, $t as O1_2024_12_17Schema, No as O3, Jt as O3Literal, qo as O3Mini, zo as O3Mini2025_01_31, Qt as O3Mini2025_01_31Literal, Is as O3Mini2025_01_31Options, Xt as O3Mini2025_01_31Schema, Wt as O3MiniLiteral, Ss as O3MiniOptions, Yt as O3MiniSchema, xs as O3Options, Kt as O3Schema, Do as O3_2025_04_16, Ht as O3_2025_04_16Literal, bs as O3_2025_04_16Options, Vt as O3_2025_04_16Schema, Uo as O4_Mini, on as O4_MiniLiteral, As as O4_MiniOptions, tn as O4_MiniSchema, Bo as O4_Mini_2025_04_16, Zt as O4_Mini_2025_04_16Literal, Rs as O4_Mini_2025_04_16Options, en as O4_Mini_2025_04_16Schema, K as OpenAI, a as OpenAIChatModelConfigs, y as OpenAIChatModelModalities, M as OpenAIChatModelModalitiesEnum, m as OpenAIChatModelRoles, d as OpenAIChatModelRolesMap, Jl as OpenAIChatModelTextModalities, Kl as OpenAIChatModelTextModalitiesEnum, w as OpenAIChatModelTextToolModalities, v as OpenAIChatModelTextToolModalitiesEnum, Us as OpenAIChatRequest, Li as OpenAIChatRequestAssistantMessage, Ei as OpenAIChatRequestImageContent, Ni as OpenAIChatRequestMessage, Gi as OpenAIChatRequestResponseFormat, wi as OpenAIChatRequestSystemMessage, dn as OpenAIChatRequestTextContent, Ii as OpenAIChatRequestTool, ki as OpenAIChatRequestToolCallContent, Ri as OpenAIChatRequestToolChoiceEnum, Ai as OpenAIChatRequestToolChoiceFunction, Di as OpenAIChatRequestToolMessage, vi as OpenAIChatRequestUserMessage, zs as OpenAICompleteChatResponse, J as OpenAIEmbeddingModelConfigs, le as OpenAIEmbeddingModelModalities, pe as OpenAIEmbeddingModelModalitiesEnum, ti as OpenAIEmbeddingRequest, Lr as OpenAIEmbeddingRequestInput, oi as OpenAIGetEmbeddingsResponse, Bs as OpenAIStreamChatResponse, xi as OpenAIToolCallsCompleteChatResponse, Si as OpenAIToolCallsStreamChatResponse, Pi as ProviderLiteral, Fo as Text_Embedding_3_Large, ln as Text_Embedding_3_LargeLiteral, pn as Text_Embedding_3_LargeSchema, ks as Text_Embedding_3_Large_Options, $o as Text_Embedding_3_Small, an as Text_Embedding_3_SmallLiteral, rn as Text_Embedding_3_SmallSchema, Es as Text_Embedding_3_Small_Options, jo as Text_Embedding_Ada002, nn as Text_Embedding_Ada002Literal, sn as Text_Embedding_Ada002Schema, Gs as Text_Embedding_Ada002_Options, dt as dimensions, mt as encodingFormat, tt as frequencyPenalty, it as logProbs, Zo as maxTokens, nt as presencePenalty, lt as reasoningEffort, st as seed, et as stop, Xo as temperature, rt as toolChoice, at as topLogProbs, ot as topP, pt as verbosity };