@adaline/together-ai 1.7.0 → 1.7.1

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.js CHANGED
@@ -2,47 +2,47 @@
2
2
 
3
3
  var zod = require('zod');
4
4
 
5
- var Xt=Object.defineProperty;var je=Object.getOwnPropertySymbols;var Wt=Object.prototype.hasOwnProperty,Yt=Object.prototype.propertyIsEnumerable;var z=(o,t)=>(t=Symbol[o])?t:Symbol.for("Symbol."+o),Jt=o=>{throw TypeError(o)};var Le=(o,t,n)=>t in o?Xt(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n,b=(o,t)=>{for(var n in t||(t={}))Wt.call(t,n)&&Le(o,n,t[n]);if(je)for(var n of je(t))Yt.call(t,n)&&Le(o,n,t[n]);return o};var P=(o,t,n)=>new Promise((a,i)=>{var s=u=>{try{m(n.next(u));}catch(g){i(g);}},l=u=>{try{m(n.throw(u));}catch(g){i(g);}},m=u=>u.done?a(u.value):Promise.resolve(u.value).then(s,l);m((n=n.apply(o,t)).next());}),qe=function(o,t){this[0]=o,this[1]=t;},K=(o,t,n)=>{var a=(l,m,u,g)=>{try{var d=n[l](m),f=(m=d.value)instanceof qe,y=d.done;Promise.resolve(f?m[0]:m).then(T=>f?a(l==="return"?l:"next",m[1]?{done:T.done,value:T.value}:T,u,g):u({value:T,done:y})).catch(T=>a("throw",T,u,g));}catch(T){g(T);}},i=l=>s[l]=m=>new Promise((u,g)=>a(l,m,u,g)),s={};return n=n.apply(o,t),s[z("asyncIterator")]=()=>s,i("next"),i("throw"),i("return"),s},De=o=>{var t=o[z("asyncIterator")],n=!1,a,i={};return t==null?(t=o[z("iterator")](),a=s=>i[s]=l=>t[s](l)):(t=t.call(o),a=s=>i[s]=l=>{if(n){if(n=!1,s==="throw")throw l;return l}return n=!0,{done:!1,value:new qe(new Promise(m=>{var u=t[s](l);u instanceof Object||Jt("Object expected"),m(u);}),1)}}),i[z("iterator")]=()=>i,a("next"),"throw"in t?a("throw"):i.throw=s=>{throw s},"return"in t&&a("return"),i};var q="system",D="user",x="assistant",B="tool",Zt=[q,D,x,B],Y=zod.z.enum(Zt),en=[x],tn=zod.z.enum(en),$e="image",nn="base64",on=["png","jpeg","webp","gif"],an=zod.z.object({type:zod.z.literal(nn),base64:zod.z.string(),mediaType:zod.z.enum(on)}),sn="url",rn=zod.z.object({type:zod.z.literal(sn),url:zod.z.string()}),ln=zod.z.discriminatedUnion("type",[an,rn]),mn=["low","medium","high","auto"],cn=zod.z.enum(mn),pn=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal($e),detail:cn,value:ln,metadata:o}),ze="pdf",un="base64",dn=zod.z.object({type:zod.z.literal(un),base64:zod.z.string()}),gn="url",hn=zod.z.object({type:zod.z.literal(gn),url:zod.z.string()}),fn=zod.z.discriminatedUnion("type",[dn,hn]),yn=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(ze),value:fn,file:zod.z.object({name:zod.z.string(),id:zod.z.string(),size:zod.z.number().optional()}),metadata:o}),Ve="reasoning",He="partial-reasoning",Qe="thinking",Tn="redacted",W=zod.z.object({type:zod.z.literal(Qe),thinking:zod.z.string(),signature:zod.z.string()}),Ge=zod.z.object({type:zod.z.literal(Tn),data:zod.z.string()}),bn=zod.z.discriminatedUnion("type",[W,Ge]),Pn=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Ve),value:bn,metadata:o}),kn=zod.z.object({type:zod.z.literal(Qe),thinking:W.shape.thinking.optional(),signature:W.shape.signature.optional()}),Mn=zod.z.discriminatedUnion("type",[kn,Ge]),Cn=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(He),value:Mn,metadata:o}),M="text",Ke=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(M),value:zod.z.string(),metadata:o}),J="partial-text",Xe=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(J),value:zod.z.string(),metadata:o}),I="tool-call",We=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(I),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),arguments:zod.z.string(),serverName:zod.z.string().optional(),metadata:o}),Z="partial-tool-call",Ye=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Z),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),arguments:zod.z.string().optional(),serverName:zod.z.string().optional(),metadata:o}),w="tool-response",Rn=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(w),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),data:zod.z.string(),apiResponse:zod.z.object({statusCode:zod.z.number().int().nonnegative()}).optional(),metadata:o}),xn="partial-tool-response",In=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(xn),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),data:zod.z.string().optional(),apiResponse:zod.z.object({statusCode:zod.z.number().int().nonnegative()}).optional(),metadata:o}),vn=[M,$e,ze,I,w,Ve],Je=zod.z.enum(vn),Sn=(o=zod.z.undefined(),t=zod.z.undefined(),n=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined(),s=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[Ke(o),pn(t),yn(n),We(a),Rn(i),Pn(s)]),En=[J,Z,He];zod.z.enum(En);var wn=(o=zod.z.undefined(),t=zod.z.undefined(),n=zod.z.undefined(),a=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[Xe(o),Ye(t),Cn(n),In(a)]);var ee=(o=Y,t=zod.z.undefined(),n=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined(),s=zod.z.undefined(),l=zod.z.undefined(),m=zod.z.undefined())=>zod.z.object({role:o,content:zod.z.array(Sn(t,n,a,i,l,s)),metadata:m}),te=(o=tn,t=zod.z.undefined(),n=zod.z.undefined(),a=zod.z.undefined(),i=zod.z.undefined(),s=zod.z.undefined())=>zod.z.object({role:o,partialContent:wn(t,n,a,s),metadata:i}),Un=zod.z.object({promptTokens:zod.z.number().nonnegative(),completionTokens:zod.z.number().nonnegative(),totalTokens:zod.z.number().nonnegative()}),Be=zod.z.object({token:zod.z.string(),logProb:zod.z.number(),bytes:zod.z.array(zod.z.number().int()).nullable()}),An=Be.extend({topLogProbs:zod.z.array(Be)}),Ze=zod.z.array(An);zod.z.object({messages:zod.z.array(ee()),usage:Un.optional(),logProbs:Ze.optional()});var _n=zod.z.object({promptTokens:zod.z.number().nonnegative().optional(),completionTokens:zod.z.number().nonnegative().optional(),totalTokens:zod.z.number().nonnegative().optional()});zod.z.object({partialMessages:zod.z.array(te()),usage:_n.optional(),logProbs:Ze.optional()});var V=(o=zod.z.record(zod.z.string(),zod.z.any()).optional())=>o,Nn=zod.z.object({enabled:zod.z.boolean().default(!0),allowedTools:zod.z.array(zod.z.string().min(1))});zod.z.object({type:zod.z.literal("url"),url:zod.z.string().url().refine(o=>o.startsWith("https://"),{message:"MCP server URL must start with https://"}),name:zod.z.string().min(1),toolConfiguration:Nn.optional(),authorizationToken:zod.z.string().min(1).optional()});var jn=["object","array","number","string","boolean","enum"],Oe=zod.z.enum(jn),Ln=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([Oe,zod.z.array(zod.z.union([Oe,zod.z.literal("null")]))]).optional(),default:zod.z.any().optional(),title:zod.z.string().optional(),description:zod.z.string().max(4096).optional(),properties:zod.z.record(zod.z.any()).optional(),required:zod.z.array(zod.z.string()).optional(),minItems:zod.z.number().int().min(0).optional(),maxItems:zod.z.number().int().optional(),items:zod.z.record(zod.z.any()).optional(),enum:zod.z.array(zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),minLength:zod.z.number().int().min(0).optional(),maxLength:zod.z.number().int().optional(),$ref:zod.z.string().optional()}),qn=zod.z.object({type:zod.z.enum(["object"]),required:zod.z.array(zod.z.string()),$defs:zod.z.record(zod.z.any()).optional(),properties:zod.z.record(Ln),additionalProperties:zod.z.literal(!1)}),et=zod.z.object({name:zod.z.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:zod.z.string().max(4096),strict:zod.z.boolean().optional(),schema:qn}).optional(),U="text",tt="token",Dn=[U,tt],nt=zod.z.enum(Dn),Bn=zod.z.array(zod.z.string().min(1)),On=zod.z.array(zod.z.array(zod.z.number().int().nonnegative())),ot=(o=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[zod.z.object({modality:zod.z.literal(U),metadata:o,requests:Bn}),zod.z.object({modality:zod.z.literal(tt),metadata:o,requests:On})]),ne="float",Fn=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),$n="base64",zn=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),Fe=zod.z.object({totalTokens:zod.z.number().int().nonnegative()});zod.z.discriminatedUnion("encodingFormat",[zod.z.object({encodingFormat:zod.z.literal(ne),embeddings:zod.z.array(Fn),usage:Fe.optional()}),zod.z.object({encodingFormat:zod.z.literal($n),embeddings:zod.z.array(zn),usage:Fe.optional()})]);var Vn=o=>{let t=new WeakSet;return JSON.stringify(o,(n,a)=>{if(typeof a=="object"&&a!==null){if(t.has(a))return;t.add(a);}return a})},Hn=o=>o==null?"unknown error":typeof o=="string"?o:o instanceof Error?o.message:Vn(o),X="GatewayBaseError",N=class at extends Error{constructor({info:t,cause:n},a){super(`[${a!=null?a:X}]: ${t}
6
- Message: ${Hn(n)}`),this.name=X,this.info=t,this.cause=n,this.name=a!=null?a:X,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(t){return t instanceof at}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},Qn=zod.z.object({inputPricePerMillion:zod.z.number().nonnegative().describe("Price per 1M input tokens"),outputPricePerMillion:zod.z.number().nonnegative().describe("Price per 1M output tokens")}).describe("Input/output price pair (per 1M tokens) for a specific category within a ChatModel pricing tier."),Gn=zod.z.object({base:Qn.describe("Base (uncached, non\u2011reasoning) rates")}).describe("Holds the `ChatModelTokenPairPrice` for different categories (e.g., base) within a single pricing tier."),Kn=zod.z.object({minTokens:zod.z.number().int().nonnegative().describe("Inclusive lower token bound for this tier."),maxTokens:zod.z.number().int().nullable().optional().describe("Exclusive upper token bound; `null` means \u221E."),prices:Gn.describe("Price categories and rates for this specific token range.")}).refine(o=>o.maxTokens===null||typeof o.maxTokens=="number"&&o.maxTokens>o.minTokens,{message:"maxTokens must be > minTokens (or null for infinite).",path:["maxTokens"]}).describe("A single pricing tier defined by a token range and associated prices.");zod.z.object({modelName:zod.z.string().describe("Model name this schedule applies to."),currency:zod.z.string().default("USD").describe("Currency code (e.g., USD)."),tokenRanges:zod.z.array(Kn).min(1).describe("Pricing tiers (`ChatModelTokenRangePrice`) schedule, sorted by minTokens.")}).superRefine((o,t)=>{let{tokenRanges:n}=o;n[0].minTokens!==0&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",0,"minTokens"],message:"The first tier must have minTokens = 0."});for(let i=1;i<n.length;i++){let s=n[i-1],l=n[i];if(s.maxTokens===null){t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",i-1,"maxTokens"],message:"Cannot define any tokenRanges after an infinite tier (maxTokens = null)."});break}l.minTokens!==s.maxTokens&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",i,"minTokens"],message:`Tier ${i} minTokens (${l.minTokens}) must equal previous tier's maxTokens (${s.maxTokens}) for contiguity.`}),l.minTokens<s.minTokens&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",i,"minTokens"],message:`tokenRanges must be sorted by ascending minTokens. Tier ${i} (${l.minTokens}) starts before Tier ${i-1} (${s.minTokens}).`});}let a=n[n.length-1];n.every(i=>i.maxTokens!==null||i===a)&&a.maxTokens!==null&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",n.length-1,"maxTokens"],message:"The final tier must have maxTokens = null (representing infinity)."});}).describe("Complete pricing schedule for a single chat model, including all its token-based tiers.");var Xn="function";var Wn=zod.z.enum(["object","array","number","string","boolean","null"]),Yn=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:Wn.optional(),default:zod.z.any().optional(),title:zod.z.string().optional(),description:zod.z.string().max(4096).optional(),properties:zod.z.record(zod.z.any()).optional(),required:zod.z.array(zod.z.string()).optional(),minItems:zod.z.number().int().min(0).optional(),maxItems:zod.z.number().int().optional(),items:zod.z.record(zod.z.any()).optional(),enum:zod.z.array(zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),minLength:zod.z.number().int().min(0).optional(),maxLength:zod.z.number().int().optional()});zod.z.object({type:zod.z.enum(["object"]),title:zod.z.string().optional(),$defs:zod.z.record(zod.z.any()).optional(),properties:zod.z.record(Yn).optional(),required:zod.z.array(zod.z.string()).optional()});var Jn=zod.z.object({name:zod.z.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:zod.z.string().max(4096),parameters:zod.z.any(),strict:zod.z.boolean().optional()});var Zn=zod.z.enum(["function"]),eo=zod.z.object({maxAttempts:zod.z.number().int().positive(),initialDelay:zod.z.number().int().positive(),exponentialFactor:zod.z.number().int().positive()}),to=zod.z.object({type:zod.z.literal("http"),method:zod.z.enum(["get","post"]),url:zod.z.string().url(),headers:zod.z.record(zod.z.string()).optional(),query:zod.z.record(zod.z.string()).optional(),body:zod.z.record(zod.z.any()).optional(),proxyUrl:zod.z.string().url().optional(),proxyHeaders:zod.z.record(zod.z.string()).optional(),retry:eo.optional()}),no=zod.z.discriminatedUnion("type",[to]),oo=zod.z.object({type:Zn,definition:zod.z.object({schema:Jn}),request:no.optional()}),ao=[Xn];zod.z.enum(ao);var it=(o=zod.z.undefined())=>zod.z.discriminatedUnion("type",[oo.extend({metadata:o})]),st=o=>Ke().parse({modality:M,value:o}),rt=(o,t,n,a,i)=>We().parse({modality:I,index:o,id:t,name:n,arguments:a,serverName:i});var oe=(o,t)=>te().parse({role:o,partialContent:Xe().parse({modality:J,value:t})}),lt=(o,t,n,a,i,s)=>te().parse({role:o,partialContent:Ye().parse({modality:Z,index:t,id:n,name:a,arguments:i,serverName:s})});var io=Object.defineProperty,mt=Object.getOwnPropertySymbols,so=Object.prototype.hasOwnProperty,ro=Object.prototype.propertyIsEnumerable,ct=(o,t,n)=>t in o?io(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n,F=(o,t)=>{for(var n in t||(t={}))so.call(t,n)&&ct(o,n,t[n]);if(mt)for(var n of mt(t))ro.call(t,n)&&ct(o,n,t[n]);return o};var pt="ModelResponseError",_=class Tt extends N{constructor({info:t,cause:n}){super({info:t,cause:n},pt),this.name=pt,this.cause=n,this.info=t;}static isModelResponseError(t){return t instanceof Tt}},ut="InvalidModelRequestError",O=class bt extends N{constructor({info:t,cause:n}){super({info:t,cause:n},ut),this.name=ut,this.cause=n,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(t){return t instanceof bt}},dt="InvalidConfigError",S=class Pt extends N{constructor({info:t,cause:n}){super({info:t,cause:n},dt),this.name=dt,this.cause=n,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(t){return t instanceof Pt}},gt="InvalidMessagesError",R=class kt extends N{constructor({info:t,cause:n}){super({info:t,cause:n},gt),this.name=gt,this.cause=n,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(t){return t instanceof kt}},ht="InvalidToolsError",ae=class Mt extends N{constructor({info:t,cause:n}){super({info:t,cause:n},ht),this.name=ht,this.cause=n,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(t){return t instanceof Mt}},ft="InvalidEmbeddingRequestsError",ie=class Ct extends N{constructor({info:t,cause:n}){super({info:t,cause:n},ft),this.name=ft,this.info=t,this.cause=n,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(t){return t instanceof Ct}},se="multi-string",Rt=zod.z.object({type:zod.z.literal(se),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),max:zod.z.number().int().positive()}),lo=o=>zod.z.array(zod.z.string()).max(o).default([]).optional(),xt=o=>({def:Rt.parse(F({type:se},o)),schema:lo(o.max)}),re="object-schema",It=zod.z.object({type:zod.z.literal(re),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),objectSchema:zod.z.any()}),mo=o=>o.optional(),vt=o=>({def:It.parse(F({type:re},o)),schema:mo(o.objectSchema)}),St="paired-select",co=zod.z.object({value:zod.z.string().min(1),label:zod.z.string().min(1)}),yt=zod.z.object({key:zod.z.string().min(1),label:zod.z.string().min(1),description:zod.z.string().min(1).max(500).optional(),choices:zod.z.array(co).min(1)}),po=zod.z.object({type:zod.z.literal(St),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),fields:zod.z.tuple([yt,yt]),uniqueByField:zod.z.string().min(1).optional()});var le="range",Et=zod.z.object({type:zod.z.literal(le),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),min:zod.z.number().int(),max:zod.z.number().int(),step:zod.z.number().positive(),default:zod.z.number()}),uo=(o,t,n,a)=>zod.z.number().min(o).max(t).step(n).default(a).optional(),E=o=>({def:Et.parse(F({type:le},o)),schema:uo(o.min,o.max,o.step,o.default)}),me="select-boolean",wt=zod.z.object({type:zod.z.literal(me),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),default:zod.z.boolean().nullable()}),go=o=>zod.z.boolean().nullable().default(o).optional(),Ut=o=>({def:wt.parse(F({type:me},o)),schema:go(o.default)}),ce="select-string",At=zod.z.object({type:zod.z.literal(ce),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),default:zod.z.string(),choices:zod.z.array(zod.z.string())}),ho=(o,t)=>zod.z.enum(t).nullable().default(o).optional(),pe=o=>({def:At.parse(F({type:ce},o)),schema:ho(o.default,o.choices)}),fo=[le,se,ce,re,me,St];zod.z.enum(fo);var _t=zod.z.discriminatedUnion("type",[Et,Rt,At,wt,It,po]),Nt=(o=Y,t=Je)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(o,zod.z.string().min(1).optional()),modalities:zod.z.array(t).nonempty(),maxInputTokens:zod.z.number().int().positive().min(1),maxOutputTokens:zod.z.number().int().positive().min(1),maxReasoningTokens:zod.z.number().int().positive().min(1).optional(),config:zod.z.object({def:zod.z.record(zod.z.string().min(1),_t),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(n=>{var a,i;let s=Object.keys(n.def),l=Object.keys((i=(a=n.schema)==null?void 0:a.shape)!=null?i:{});return s.every(m=>l.includes(m))&&l.every(m=>s.includes(m))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"}),price:zod.z.custom()}),jt=(o=nt)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),modalities:zod.z.array(o).nonempty(),maxInputTokens:zod.z.number().int().positive().min(1),maxOutputTokens:zod.z.number().int().positive().min(1),config:zod.z.object({def:zod.z.record(zod.z.string().min(1),_t),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(t=>{var n,a;let i=Object.keys(t.def),s=Object.keys((a=(n=t.schema)==null?void 0:n.shape)!=null?a:{});return i.every(l=>s.includes(l))&&s.every(l=>i.includes(l))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})});zod.z.record(zod.z.string());zod.z.record(zod.z.union([zod.z.boolean(),zod.z.string(),zod.z.number(),zod.z.object({}),zod.z.array(zod.z.any()),zod.z.null(),zod.z.undefined()]));zod.z.string().url();var yo={type:"range",title:"Temperature",description:"Adjusts the model's creativity level. With a setting of 0, the model strictly picks the most probable next word. For endeavors that benefit from a dash of inventiveness, consider dialing it up to 0.7 or higher, enabling the model to produce text that's unexpectedly fresh."},To={type:"range",title:"Max tokens",description:"Specify the total tokens for generation, where one token approximates four English characters. Setting this to 0 defaults to the model's maximum capacity."},bo={type:"range",title:"Max reasoning tokens",description:"Specify the total tokens for reasoning, where one token approximates four English characters."},Po=o=>({type:"multi",title:"Stop sequence",description:`Enter up to ${o} sequences that will halt additional text output. The generated text will exclude these sequences.`}),ko={type:"range",title:"Top A",description:"Considers only the top tokens that have 'sufficiently high' probabilities relative to the most likely token, functioning like a dynamic Top-P. A lower Top-A value narrows down the token choices based on the highest probability token, while a higher Top-A value refines the filtering without necessarily impacting the creativity of the output."},Mo={type:"range",title:"Top P",description:"Selects a subset of likely tokens for generation, restricting choices to the top-P fraction of possibilities, such as the top 10% when P=0.1. This approach can limit the variety of the output. By default, it's set to 1, indicating no restriction. It's advised to adjust this parameter or temperature to modulate output diversity, but not to modify both simultaneously."},Co={type:"range",title:"Top K",description:"Select only from the highest K probabilities for each following word, effectively eliminating the less likely 'long tail' options."},Ro={type:"range",title:"Min P",description:"Specifies the minimum probability a token must have to be considered, in relation to the probability of the most likely token. (This value varies based on the confidence level of the top token.) For example, if Min-P is set to 0.1, only tokens with at least 1/10th the probability of the highest-ranked token will be considered."},xo={type:"range",title:"Frequency penalty",description:"Minimize redundancy. By assigning a penalty to frequently used tokens within the text, the likelihood of repeating identical phrases is reduced. The default setting for this penalty is zero."},Io={type:"range",title:"Presence penalty",description:"Enhance the introduction of novel subjects by reducing the preference for tokens that have already appeared in the text, thus boosting the chances of exploring fresh topics. The standard setting for this is zero."},vo={type:"range",title:"Seed",description:"When seed is fixed to a specific value, the model makes a best effort to provide the same response for repeated requests. Deterministic output isn't guaranteed. Also, changing the model or parameter settings, such as the temperature, can cause variations in the response even when you use the same seed value. By default, a random seed value is used."},So={type:"range",title:"Repetition penalty",description:"Reduces the likelihood of repeating tokens from the input. Increasing this value makes the model less prone to repetition, but setting it too high may lead to less coherent output, often resulting in run-on sentences missing smaller words. The token penalty is scaled according to the original token's probability."},Eo={type:"boolean",title:"Log probs",description:"Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned."},wo={type:"range",title:"Top log probs",description:"The number of most likely tokens to return at each token position, each with an associated log probability. 'logprobs' must be set to true if this parameter is used."},Uo={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},Ao={type:"select",title:"Response format",description:"Choose the response format of your model. For JSON, you must include the string 'JSON' in some form within your system / user prompt."},_o={type:"select",title:"Response format",description:"Choose the response format of your model. 'json_object' colloquially known as JSON mode, instructs the model to respond with a valid JSON (must include the term 'json' in prompt). 'json_schema' colloquially known as structured outputs, allows you to specify a strict response schema that the model will adhere to."},No={type:"object",title:"Response schema",description:"When response format is set to 'json_schema', the model will return a JSON object of the specified schema."},jo={type:"object",title:"MCP servers",description:"MCP servers to use for the model."},h={TEMPERATURE:yo,MAX_TOKENS:To,STOP:Po,TOP_A:ko,TOP_P:Mo,TOP_K:Co,MIN_P:Ro,FREQUENCY_PENALTY:xo,PRESENCE_PENALTY:Io,REPETITION_PENALTY:So,SEED:vo,LOG_PROBS:Eo,TOP_LOG_PROBS:wo,ECHO:Uo,RESPONSE_FORMAT:Ao,RESPONSE_FORMAT_WITH_SCHEMA:_o,RESPONSE_SCHEMA:No,MAX_REASONING_TOKENS:bo,MCP_SERVERS:jo};var H=o=>Object.fromEntries(Object.entries(o).filter(([t,n])=>n!=null));var j=o=>o==null?void 0:o.replace(/\/$/,"");var ue=E({param:"temperature",title:h.TEMPERATURE.title,description:h.TEMPERATURE.description,min:0,max:1,step:.01,default:1}),de=o=>E({param:"max_tokens",title:h.MAX_TOKENS.title,description:h.MAX_TOKENS.description,min:0,max:o,step:1,default:0}),ge=o=>xt({param:"stop",title:h.STOP(o).title,description:h.STOP(o).description,max:o}),he=E({param:"top_k",title:h.TOP_K.title,description:h.TOP_K.description,min:0,max:1e4,step:1,default:0}),fe=E({param:"top_p",title:h.TOP_P.title,description:h.TOP_P.description,min:0,max:1,step:.01,default:1}),ye=E({param:"min_p",title:h.MIN_P.title,description:h.MIN_P.description,min:0,max:1,step:.01,default:0}),Te=E({param:"frequency_penalty",title:h.FREQUENCY_PENALTY.title,description:h.FREQUENCY_PENALTY.description,min:-2,max:2,step:.01,default:0}),be=E({param:"presence_penalty",title:h.PRESENCE_PENALTY.title,description:h.PRESENCE_PENALTY.description,min:-2,max:2,step:.01,default:0}),Pe=E({param:"repetition_penalty",title:h.REPETITION_PENALTY.title,description:h.REPETITION_PENALTY.description,min:0,max:1e4,step:.01,default:0}),ke=E({param:"seed",title:h.SEED.title,description:h.SEED.description,min:0,max:1e6,step:1,default:0}),Me=Ut({param:"logprobs",title:h.LOG_PROBS.title,description:h.LOG_PROBS.description,default:!1}),Ce=pe({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"]}),Re=pe({param:"response_format",title:h.RESPONSE_FORMAT.title,description:h.RESPONSE_FORMAT.description,default:"text",choices:["text","json_object"]}),xe=vt({param:"response_schema",title:h.RESPONSE_SCHEMA.title,description:h.RESPONSE_SCHEMA.description,objectSchema:et});var Lt=(o,t)=>zod.z.object({temperature:ue.schema,maxTokens:de(o).schema,stop:ge(t).schema,topP:fe.schema,topK:he.schema,minP:ye.schema,frequencyPenalty:Te.schema,presencePenalty:be.schema,repetitionPenalty:Pe.schema,seed:ke.schema.transform(n=>n===0?void 0:n),logProbs:Me.schema,toolChoice:Ce.schema,responseSchema:xe.schema,responseFormat:Re.schema}),qt=(o,t)=>({temperature:ue.def,maxTokens:de(o).def,stop:ge(t).def,topP:fe.def,topK:he.def,minP:ye.def,frequencyPenalty:Te.def,presencePenalty:be.def,repetitionPenalty:Pe.def,seed:ke.def,logProbs:Me.def,toolChoice:Ce.def,responseSchema:xe.def,responseFormat:Re.def});var Ie={base:(o,t)=>({def:qt(o,t),schema:Lt(o,t)})};var Dt=zod.z.enum([q,D,x,B]),Bt={system:q,user:D,assistant:x,tool:B};var Ot=[M,I,w],Ft=zod.z.enum([M,I,w]);var Bo=zod.z.object({token_ids:zod.z.array(zod.z.number()),tokens:zod.z.array(zod.z.string()),token_logprobs:zod.z.array(zod.z.number())}),Oo=zod.z.array(zod.z.object({id:zod.z.string().min(1),type:zod.z.enum(["function"]),function:zod.z.object({name:zod.z.string(),arguments:zod.z.string()})})),$t=zod.z.object({id:zod.z.string(),object:zod.z.literal("chat.completion"),created:zod.z.number(),model:zod.z.string(),prompt:zod.z.any(),choices:zod.z.array(zod.z.object({index:zod.z.number(),message:zod.z.object({role:zod.z.string(),content:zod.z.string().nullable().optional(),tool_calls:Oo.optional()}),logprobs:Bo.nullable().optional(),seed:zod.z.number().nullable().optional(),finish_reason:zod.z.string()})),usage:zod.z.object({prompt_tokens:zod.z.number(),completion_tokens:zod.z.number(),total_tokens:zod.z.number()}).nullable().optional()}),Fo=zod.z.array(zod.z.object({index:zod.z.number().int(),id:zod.z.string().min(1).optional(),type:zod.z.enum(["function"]).optional(),function:zod.z.object({name:zod.z.string().min(1).optional(),arguments:zod.z.string().optional()}).optional()})),zt=zod.z.object({id:zod.z.string(),object:zod.z.string(),created:zod.z.number(),model:zod.z.string(),choices:zod.z.array(zod.z.object({index:zod.z.number(),delta:zod.z.object({token_id:zod.z.number().nullable().optional(),role:zod.z.string().nullable().optional(),content:zod.z.string().nullable().optional(),tool_calls:Fo.nullable().optional()}).or(zod.z.object({})),logprobs:zod.z.any().nullable().optional(),seed:zod.z.number().nullable().optional(),finish_reason:zod.z.string().nullable(),text:zod.z.string().nullable().optional()})),usage:zod.z.object({prompt_tokens:zod.z.number(),completion_tokens:zod.z.number(),total_tokens:zod.z.number()}).nullable().optional()});var $o=zod.z.object({type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1).optional(),strict:zod.z.boolean().optional(),parameters:zod.z.any()})}),zo=zod.z.enum(["none","auto","required"]),Vo=zod.z.object({type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1)})}),Ho=zod.z.object({type:zod.z.enum(["text","json_object"])}).or(zod.z.object({type:zod.z.literal("json_schema"),json_schema:zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1).optional(),strict:zod.z.boolean().optional(),schema:zod.z.any()})})),ve=zod.z.string(),Qo=zod.z.object({id:zod.z.string().min(1),type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1),arguments:zod.z.string().min(1)})}),Go=zod.z.object({role:zod.z.literal("system"),content:ve}),Ko=zod.z.object({role:zod.z.literal("user"),content:ve}),Xo=zod.z.object({role:zod.z.literal("assistant"),content:ve.optional(),tool_calls:zod.z.array(Qo).min(1).optional()}),Wo=zod.z.object({role:zod.z.literal("tool"),tool_call_id:zod.z.string().min(1),content:zod.z.string().min(1)}),Yo=zod.z.union([Go,Ko,Xo,Wo]),Vt=zod.z.object({model:zod.z.string().min(1).optional(),messages:zod.z.array(Yo).min(1),frequency_penalty:zod.z.number().min(-2).max(2).nullable().optional(),logprobs:zod.z.number().min(0).max(1).nullable().optional(),max_tokens:zod.z.number().min(0).nullable().optional(),presence_penalty:zod.z.number().min(-2).max(2).nullable().optional(),repetition_penalty:zod.z.number().min(0).max(2).nullable().optional(),response_format:Ho.optional(),seed:zod.z.number().optional(),stop:zod.z.string().or(zod.z.array(zod.z.string()).max(4)).nullable().optional(),temperature:zod.z.number().min(0).max(1).nullable().optional(),top_p:zod.z.number().min(0).max(1).nullable().optional(),top_k:zod.z.number().min(0).max(1e4).nullable().optional(),min_p:zod.z.number().min(0).max(1).nullable().optional(),echo:zod.z.boolean().nullable().optional(),tools:zod.z.array($o).optional(),tool_choice:zo.or(Vo).optional()});var Se=Nt(Dt,Ft).parse({name:"__base__",description:"Base chat model for Together AI",maxInputTokens:128e3,maxOutputTokens:128e3,roles:Bt,modalities:Ot,config:{def:Ie.base(128e3,4).def,schema:Ie.base(128e3,4).schema}});var Jo="together-ai",L=class{constructor(){this.version="v1";this.name=Jo;}chatModelLiterals(){return ["__base__"]}chatModelSchemas(){return {__base__:Se}}chatModel(t){let n=Q,a=we.parse(t);return new n(Se,a)}embeddingModelLiterals(){return ["__base__"]}embeddingModelSchemas(){return {__base__:Ee}}embeddingModel(t){let n=G,a=Ue.parse(t);return new n(Ee,a)}};L.baseUrl="https://api.together.xyz/v1";var Ae={"WhereIsAI/UAE-Large-V1":{modelName:"WhereIsAI/UAE-Large-V1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.016,outputPricePerMillion:.016}}}]},"meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8":{modelName:"meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.27,outputPricePerMillion:.85}}}]},"togethercomputer/m2-bert-80M-32k-retrieval":{modelName:"togethercomputer/m2-bert-80M-32k-retrieval",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.008,outputPricePerMillion:.008}}}]},"google/gemma-2-9b-it":{modelName:"google/gemma-2-9b-it",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.3,outputPricePerMillion:.3}}}]},"cartesia/sonic":{modelName:"cartesia/sonic",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:65,outputPricePerMillion:0}}}]},"BAAI/bge-large-en-v1.5":{modelName:"BAAI/bge-large-en-v1.5",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.016,outputPricePerMillion:.016}}}]},"NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO":{modelName:"NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.6,outputPricePerMillion:.6}}}]},"black-forest-labs/FLUX.1-schnell-Free":{modelName:"black-forest-labs/FLUX.1-schnell-Free",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"black-forest-labs/FLUX.1.1-pro":{modelName:"black-forest-labs/FLUX.1.1-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"Qwen/Qwen2.5-7B-Instruct-Turbo":{modelName:"Qwen/Qwen2.5-7B-Instruct-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.3,outputPricePerMillion:.3}}}]},"deepseek-ai/DeepSeek-R1-Distill-Llama-70B-free":{modelName:"deepseek-ai/DeepSeek-R1-Distill-Llama-70B-free",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"meta-llama-llama-2-70b-hf":{modelName:"meta-llama-llama-2-70b-hf",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.9,outputPricePerMillion:.9}}}]},"BAAI/bge-base-en-v1.5":{modelName:"BAAI/bge-base-en-v1.5",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.008,outputPricePerMillion:.008}}}]},"Gryphe/MythoMax-L2-13b":{modelName:"Gryphe/MythoMax-L2-13b",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.3,outputPricePerMillion:.3}}}]},"google/gemma-2-27b-it":{modelName:"google/gemma-2-27b-it",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.8,outputPricePerMillion:.8}}}]},"Qwen/Qwen2-VL-72B-Instruct":{modelName:"Qwen/Qwen2-VL-72B-Instruct",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.2,outputPricePerMillion:1.2}}}]},"meta-llama/LlamaGuard-2-8b":{modelName:"meta-llama/LlamaGuard-2-8b",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.2,outputPricePerMillion:.2}}}]},"cartesia/sonic-2":{modelName:"cartesia/sonic-2",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:65,outputPricePerMillion:0}}}]},"togethercomputer/m2-bert-80M-8k-retrieval":{modelName:"togethercomputer/m2-bert-80M-8k-retrieval",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.008,outputPricePerMillion:.008}}}]},"meta-llama/Llama-3.3-70B-Instruct-Turbo-Free":{modelName:"meta-llama/Llama-3.3-70B-Instruct-Turbo-Free",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"togethercomputer/MoA-1":{modelName:"togethercomputer/MoA-1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"meta-llama/Meta-Llama-3-70B-Instruct-Turbo":{modelName:"meta-llama/Meta-Llama-3-70B-Instruct-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.88,outputPricePerMillion:.88}}}]},"mistralai/Mistral-7B-Instruct-v0.2":{modelName:"mistralai/Mistral-7B-Instruct-v0.2",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.2,outputPricePerMillion:.2}}}]},"togethercomputer/m2-bert-80M-2k-retrieval":{modelName:"togethercomputer/m2-bert-80M-2k-retrieval",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.008,outputPricePerMillion:.008}}}]},"google/gemma-2b-it":{modelName:"google/gemma-2b-it",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.1}}}]},"black-forest-labs/FLUX.1-pro":{modelName:"black-forest-labs/FLUX.1-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"mistralai/Mistral-Small-24B-Instruct-2501":{modelName:"mistralai/Mistral-Small-24B-Instruct-2501",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.8,outputPricePerMillion:.8}}}]},"Gryphe/MythoMax-L2-13b-Lite":{modelName:"Gryphe/MythoMax-L2-13b-Lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.1}}}]},"scb10x/scb10x-llama3-1-typhoon2-70b-instruct":{modelName:"scb10x/scb10x-llama3-1-typhoon2-70b-instruct",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.88,outputPricePerMillion:.88}}}]},"black-forest-labs/FLUX.1-redux":{modelName:"black-forest-labs/FLUX.1-redux",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"meta-llama/Meta-Llama-Guard-3-8B":{modelName:"meta-llama/Meta-Llama-Guard-3-8B",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.2,outputPricePerMillion:.2}}}]},"black-forest-labs/FLUX.1-depth":{modelName:"black-forest-labs/FLUX.1-depth",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"black-forest-labs/FLUX.1-canny":{modelName:"black-forest-labs/FLUX.1-canny",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"meta-llama/Llama-3-8b-chat-hf":{modelName:"meta-llama/Llama-3-8b-chat-hf",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.2,outputPricePerMillion:.2}}}]},"arcee-ai/caller":{modelName:"arcee-ai/caller",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.55,outputPricePerMillion:.85}}}]},"togethercomputer/MoA-1-Turbo":{modelName:"togethercomputer/MoA-1-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"mistralai/Mistral-7B-Instruct-v0.1":{modelName:"mistralai/Mistral-7B-Instruct-v0.1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.2,outputPricePerMillion:.2}}}]},"scb10x/scb10x-llama3-1-typhoon2-8b-instruct":{modelName:"scb10x/scb10x-llama3-1-typhoon2-8b-instruct",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.18000000000000002,outputPricePerMillion:.18000000000000002}}}]},"mistralai/Mixtral-8x7B-v0.1":{modelName:"mistralai/Mixtral-8x7B-v0.1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.6,outputPricePerMillion:.6}}}]},"black-forest-labs/FLUX.1-dev-lora":{modelName:"black-forest-labs/FLUX.1-dev-lora",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"deepseek-ai/DeepSeek-R1":{modelName:"deepseek-ai/DeepSeek-R1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:7}}}]},"arcee-ai/arcee-blitz":{modelName:"arcee-ai/arcee-blitz",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.45,outputPricePerMillion:.75}}}]},"deepseek-ai/DeepSeek-V3-p-dp":{modelName:"deepseek-ai/DeepSeek-V3-p-dp",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:1.25}}}]},"deepseek-ai/DeepSeek-R1-Distill-Qwen-14B":{modelName:"deepseek-ai/DeepSeek-R1-Distill-Qwen-14B",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.6,outputPricePerMillion:1.6}}}]},"deepseek-ai/DeepSeek-V3":{modelName:"deepseek-ai/DeepSeek-V3",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:1.25}}}]},"Qwen/Qwen2.5-VL-72B-Instruct":{modelName:"Qwen/Qwen2.5-VL-72B-Instruct",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.95,outputPricePerMillion:8}}}]},"Qwen/Qwen2.5-Coder-32B-Instruct":{modelName:"Qwen/Qwen2.5-Coder-32B-Instruct",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.8,outputPricePerMillion:.8}}}]},"meta-llama/Llama-3.3-70B-Instruct-Turbo":{modelName:"meta-llama/Llama-3.3-70B-Instruct-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.88,outputPricePerMillion:.88}}}]},"Qwen/Qwen2-72B-Instruct":{modelName:"Qwen/Qwen2-72B-Instruct",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.9,outputPricePerMillion:.9}}}]},"microsoft/WizardLM-2-8x22B":{modelName:"microsoft/WizardLM-2-8x22B",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.2,outputPricePerMillion:1.2}}}]},"deepseek-ai/DeepSeek-R1-Distill-Llama-70B":{modelName:"deepseek-ai/DeepSeek-R1-Distill-Llama-70B",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:2,outputPricePerMillion:2}}}]},"meta-llama/Llama-3.2-11B-Vision-Instruct-Turbo":{modelName:"meta-llama/Llama-3.2-11B-Vision-Instruct-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.18000000000000002,outputPricePerMillion:.18000000000000002}}}]},"deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B":{modelName:"deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.18000000000000002,outputPricePerMillion:.18000000000000002}}}]},"meta-llama/Llama-3.2-90B-Vision-Instruct-Turbo":{modelName:"meta-llama/Llama-3.2-90B-Vision-Instruct-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.2,outputPricePerMillion:1.2}}}]},"meta-llama/Meta-Llama-3-8B-Instruct-Lite":{modelName:"meta-llama/Meta-Llama-3-8B-Instruct-Lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.1}}}]},"black-forest-labs/FLUX.1-schnell":{modelName:"black-forest-labs/FLUX.1-schnell",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"mistralai/Mixtral-8x7B-Instruct-v0.1":{modelName:"mistralai/Mixtral-8x7B-Instruct-v0.1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.6,outputPricePerMillion:.6}}}]},"meta-llama/Llama-3-70b-chat-hf":{modelName:"meta-llama/Llama-3-70b-chat-hf",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.88,outputPricePerMillion:.88}}}]},"mistralai/Mistral-7B-Instruct-v0.3":{modelName:"mistralai/Mistral-7B-Instruct-v0.3",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.2,outputPricePerMillion:.2}}}]},"Salesforce/Llama-Rank-V1":{modelName:"Salesforce/Llama-Rank-V1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.1}}}]},"nvidia/Llama-3.1-Nemotron-70B-Instruct-HF":{modelName:"nvidia/Llama-3.1-Nemotron-70B-Instruct-HF",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.88,outputPricePerMillion:.88}}}]},"meta-llama/Llama-Vision-Free":{modelName:"meta-llama/Llama-Vision-Free",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"meta-llama/Llama-Guard-3-11B-Vision-Turbo":{modelName:"meta-llama/Llama-Guard-3-11B-Vision-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.18000000000000002,outputPricePerMillion:.18000000000000002}}}]},"meta-llama/Llama-3.2-3B-Instruct-Turbo":{modelName:"meta-llama/Llama-3.2-3B-Instruct-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.060000000000000005,outputPricePerMillion:.060000000000000005}}}]},"black-forest-labs/FLUX.1-dev":{modelName:"black-forest-labs/FLUX.1-dev",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"Qwen/Qwen2.5-72B-Instruct-Turbo":{modelName:"Qwen/Qwen2.5-72B-Instruct-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.2,outputPricePerMillion:1.2}}}]},"arcee-ai/virtuoso-medium-v2":{modelName:"arcee-ai/virtuoso-medium-v2",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:.8}}}]},"arcee-ai/virtuoso-large":{modelName:"arcee-ai/virtuoso-large",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.75,outputPricePerMillion:1.2}}}]},"arcee-ai/maestro-reasoning":{modelName:"arcee-ai/maestro-reasoning",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.9,outputPricePerMillion:3.3}}}]},"arcee-ai/coder-large":{modelName:"arcee-ai/coder-large",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:.8}}}]},"arcee_ai/arcee-spotlight":{modelName:"arcee_ai/arcee-spotlight",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.18000000000000002,outputPricePerMillion:.18000000000000002}}}]},"Qwen/QwQ-32B":{modelName:"Qwen/QwQ-32B",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.2,outputPricePerMillion:1.2}}}]},"meta-llama/Llama-4-Scout-17B-16E-Instruct":{modelName:"meta-llama/Llama-4-Scout-17B-16E-Instruct",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.18000000000000002,outputPricePerMillion:.5900000000000001}}}]},"meta-llama/Llama-2-70b-hf":{modelName:"meta-llama/Llama-2-70b-hf",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.9,outputPricePerMillion:.9}}}]},"meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo":{modelName:"meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3.5,outputPricePerMillion:3.5}}}]},"meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo":{modelName:"meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.88,outputPricePerMillion:.88}}}]},"meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo":{modelName:"meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.18000000000000002,outputPricePerMillion:.18000000000000002}}}]}};var we=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string()}),Q=class{constructor(t,n){this.version="v1";let a=we.parse(n);this.modelSchema=t,this.modelName=a.modelName,this.apiKey=a.apiKey,this.baseUrl=j(L.baseUrl),this.streamChatUrl=j(`${this.baseUrl}/chat/completions`),this.completeChatUrl=j(`${this.baseUrl}/chat/completions`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"}}getDefaultParams(){return {model:this.modelName}}getRetryDelay(t){return {shouldRetry:!0,delayMs:0}}getTokenCount(t){return t.reduce((n,a)=>n+a.content.map(i=>i.modality==="text"?i.value:"").join(" ").length,0)}transformModelRequest(t){let n=Vt.safeParse(t);if(!n.success)throw new O({info:"Invalid model request",cause:n.error});let a=n.data,i=a.model;if(a.tool_choice&&(!a.tools||a.tools.length===0))throw new O({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let s={};a.response_format&&(s.responseFormat=a.response_format.type,a.response_format.type==="json_schema"&&(s.responseSchema={name:a.response_format.json_schema.name,description:a.response_format.json_schema.description||"",strict:a.response_format.json_schema.strict,schema:a.response_format.json_schema.schema})),a.tool_choice&&(typeof a.tool_choice=="string"?s.toolChoice=a.tool_choice:s.toolChoice=a.tool_choice.function.name),s.seed=a.seed,s.maxTokens=a.max_tokens,s.temperature=a.temperature,s.topP=a.top_p,s.minP=a.min_p,s.topK=a.top_k,s.repetitionPenalty=a.repetition_penalty,s.presencePenalty=a.presence_penalty,s.frequencyPenalty=a.frequency_penalty,s.repetitionPenalty=a.repetition_penalty,s.stop=a.stop,s.logProbs=a.logprobs!==0,s.echo=a.echo;let l=V().parse(H(s)),m=[],u={};a.messages.forEach(d=>{let f=d.role;switch(f){case"system":m.push({role:f,content:[{modality:M,value:d.content}]});break;case"user":m.push({role:f,content:[{modality:M,value:d.content}]});break;case"assistant":{let y=[];if(!d.content&&!d.tool_calls)throw new O({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("one of'content' or 'tool_calls' must be provided")});d.content&&y.push({modality:M,value:d.content}),d.tool_calls&&d.tool_calls.forEach((v,k)=>{let A={modality:I,id:v.id,index:k,name:v.function.name,arguments:v.function.arguments};y.push(A),u[A.id]=A;}),m.push({role:f,content:y});}break;case"tool":{let y=d;m.push({role:f,content:[{modality:w,id:y.tool_call_id,index:u[y.tool_call_id].index,name:u[y.tool_call_id].name,data:y.content}]});}break}});let g=[];return a.tools&&a.tools.forEach(d=>{g.push({type:"function",definition:{schema:{name:d.function.name,description:d.function.description||"",strict:d.function.strict,parameters:d.function.parameters}}});}),{modelName:i,config:l,messages:m,tools:g.length>0?g:void 0}}transformConfig(t,n,a){let i=t.toolChoice;delete t.toolChoice;let s=this.modelSchema.config.schema.safeParse(t);if(!s.success)throw new S({info:`Invalid config for model : '${this.modelName}'`,cause:s.error});let l=s.data;i!==void 0&&(l.toolChoice=i),Object.keys(l).forEach(u=>{if(!(u in this.modelSchema.config.def))throw new S({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${u}',
7
- available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let m=Object.keys(l).reduce((u,g)=>{let d=this.modelSchema.config.def[g],f=d.param,y=l[g];return f==="max_tokens"&&d.type==="range"&&y===0?u[f]=d.max:f==="logprobs"&&d.type==="select-boolean"?y===!0?u[f]=1:u[f]=0:u[f]=y,u},{});if(m.top_logprobs&&!m.logprobs)throw new S({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'logprobs' must be 'true' when 'top_logprobs' is specified")});if("tool_choice"in m&&m.tool_choice!==void 0){let u=m.tool_choice;if(!a||a&&a.length===0)throw new S({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(a&&a.length>0){let g=this.modelSchema.config.def.toolChoice;if(!g.choices.includes(u))if(a.map(d=>d.definition.schema.name).includes(u))m.tool_choice={type:"function",function:{name:u}};else throw new S({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`toolChoice : '${u}' is not part of provided 'tools' names or
8
- one of [${g.choices.join(", ")}]`)})}}if("response_format"in m&&m.response_format!==void 0){let u=m.response_format;if(u==="json_schema")if("response_schema"in m)m.response_format={type:"json_schema",json_schema:m.response_schema},delete m.response_schema;else throw new S({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'responseSchema' is required in config when 'responseFormat' is 'json_schema'")});else m.response_format={type:u};}return m}transformMessages(t){if(!t||t&&t.length===0)return {messages:[]};let n=t.map(i=>{let s=ee().safeParse(i);if(!s.success)throw new R({info:"Invalid messages",cause:s.error});return s.data});return n.forEach(i=>{i.content.forEach(s=>{if(!this.modelSchema.modalities.includes(s.modality))throw new R({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${s.modality}',
9
- available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),n.forEach(i=>{if(!Object.keys(this.modelSchema.roles).includes(i.role))throw new R({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${i.role}',
10
- available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}),{messages:n.map(i=>{switch(i.role){case q:{let s="";return i.content.forEach(l=>{if(l.modality===M)s+=l.value+`
11
- `;else throw new R({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${i.role}' cannot have content with modality : '${l.modality}'`)})}),{role:this.modelSchema.roles[i.role],content:s}}case x:{let s="",l=[];return i.content.forEach(m=>{if(m.modality===M)s+=m.value+`
12
- `;else if(m.modality===I)l.push({id:m.id,type:"function",function:{name:m.name,arguments:m.arguments}});else throw new R({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${i.role}' cannot have content with modality : '${m.modality}'`)})}),b({role:this.modelSchema.roles[i.role],content:s},l.length>0?{tool_calls:l}:{})}case D:{let s="";return i.content.forEach(l=>{if(l.modality===M)s+=l.value+`
13
- `;else throw new R({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${i.role}' cannot have content with modality : '${l.modality}'`)})}),{role:this.modelSchema.roles[i.role],content:s}}case B:{if(i.content.length!==1)throw new R({info:`Invalid message for role : '${i.role}'`,cause:new Error(`role : '${i.role}' must have exactly one content item`)});if(i.content[0].modality!==w)throw new R({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${i.role}' must have content with modality : '${w}'`)});let s=i.content[0];return {role:this.modelSchema.roles[i.role],tool_call_id:s.id,content:s.data}}default:throw new R({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${i.role}' is not supported,
14
- available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}})}}transformTools(t){if(!this.modelSchema.modalities.includes(I))throw new ae({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${I}'`)});return !t||t&&t.length===0?{tools:[]}:{tools:t.map(i=>{let s=it().safeParse(i);if(!s.success)throw new ae({info:"Invalid tools",cause:s.error});return s.data}).map(i=>({type:"function",function:i.definition.schema}))}}getCompleteChatUrl(t,n,a){return P(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getCompleteChatHeaders(t,n,a){return P(this,null,function*(){return new Promise(i=>{i(this.getDefaultHeaders());})})}getCompleteChatData(t,n,a){return P(this,null,function*(){let i=this.transformConfig(t,n,a),s=this.transformMessages(n);if(s.messages&&s.messages.length===0)throw new R({info:"Messages are required",cause:new Error("Messages are required")});let l=a?this.transformTools(a):{};return new Promise(m=>{m(b(b(b(b({},this.getDefaultParams()),i),s),l));})})}transformCompleteChatResponse(t){let n=$t.safeParse(t);if(n.success){if(n.data.choices.length===0)throw new _({info:"Invalid response from model",cause:new Error(`No choices in response : ${JSON.stringify(n.data)}`)});let a=n.data,i=[{role:x,content:[]}],s=a.choices[0].message;s.content&&i[0].content.push(st(s.content)),s.tool_calls&&s.tool_calls.forEach((g,d)=>{i[0].content.push(rt(d,g.id,g.function.name,g.function.arguments));});let l;a.usage&&(l={promptTokens:a.usage.prompt_tokens,completionTokens:a.usage.completion_tokens,totalTokens:a.usage.total_tokens});let m=[],u=a.choices[0].logprobs;return u&&u.tokens.forEach((g,d)=>{m.push({token:g,logProb:u.token_logprobs[d],bytes:null,topLogProbs:[]});}),{messages:i,usage:l,logProbs:m}}throw new _({info:"Invalid response from model",cause:n.error})}getStreamChatUrl(t,n,a){return P(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getStreamChatHeaders(t,n,a){return P(this,null,function*(){return new Promise(i=>{i(this.getDefaultHeaders());})})}getStreamChatData(t,n,a){return P(this,null,function*(){let i=this.transformConfig(t,n,a),s=this.transformMessages(n);if(s.messages&&s.messages.length===0)throw new R({info:"Messages are required",cause:new Error("Messages are required")});let l=a?this.transformTools(a):{};return new Promise(m=>{m(b(b(b(b({stream:!0,stream_options:{include_usage:!0}},this.getDefaultParams()),i),s),l));})})}transformStreamChatResponseChunk(t,n){return K(this,null,function*(){var m,u;let a=n+t,i=[],s="",l=0;for(;l<a.length;){let g=a.indexOf(`
15
- `,l);if(g===-1){s=a.substring(l);break}else {let d=a.substring(l,g).trim();d&&i.push(d),l=g+1;}}for(let g of i){if(g==="data: [DONE]")return;if(g.startsWith("data: ")){let d=g.substring(6);try{let f=JSON.parse(d),y=zt.safeParse(f);if(y.success){let T={partialMessages:[]},v=y.data;if(v.choices.length>0){let k=v.choices[0].delta;if(k!==void 0&&Object.keys(k).length!==0){if("content"in k&&k.content!==null)T.partialMessages.push(oe(x,k.content));else if("refusal"in k&&k.refusal!==null)T.partialMessages.push(oe(x,k.refusal));else if("tool_calls"in k&&Array.isArray(k.tool_calls)&&k.tool_calls.length>0){let A=k.tool_calls[0];T.partialMessages.push(lt(x,A.index,A.id,(m=A.function)==null?void 0:m.name,(u=A.function)==null?void 0:u.arguments));}}}v.usage&&(T.usage={promptTokens:v.usage.prompt_tokens,completionTokens:v.usage.completion_tokens,totalTokens:v.usage.total_tokens}),yield {partialResponse:T,buffer:s};}else throw new _({info:"Invalid response from model",cause:y.error})}catch(f){throw new _({info:`Malformed JSON received in stream: ${d}`,cause:f})}}}yield {partialResponse:{partialMessages:[]},buffer:s};})}transformProxyStreamChatResponseChunk(t,n,a,i,s){return K(this,null,function*(){yield*De(this.transformStreamChatResponseChunk(t,n));})}getProxyStreamChatUrl(t,n,a){return P(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getProxyCompleteChatUrl(t,n,a){return P(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getProxyCompleteChatHeaders(t,n,a){return P(this,null,function*(){if(!n)return {};let i=b({},n);return delete i.host,delete i["content-length"],i})}getProxyStreamChatHeaders(t,n,a){return P(this,null,function*(){return yield this.getProxyCompleteChatHeaders(t,n,a)})}getModelPricing(){if(!(this.modelName in Ae))throw new _({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return Ae[this.modelName]}};var Ht=[U],Qt=zod.z.enum([U]);var Gt=zod.z.object({object:zod.z.literal("list"),model:zod.z.string(),data:zod.z.array(zod.z.object({index:zod.z.number(),object:zod.z.literal("embedding"),embedding:zod.z.array(zod.z.number()).or(zod.z.string().base64())})),usage:zod.z.object({prompt_tokens:zod.z.number().nonnegative(),total_tokens:zod.z.number().nonnegative()}).optional()});var ta=zod.z.string().min(1).or(zod.z.array(zod.z.string().min(1)).min(1)),Kt=zod.z.object({model:zod.z.string().min(1).optional(),input:ta});var Ue=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string()}),G=class{constructor(t,n){this.version="v1";let a=Ue.parse(n);this.modelSchema=t,this.modelName=a.modelName,this.apiKey=a.apiKey,this.baseUrl=j(L.baseUrl),this.getEmbeddingsUrl=j(`${this.baseUrl}/embeddings`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"}}getDefaultParams(){return {model:this.modelName}}getRetryDelay(t){return {shouldRetry:!0,delayMs:0}}getTokenCount(t){return t.requests.reduce((n,a)=>n+a.length,0)}transformModelRequest(t){let n=Kt.safeParse(t);if(!n.success)throw new O({info:"Invalid model request",cause:n.error});let a=n.data,i=a.model,s={},l=V().parse(H(s)),m={modality:U,requests:[...a.input]};return {modelName:i,config:l,embeddingRequests:m}}transformConfig(t,n){let a=this.modelSchema.config.schema.safeParse(t);if(!a.success)throw new S({info:`Invalid config for model : '${this.modelName}'`,cause:a.error});let i=a.data;return Object.keys(i).forEach(l=>{if(!this.modelSchema.config.def[l])throw new S({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${l}',
16
- available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(i).reduce((l,m)=>{let g=this.modelSchema.config.def[m].param,d=i[m];return l[g]=d,l},{})}transformEmbeddingRequests(t){let n=ot().safeParse(t);if(!n.success)throw new ie({info:"Invalid embedding requests",cause:n.error});if(t.modality!==U)throw new ie({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Only '${U}' modality is supported for model : '${this.modelName}'`)});return {input:n.data.requests}}getGetEmbeddingsUrl(t,n){return P(this,null,function*(){return new Promise(a=>{a(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(t,n){return P(this,null,function*(){return new Promise(a=>{a(this.getDefaultHeaders());})})}getGetEmbeddingsData(t,n){return P(this,null,function*(){return new Promise(a=>{a(b(b(b({},this.getDefaultParams()),this.transformConfig(t,n)),this.transformEmbeddingRequests(n)));})})}transformGetEmbeddingsResponse(t){var a;let n=Gt.safeParse(t);if(n.success){let i=n.data,s=i.data.map(l=>({index:l.index,embedding:l.embedding}));return {encodingFormat:ne,embeddings:s,usage:{totalTokens:(a=i.usage)==null?void 0:a.total_tokens}}}throw new _({info:"Invalid response from model",cause:n.error})}};var Ee=jt(Qt).parse({name:"__base__",description:"Base embedding model for Together AI",maxInputTokens:128e3,maxOutputTokens:128e3,modalities:Ht,config:{def:{},schema:zod.z.object({})}});
5
+ var tn=Object.defineProperty;var Ne=Object.getOwnPropertySymbols;var nn=Object.prototype.hasOwnProperty,on=Object.prototype.propertyIsEnumerable;var z=(o,t)=>(t=Symbol[o])?t:Symbol.for("Symbol."+o),an=o=>{throw TypeError(o)};var Le=(o,t,n)=>t in o?tn(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n,T=(o,t)=>{for(var n in t||(t={}))nn.call(t,n)&&Le(o,n,t[n]);if(Ne)for(var n of Ne(t))on.call(t,n)&&Le(o,n,t[n]);return o};var P=(o,t,n)=>new Promise((a,r)=>{var i=u=>{try{m(n.next(u));}catch(g){r(g);}},l=u=>{try{m(n.throw(u));}catch(g){r(g);}},m=u=>u.done?a(u.value):Promise.resolve(u.value).then(i,l);m((n=n.apply(o,t)).next());}),qe=function(o,t){this[0]=o,this[1]=t;},K=(o,t,n)=>{var a=(l,m,u,g)=>{try{var d=n[l](m),y=(m=d.value)instanceof qe,f=d.done;Promise.resolve(y?m[0]:m).then(b=>y?a(l==="return"?l:"next",m[1]?{done:b.done,value:b.value}:b,u,g):u({value:b,done:f})).catch(b=>a("throw",b,u,g));}catch(b){g(b);}},r=l=>i[l]=m=>new Promise((u,g)=>a(l,m,u,g)),i={};return n=n.apply(o,t),i[z("asyncIterator")]=()=>i,r("next"),r("throw"),r("return"),i},De=o=>{var t=o[z("asyncIterator")],n=!1,a,r={};return t==null?(t=o[z("iterator")](),a=i=>r[i]=l=>t[i](l)):(t=t.call(o),a=i=>r[i]=l=>{if(n){if(n=!1,i==="throw")throw l;return l}return n=!0,{done:!1,value:new qe(new Promise(m=>{var u=t[i](l);u instanceof Object||an("Object expected"),m(u);}),1)}}),r[z("iterator")]=()=>r,a("next"),"throw"in t?a("throw"):r.throw=i=>{throw i},"return"in t&&a("return"),r};var q="system",D="user",v="assistant",B="tool",rn=[q,D,v,B],J=zod.z.enum(rn),sn=[v],ln=zod.z.enum(sn),$e="error",ze="safety",mn=zod.z.object({type:zod.z.literal(ze),value:zod.z.object({category:zod.z.string(),probability:zod.z.string(),blocked:zod.z.boolean(),message:zod.z.string()})}),cn=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal($e),value:zod.z.discriminatedUnion("type",[mn]),metadata:o}),Ve="partial-error",pn=zod.z.object({type:zod.z.literal(ze),category:zod.z.string().optional(),probability:zod.z.string().optional(),blocked:zod.z.boolean().optional(),message:zod.z.string().optional()}),un=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Ve),value:zod.z.discriminatedUnion("type",[pn]),metadata:o}),He="image",dn="base64",gn=["png","jpeg","webp","gif"],hn=zod.z.object({type:zod.z.literal(dn),base64:zod.z.string(),mediaType:zod.z.enum(gn)}),yn="url",fn=zod.z.object({type:zod.z.literal(yn),url:zod.z.string()}),bn=zod.z.discriminatedUnion("type",[hn,fn]),Tn=["low","medium","high","auto"],Pn=zod.z.enum(Tn),kn=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(He),detail:Pn,value:bn,metadata:o}),Qe="pdf",Mn="base64",Cn=zod.z.object({type:zod.z.literal(Mn),base64:zod.z.string()}),Rn="url",vn=zod.z.object({type:zod.z.literal(Rn),url:zod.z.string()}),xn=zod.z.discriminatedUnion("type",[Cn,vn]),In=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Qe),value:xn,file:zod.z.object({name:zod.z.string(),id:zod.z.string(),size:zod.z.number().optional()}),metadata:o}),Ge="reasoning",Ke="partial-reasoning",Xe="thinking",Sn="redacted",W=zod.z.object({type:zod.z.literal(Xe),thinking:zod.z.string(),signature:zod.z.string()}),We=zod.z.object({type:zod.z.literal(Sn),data:zod.z.string()}),En=zod.z.discriminatedUnion("type",[W,We]),wn=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Ge),value:En,metadata:o}),jn=zod.z.object({type:zod.z.literal(Xe),thinking:W.shape.thinking.optional(),signature:W.shape.signature.optional()}),Un=zod.z.discriminatedUnion("type",[jn,We]),_n=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Ke),value:Un,metadata:o}),Je="search-result",Ye="google",An=zod.z.object({type:zod.z.literal(Ye),query:zod.z.string(),responses:zod.z.array(zod.z.object({source:zod.z.string(),url:zod.z.string(),title:zod.z.string(),snippet:zod.z.string().optional()})),references:zod.z.array(zod.z.object({text:zod.z.string(),responseIndices:zod.z.array(zod.z.number()),startIndex:zod.z.number().optional(),endIndex:zod.z.number().optional(),confidenceScores:zod.z.array(zod.z.number()).optional()}))}),Nn=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Je),value:zod.z.discriminatedUnion("type",[An]),metadata:o}),Ze="partial-search-result",Ln=zod.z.object({type:zod.z.literal(Ye),query:zod.z.string().optional(),responses:zod.z.array(zod.z.object({source:zod.z.string().optional(),url:zod.z.string().optional(),title:zod.z.string().optional(),snippet:zod.z.string().optional()})).optional(),references:zod.z.array(zod.z.object({text:zod.z.string().optional(),responseIndices:zod.z.array(zod.z.number()).optional(),startIndex:zod.z.number().optional(),endIndex:zod.z.number().optional(),confidenceScores:zod.z.array(zod.z.number()).optional()})).optional()}),qn=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Ze),value:zod.z.discriminatedUnion("type",[Ln]),metadata:o}),M="text",et=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(M),value:zod.z.string(),metadata:o}),Y="partial-text",tt=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Y),value:zod.z.string(),metadata:o}),x="tool-call",nt=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(x),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),arguments:zod.z.string(),serverName:zod.z.string().optional(),metadata:o}),Z="partial-tool-call",ot=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Z),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),arguments:zod.z.string().optional(),serverName:zod.z.string().optional(),metadata:o}),w="tool-response",Dn=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(w),index:zod.z.number().int().nonnegative(),id:zod.z.string().min(1),name:zod.z.string().min(1),data:zod.z.string(),apiResponse:zod.z.object({statusCode:zod.z.number().int().nonnegative()}).optional(),metadata:o}),Bn="partial-tool-response",On=(o=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Bn),index:zod.z.number().int().nonnegative(),id:zod.z.string().optional(),name:zod.z.string().optional(),data:zod.z.string().optional(),apiResponse:zod.z.object({statusCode:zod.z.number().int().nonnegative()}).optional(),metadata:o}),Fn=[M,He,Qe,x,w,Ge,$e,Je],at=zod.z.enum(Fn),$n=(o=zod.z.undefined(),t=zod.z.undefined(),n=zod.z.undefined(),a=zod.z.undefined(),r=zod.z.undefined(),i=zod.z.undefined(),l=zod.z.undefined(),m=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[et(o),kn(t),In(n),nt(a),Dn(r),wn(i),cn(l),Nn(m)]),zn=[Y,Z,Ke,Ve,Ze];zod.z.enum(zn);var Vn=(o=zod.z.undefined(),t=zod.z.undefined(),n=zod.z.undefined(),a=zod.z.undefined(),r=zod.z.undefined(),i=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[tt(o),ot(t),_n(a),On(n),un(r),qn(i)]);var ee=(o=J,t=zod.z.undefined(),n=zod.z.undefined(),a=zod.z.undefined(),r=zod.z.undefined(),i=zod.z.undefined(),l=zod.z.undefined(),m=zod.z.undefined())=>zod.z.object({role:o,content:zod.z.array($n(t,n,a,r,l,i)),metadata:m}),te=(o=ln,t=zod.z.undefined(),n=zod.z.undefined(),a=zod.z.undefined(),r=zod.z.undefined(),i=zod.z.undefined())=>zod.z.object({role:o,partialContent:Vn(t,n,a,i),metadata:r}),Hn=zod.z.object({promptTokens:zod.z.number().nonnegative(),completionTokens:zod.z.number().nonnegative(),totalTokens:zod.z.number().nonnegative()}),Be=zod.z.object({token:zod.z.string(),logProb:zod.z.number(),bytes:zod.z.array(zod.z.number().int()).nullable()}),Qn=Be.extend({topLogProbs:zod.z.array(Be)}),rt=zod.z.array(Qn);zod.z.object({messages:zod.z.array(ee()),usage:Hn.optional(),logProbs:rt.optional()});var Gn=zod.z.object({promptTokens:zod.z.number().nonnegative().optional(),completionTokens:zod.z.number().nonnegative().optional(),totalTokens:zod.z.number().nonnegative().optional()});zod.z.object({partialMessages:zod.z.array(te()),usage:Gn.optional(),logProbs:rt.optional()});var V=(o=zod.z.record(zod.z.string(),zod.z.any()).optional())=>o,Kn=zod.z.object({enabled:zod.z.boolean().default(!0),allowedTools:zod.z.array(zod.z.string().min(1))});zod.z.object({type:zod.z.literal("url"),url:zod.z.string().url().refine(o=>o.startsWith("https://"),{message:"MCP server URL must start with https://"}),name:zod.z.string().min(1),toolConfiguration:Kn.optional(),authorizationToken:zod.z.string().min(1).optional()});var Xn=["object","array","number","string","boolean","enum"],Oe=zod.z.enum(Xn),Wn=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:zod.z.union([Oe,zod.z.array(zod.z.union([Oe,zod.z.literal("null")]))]).optional(),default:zod.z.any().optional(),title:zod.z.string().optional(),description:zod.z.string().max(4096).optional(),properties:zod.z.record(zod.z.any()).optional(),required:zod.z.array(zod.z.string()).optional(),minItems:zod.z.number().int().min(0).optional(),maxItems:zod.z.number().int().optional(),items:zod.z.record(zod.z.any()).optional(),enum:zod.z.array(zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),minLength:zod.z.number().int().min(0).optional(),maxLength:zod.z.number().int().optional(),$ref:zod.z.string().optional()}),Jn=zod.z.object({type:zod.z.enum(["object"]),required:zod.z.array(zod.z.string()),$defs:zod.z.record(zod.z.any()).optional(),properties:zod.z.record(Wn),additionalProperties:zod.z.literal(!1)}),it=zod.z.object({name:zod.z.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:zod.z.string().max(4096),strict:zod.z.boolean().optional(),schema:Jn}).optional(),j="text",st="token",Yn=[j,st],lt=zod.z.enum(Yn),Zn=zod.z.array(zod.z.string().min(1)),eo=zod.z.array(zod.z.array(zod.z.number().int().nonnegative())),mt=(o=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[zod.z.object({modality:zod.z.literal(j),metadata:o,requests:Zn}),zod.z.object({modality:zod.z.literal(st),metadata:o,requests:eo})]),ne="float",to=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),no="base64",oo=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),Fe=zod.z.object({totalTokens:zod.z.number().int().nonnegative()});zod.z.discriminatedUnion("encodingFormat",[zod.z.object({encodingFormat:zod.z.literal(ne),embeddings:zod.z.array(to),usage:Fe.optional()}),zod.z.object({encodingFormat:zod.z.literal(no),embeddings:zod.z.array(oo),usage:Fe.optional()})]);var ao=o=>{let t=new WeakSet;return JSON.stringify(o,(n,a)=>{if(typeof a=="object"&&a!==null){if(t.has(a))return;t.add(a);}return a})},ro=o=>o==null?"unknown error":typeof o=="string"?o:o instanceof Error?o.message:ao(o),X="GatewayBaseError",A=class ct extends Error{constructor({info:t,cause:n},a){super(`[${a!=null?a:X}]: ${t}
6
+ Message: ${ro(n)}`),this.name=X,this.info=t,this.cause=n,this.name=a!=null?a:X,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(t){return t instanceof ct}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},io=zod.z.object({inputPricePerMillion:zod.z.number().nonnegative().describe("Price per 1M input tokens"),outputPricePerMillion:zod.z.number().nonnegative().describe("Price per 1M output tokens")}).describe("Input/output price pair (per 1M tokens) for a specific category within a ChatModel pricing tier."),so=zod.z.object({base:io.describe("Base (uncached, non\u2011reasoning) rates")}).describe("Holds the `ChatModelTokenPairPrice` for different categories (e.g., base) within a single pricing tier."),lo=zod.z.object({minTokens:zod.z.number().int().nonnegative().describe("Inclusive lower token bound for this tier."),maxTokens:zod.z.number().int().nullable().optional().describe("Exclusive upper token bound; `null` means \u221E."),prices:so.describe("Price categories and rates for this specific token range.")}).refine(o=>o.maxTokens===null||typeof o.maxTokens=="number"&&o.maxTokens>o.minTokens,{message:"maxTokens must be > minTokens (or null for infinite).",path:["maxTokens"]}).describe("A single pricing tier defined by a token range and associated prices.");zod.z.object({modelName:zod.z.string().describe("Model name this schedule applies to."),currency:zod.z.string().default("USD").describe("Currency code (e.g., USD)."),tokenRanges:zod.z.array(lo).min(1).describe("Pricing tiers (`ChatModelTokenRangePrice`) schedule, sorted by minTokens.")}).superRefine((o,t)=>{let{tokenRanges:n}=o;n[0].minTokens!==0&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",0,"minTokens"],message:"The first tier must have minTokens = 0."});for(let r=1;r<n.length;r++){let i=n[r-1],l=n[r];if(i.maxTokens===null){t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",r-1,"maxTokens"],message:"Cannot define any tokenRanges after an infinite tier (maxTokens = null)."});break}l.minTokens!==i.maxTokens&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",r,"minTokens"],message:`Tier ${r} minTokens (${l.minTokens}) must equal previous tier's maxTokens (${i.maxTokens}) for contiguity.`}),l.minTokens<i.minTokens&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",r,"minTokens"],message:`tokenRanges must be sorted by ascending minTokens. Tier ${r} (${l.minTokens}) starts before Tier ${r-1} (${i.minTokens}).`});}let a=n[n.length-1];n.every(r=>r.maxTokens!==null||r===a)&&a.maxTokens!==null&&t.addIssue({code:zod.z.ZodIssueCode.custom,path:["tokenRanges",n.length-1,"maxTokens"],message:"The final tier must have maxTokens = null (representing infinity)."});}).describe("Complete pricing schedule for a single chat model, including all its token-based tiers.");var mo="function";var co=zod.z.enum(["object","array","number","string","boolean","null"]),po=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:co.optional(),default:zod.z.any().optional(),title:zod.z.string().optional(),description:zod.z.string().max(4096).optional(),properties:zod.z.record(zod.z.any()).optional(),required:zod.z.array(zod.z.string()).optional(),minItems:zod.z.number().int().min(0).optional(),maxItems:zod.z.number().int().optional(),items:zod.z.record(zod.z.any()).optional(),enum:zod.z.array(zod.z.union([zod.z.string(),zod.z.number(),zod.z.boolean(),zod.z.null()])).optional(),minimum:zod.z.number().optional(),maximum:zod.z.number().optional(),minLength:zod.z.number().int().min(0).optional(),maxLength:zod.z.number().int().optional()});zod.z.object({type:zod.z.enum(["object"]),title:zod.z.string().optional(),$defs:zod.z.record(zod.z.any()).optional(),properties:zod.z.record(po).optional(),required:zod.z.array(zod.z.string()).optional()});var uo=zod.z.object({name:zod.z.string().regex(/^[a-zA-Z0-9_]{1,64}$/).max(64),description:zod.z.string().max(4096),parameters:zod.z.any(),strict:zod.z.boolean().optional()});var go=zod.z.enum(["function"]),ho=zod.z.object({maxAttempts:zod.z.number().int().positive(),initialDelay:zod.z.number().int().positive(),exponentialFactor:zod.z.number().int().positive()}),yo=zod.z.object({type:zod.z.literal("http"),method:zod.z.enum(["get","post"]),url:zod.z.string().url(),headers:zod.z.record(zod.z.string()).optional(),query:zod.z.record(zod.z.string()).optional(),body:zod.z.record(zod.z.any()).optional(),proxyUrl:zod.z.string().url().optional(),proxyHeaders:zod.z.record(zod.z.string()).optional(),retry:ho.optional()}),fo=zod.z.discriminatedUnion("type",[yo]),bo=zod.z.object({type:go,definition:zod.z.object({schema:uo}),request:fo.optional()}),To=[mo];zod.z.enum(To);var pt=(o=zod.z.undefined())=>zod.z.discriminatedUnion("type",[bo.extend({metadata:o})]),ut=o=>et().parse({modality:M,value:o}),dt=(o,t,n,a,r)=>nt().parse({modality:x,index:o,id:t,name:n,arguments:a,serverName:r});var oe=(o,t)=>te().parse({role:o,partialContent:tt().parse({modality:Y,value:t})}),gt=(o,t,n,a,r,i)=>te().parse({role:o,partialContent:ot().parse({modality:Z,index:t,id:n,name:a,arguments:r,serverName:i})});var Po=Object.defineProperty,ht=Object.getOwnPropertySymbols,ko=Object.prototype.hasOwnProperty,Mo=Object.prototype.propertyIsEnumerable,yt=(o,t,n)=>t in o?Po(o,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):o[t]=n,F=(o,t)=>{for(var n in t||(t={}))ko.call(t,n)&&yt(o,n,t[n]);if(ht)for(var n of ht(t))Mo.call(t,n)&&yt(o,n,t[n]);return o};var ft="ModelResponseError",_=class Rt extends A{constructor({info:t,cause:n}){super({info:t,cause:n},ft),this.name=ft,this.cause=n,this.info=t;}static isModelResponseError(t){return t instanceof Rt}},bt="InvalidModelRequestError",O=class vt extends A{constructor({info:t,cause:n}){super({info:t,cause:n},bt),this.name=bt,this.cause=n,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidModelRequestError(t){return t instanceof vt}},Tt="InvalidConfigError",S=class xt extends A{constructor({info:t,cause:n}){super({info:t,cause:n},Tt),this.name=Tt,this.cause=n,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidConfigError(t){return t instanceof xt}},Pt="InvalidMessagesError",R=class It extends A{constructor({info:t,cause:n}){super({info:t,cause:n},Pt),this.name=Pt,this.cause=n,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidMessagesError(t){return t instanceof It}},kt="InvalidToolsError",ae=class St extends A{constructor({info:t,cause:n}){super({info:t,cause:n},kt),this.name=kt,this.cause=n,this.info=t,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidToolsError(t){return t instanceof St}},Mt="InvalidEmbeddingRequestsError",re=class Et extends A{constructor({info:t,cause:n}){super({info:t,cause:n},Mt),this.name=Mt,this.info=t,this.cause=n,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(t){return t instanceof Et}},ie="multi-string",wt=zod.z.object({type:zod.z.literal(ie),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),max:zod.z.number().int().positive()}),Co=o=>zod.z.array(zod.z.string()).max(o).default([]).optional(),jt=o=>({def:wt.parse(F({type:ie},o)),schema:Co(o.max)}),se="object-schema",Ut=zod.z.object({type:zod.z.literal(se),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),objectSchema:zod.z.any()}),Ro=o=>o.optional(),_t=o=>({def:Ut.parse(F({type:se},o)),schema:Ro(o.objectSchema)}),At="paired-select",vo=zod.z.object({value:zod.z.string().min(1),label:zod.z.string().min(1)}),Ct=zod.z.object({key:zod.z.string().min(1),label:zod.z.string().min(1),description:zod.z.string().min(1).max(500).optional(),choices:zod.z.array(vo).min(1)}),xo=zod.z.object({type:zod.z.literal(At),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),fields:zod.z.tuple([Ct,Ct]),uniqueByField:zod.z.string().min(1).optional()});var le="range",Nt=zod.z.object({type:zod.z.literal(le),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),min:zod.z.number().int(),max:zod.z.number().int(),step:zod.z.number().positive(),default:zod.z.number()}),Io=(o,t,n,a)=>zod.z.number().min(o).max(t).step(n).default(a).optional(),E=o=>({def:Nt.parse(F({type:le},o)),schema:Io(o.min,o.max,o.step,o.default)}),me="select-boolean",Lt=zod.z.object({type:zod.z.literal(me),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),default:zod.z.boolean().nullable()}),So=o=>zod.z.boolean().nullable().default(o).optional(),qt=o=>({def:Lt.parse(F({type:me},o)),schema:So(o.default)}),ce="select-string",Dt=zod.z.object({type:zod.z.literal(ce),param:zod.z.string().min(1),title:zod.z.string().min(1),description:zod.z.string().min(1).max(500),default:zod.z.string(),choices:zod.z.array(zod.z.string())}),Eo=(o,t)=>zod.z.enum(t).nullable().default(o).optional(),pe=o=>({def:Dt.parse(F({type:ce},o)),schema:Eo(o.default,o.choices)}),wo=[le,ie,ce,se,me,At];zod.z.enum(wo);var Bt=zod.z.discriminatedUnion("type",[Nt,wt,Dt,Lt,Ut,xo]),Ot=(o=J,t=at)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(o,zod.z.string().min(1).optional()),modalities:zod.z.array(t).nonempty(),maxInputTokens:zod.z.number().int().positive().min(1),maxOutputTokens:zod.z.number().int().positive().min(1),maxReasoningTokens:zod.z.number().int().positive().min(1).optional(),config:zod.z.object({def:zod.z.record(zod.z.string().min(1),Bt),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(n=>{var a,r;let i=Object.keys(n.def),l=Object.keys((r=(a=n.schema)==null?void 0:a.shape)!=null?r:{});return i.every(m=>l.includes(m))&&l.every(m=>i.includes(m))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"}),price:zod.z.custom()}),Ft=(o=lt)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),modalities:zod.z.array(o).nonempty(),maxInputTokens:zod.z.number().int().positive().min(1),maxOutputTokens:zod.z.number().int().positive().min(1),config:zod.z.object({def:zod.z.record(zod.z.string().min(1),Bt),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(t=>{var n,a;let r=Object.keys(t.def),i=Object.keys((a=(n=t.schema)==null?void 0:n.shape)!=null?a:{});return r.every(l=>i.includes(l))&&i.every(l=>r.includes(l))},{message:"Keys in 'config.def' must exactly match keys in 'config.schema'"})});zod.z.record(zod.z.string());zod.z.record(zod.z.union([zod.z.boolean(),zod.z.string(),zod.z.number(),zod.z.object({}),zod.z.array(zod.z.any()),zod.z.null(),zod.z.undefined()]));zod.z.string().url();var jo={type:"range",title:"Temperature",description:"Adjusts the model's creativity level. With a setting of 0, the model strictly picks the most probable next word. For endeavors that benefit from a dash of inventiveness, consider dialing it up to 0.7 or higher, enabling the model to produce text that's unexpectedly fresh."},Uo={type:"range",title:"Max tokens",description:"Specify the total tokens for generation, where one token approximates four English characters. Setting this to 0 defaults to the model's maximum capacity."},_o={type:"range",title:"Max reasoning tokens",description:"Specify the total tokens for reasoning, where one token approximates four English characters."},Ao=o=>({type:"multi",title:"Stop sequence",description:`Enter up to ${o} sequences that will halt additional text output. The generated text will exclude these sequences.`}),No={type:"range",title:"Top A",description:"Considers only the top tokens that have 'sufficiently high' probabilities relative to the most likely token, functioning like a dynamic Top-P. A lower Top-A value narrows down the token choices based on the highest probability token, while a higher Top-A value refines the filtering without necessarily impacting the creativity of the output."},Lo={type:"range",title:"Top P",description:"Selects a subset of likely tokens for generation, restricting choices to the top-P fraction of possibilities, such as the top 10% when P=0.1. This approach can limit the variety of the output. By default, it's set to 1, indicating no restriction. It's advised to adjust this parameter or temperature to modulate output diversity, but not to modify both simultaneously."},qo={type:"range",title:"Top K",description:"Select only from the highest K probabilities for each following word, effectively eliminating the less likely 'long tail' options."},Do={type:"range",title:"Min P",description:"Specifies the minimum probability a token must have to be considered, in relation to the probability of the most likely token. (This value varies based on the confidence level of the top token.) For example, if Min-P is set to 0.1, only tokens with at least 1/10th the probability of the highest-ranked token will be considered."},Bo={type:"range",title:"Frequency penalty",description:"Minimize redundancy. By assigning a penalty to frequently used tokens within the text, the likelihood of repeating identical phrases is reduced. The default setting for this penalty is zero."},Oo={type:"range",title:"Presence penalty",description:"Enhance the introduction of novel subjects by reducing the preference for tokens that have already appeared in the text, thus boosting the chances of exploring fresh topics. The standard setting for this is zero."},Fo={type:"range",title:"Seed",description:"When seed is fixed to a specific value, the model makes a best effort to provide the same response for repeated requests. Deterministic output isn't guaranteed. Also, changing the model or parameter settings, such as the temperature, can cause variations in the response even when you use the same seed value. By default, a random seed value is used."},$o={type:"range",title:"Repetition penalty",description:"Reduces the likelihood of repeating tokens from the input. Increasing this value makes the model less prone to repetition, but setting it too high may lead to less coherent output, often resulting in run-on sentences missing smaller words. The token penalty is scaled according to the original token's probability."},zo={type:"boolean",title:"Log probs",description:"Whether to return log probabilities of the output tokens or not. If true, returns the log probabilities of each output token returned."},Vo={type:"range",title:"Top log probs",description:"The number of most likely tokens to return at each token position, each with an associated log probability. 'logprobs' must be set to true if this parameter is used."},Ho={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},Qo={type:"select",title:"Response format",description:"Choose the response format of your model. For JSON, you must include the string 'JSON' in some form within your system / user prompt."},Go={type:"select",title:"Response format",description:"Choose the response format of your model. 'json_object' colloquially known as JSON mode, instructs the model to respond with a valid JSON (must include the term 'json' in prompt). 'json_schema' colloquially known as structured outputs, allows you to specify a strict response schema that the model will adhere to."},Ko={type:"object",title:"Response schema",description:"When response format is set to 'json_schema', the model will return a JSON object of the specified schema."},Xo={type:"object",title:"MCP servers",description:"MCP servers to use for the model."},h={TEMPERATURE:jo,MAX_TOKENS:Uo,STOP:Ao,TOP_A:No,TOP_P:Lo,TOP_K:qo,MIN_P:Do,FREQUENCY_PENALTY:Bo,PRESENCE_PENALTY:Oo,REPETITION_PENALTY:$o,SEED:Fo,LOG_PROBS:zo,TOP_LOG_PROBS:Vo,ECHO:Ho,RESPONSE_FORMAT:Qo,RESPONSE_FORMAT_WITH_SCHEMA:Go,RESPONSE_SCHEMA:Ko,MAX_REASONING_TOKENS:_o,MCP_SERVERS:Xo};var H=o=>Object.fromEntries(Object.entries(o).filter(([t,n])=>n!=null));var N=o=>o==null?void 0:o.replace(/\/$/,"");var ue=E({param:"temperature",title:h.TEMPERATURE.title,description:h.TEMPERATURE.description,min:0,max:1,step:.01,default:1}),de=o=>E({param:"max_tokens",title:h.MAX_TOKENS.title,description:h.MAX_TOKENS.description,min:0,max:o,step:1,default:0}),ge=o=>jt({param:"stop",title:h.STOP(o).title,description:h.STOP(o).description,max:o}),he=E({param:"top_k",title:h.TOP_K.title,description:h.TOP_K.description,min:0,max:1e4,step:1,default:0}),ye=E({param:"top_p",title:h.TOP_P.title,description:h.TOP_P.description,min:0,max:1,step:.01,default:1}),fe=E({param:"min_p",title:h.MIN_P.title,description:h.MIN_P.description,min:0,max:1,step:.01,default:0}),be=E({param:"frequency_penalty",title:h.FREQUENCY_PENALTY.title,description:h.FREQUENCY_PENALTY.description,min:-2,max:2,step:.01,default:0}),Te=E({param:"presence_penalty",title:h.PRESENCE_PENALTY.title,description:h.PRESENCE_PENALTY.description,min:-2,max:2,step:.01,default:0}),Pe=E({param:"repetition_penalty",title:h.REPETITION_PENALTY.title,description:h.REPETITION_PENALTY.description,min:0,max:1e4,step:.01,default:0}),ke=E({param:"seed",title:h.SEED.title,description:h.SEED.description,min:0,max:1e6,step:1,default:0}),Me=qt({param:"logprobs",title:h.LOG_PROBS.title,description:h.LOG_PROBS.description,default:!1}),Ce=pe({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"]}),Re=pe({param:"response_format",title:h.RESPONSE_FORMAT.title,description:h.RESPONSE_FORMAT.description,default:"text",choices:["text","json_object"]}),ve=_t({param:"response_schema",title:h.RESPONSE_SCHEMA.title,description:h.RESPONSE_SCHEMA.description,objectSchema:it});var $t=(o,t)=>zod.z.object({temperature:ue.schema,maxTokens:de(o).schema,stop:ge(t).schema,topP:ye.schema,topK:he.schema,minP:fe.schema,frequencyPenalty:be.schema,presencePenalty:Te.schema,repetitionPenalty:Pe.schema,seed:ke.schema.transform(n=>n===0?void 0:n),logProbs:Me.schema,toolChoice:Ce.schema,responseSchema:ve.schema,responseFormat:Re.schema}),zt=(o,t)=>({temperature:ue.def,maxTokens:de(o).def,stop:ge(t).def,topP:ye.def,topK:he.def,minP:fe.def,frequencyPenalty:be.def,presencePenalty:Te.def,repetitionPenalty:Pe.def,seed:ke.def,logProbs:Me.def,toolChoice:Ce.def,responseSchema:ve.def,responseFormat:Re.def});var xe={base:(o,t)=>({def:zt(o,t),schema:$t(o,t)})};var Vt=zod.z.enum([q,D,v,B]),Ht={system:q,user:D,assistant:v,tool:B};var Qt=[M,x,w],Gt=zod.z.enum([M,x,w]);var Zo=zod.z.object({token_ids:zod.z.array(zod.z.number()),tokens:zod.z.array(zod.z.string()),token_logprobs:zod.z.array(zod.z.number())}),ea=zod.z.array(zod.z.object({id:zod.z.string().min(1),type:zod.z.enum(["function"]),function:zod.z.object({name:zod.z.string(),arguments:zod.z.string()})})),Kt=zod.z.object({id:zod.z.string(),object:zod.z.literal("chat.completion"),created:zod.z.number(),model:zod.z.string(),prompt:zod.z.any(),choices:zod.z.array(zod.z.object({index:zod.z.number(),message:zod.z.object({role:zod.z.string(),content:zod.z.string().nullable().optional(),tool_calls:ea.optional()}),logprobs:Zo.nullable().optional(),seed:zod.z.number().nullable().optional(),finish_reason:zod.z.string()})),usage:zod.z.object({prompt_tokens:zod.z.number(),completion_tokens:zod.z.number(),total_tokens:zod.z.number()}).nullable().optional()}),ta=zod.z.array(zod.z.object({index:zod.z.number().int(),id:zod.z.string().min(1).optional(),type:zod.z.enum(["function"]).optional(),function:zod.z.object({name:zod.z.string().min(1).optional(),arguments:zod.z.string().optional()}).optional()})),Xt=zod.z.object({id:zod.z.string(),object:zod.z.string(),created:zod.z.number(),model:zod.z.string(),choices:zod.z.array(zod.z.object({index:zod.z.number(),delta:zod.z.object({token_id:zod.z.number().nullable().optional(),role:zod.z.string().nullable().optional(),content:zod.z.string().nullable().optional(),tool_calls:ta.nullable().optional()}).or(zod.z.object({})),logprobs:zod.z.any().nullable().optional(),seed:zod.z.number().nullable().optional(),finish_reason:zod.z.string().nullable(),text:zod.z.string().nullable().optional()})),usage:zod.z.object({prompt_tokens:zod.z.number(),completion_tokens:zod.z.number(),total_tokens:zod.z.number()}).nullable().optional()});var na=zod.z.object({type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1).optional(),strict:zod.z.boolean().optional(),parameters:zod.z.any()})}),oa=zod.z.enum(["none","auto","required"]),aa=zod.z.object({type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1)})}),ra=zod.z.object({type:zod.z.enum(["text","json_object"])}).or(zod.z.object({type:zod.z.literal("json_schema"),json_schema:zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1).optional(),strict:zod.z.boolean().optional(),schema:zod.z.any()})})),Ie=zod.z.string(),ia=zod.z.object({id:zod.z.string().min(1),type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1),arguments:zod.z.string().min(1)})}),sa=zod.z.object({role:zod.z.literal("system"),content:Ie}),la=zod.z.object({role:zod.z.literal("user"),content:Ie}),ma=zod.z.object({role:zod.z.literal("assistant"),content:Ie.optional(),tool_calls:zod.z.array(ia).min(1).optional()}),ca=zod.z.object({role:zod.z.literal("tool"),tool_call_id:zod.z.string().min(1),content:zod.z.string().min(1)}),pa=zod.z.union([sa,la,ma,ca]),Wt=zod.z.object({model:zod.z.string().min(1).optional(),messages:zod.z.array(pa).min(1),frequency_penalty:zod.z.number().min(-2).max(2).nullable().optional(),logprobs:zod.z.number().min(0).max(1).nullable().optional(),max_tokens:zod.z.number().min(0).nullable().optional(),presence_penalty:zod.z.number().min(-2).max(2).nullable().optional(),repetition_penalty:zod.z.number().min(0).max(2).nullable().optional(),response_format:ra.optional(),seed:zod.z.number().optional(),stop:zod.z.string().or(zod.z.array(zod.z.string()).max(4)).nullable().optional(),temperature:zod.z.number().min(0).max(1).nullable().optional(),top_p:zod.z.number().min(0).max(1).nullable().optional(),top_k:zod.z.number().min(0).max(1e4).nullable().optional(),min_p:zod.z.number().min(0).max(1).nullable().optional(),echo:zod.z.boolean().nullable().optional(),tools:zod.z.array(na).optional(),tool_choice:oa.or(aa).optional()});var Se=Ot(Vt,Gt).parse({name:"__base__",description:"Base chat model for Together AI",maxInputTokens:128e3,maxOutputTokens:128e3,roles:Ht,modalities:Qt,config:{def:xe.base(128e3,4).def,schema:xe.base(128e3,4).schema}});var ua="together-ai",L=class{constructor(){this.version="v1";this.name=ua;}chatModelLiterals(){return ["__base__"]}chatModelSchemas(){return {__base__:Se}}chatModel(t){let n=Q,a=we.parse(t);return new n(Se,a)}embeddingModelLiterals(){return ["__base__"]}embeddingModelSchemas(){return {__base__:Ee}}embeddingModel(t){let n=G,a=je.parse(t);return new n(Ee,a)}};L.baseUrl="https://api.together.xyz/v1";var Ue={"WhereIsAI/UAE-Large-V1":{modelName:"WhereIsAI/UAE-Large-V1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.016,outputPricePerMillion:.016}}}]},"meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8":{modelName:"meta-llama/Llama-4-Maverick-17B-128E-Instruct-FP8",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.27,outputPricePerMillion:.85}}}]},"togethercomputer/m2-bert-80M-32k-retrieval":{modelName:"togethercomputer/m2-bert-80M-32k-retrieval",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.008,outputPricePerMillion:.008}}}]},"google/gemma-2-9b-it":{modelName:"google/gemma-2-9b-it",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.3,outputPricePerMillion:.3}}}]},"cartesia/sonic":{modelName:"cartesia/sonic",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:65,outputPricePerMillion:0}}}]},"BAAI/bge-large-en-v1.5":{modelName:"BAAI/bge-large-en-v1.5",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.016,outputPricePerMillion:.016}}}]},"NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO":{modelName:"NousResearch/Nous-Hermes-2-Mixtral-8x7B-DPO",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.6,outputPricePerMillion:.6}}}]},"black-forest-labs/FLUX.1-schnell-Free":{modelName:"black-forest-labs/FLUX.1-schnell-Free",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"black-forest-labs/FLUX.1.1-pro":{modelName:"black-forest-labs/FLUX.1.1-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"Qwen/Qwen2.5-7B-Instruct-Turbo":{modelName:"Qwen/Qwen2.5-7B-Instruct-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.3,outputPricePerMillion:.3}}}]},"deepseek-ai/DeepSeek-R1-Distill-Llama-70B-free":{modelName:"deepseek-ai/DeepSeek-R1-Distill-Llama-70B-free",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"meta-llama-llama-2-70b-hf":{modelName:"meta-llama-llama-2-70b-hf",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.9,outputPricePerMillion:.9}}}]},"BAAI/bge-base-en-v1.5":{modelName:"BAAI/bge-base-en-v1.5",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.008,outputPricePerMillion:.008}}}]},"Gryphe/MythoMax-L2-13b":{modelName:"Gryphe/MythoMax-L2-13b",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.3,outputPricePerMillion:.3}}}]},"google/gemma-2-27b-it":{modelName:"google/gemma-2-27b-it",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.8,outputPricePerMillion:.8}}}]},"Qwen/Qwen2-VL-72B-Instruct":{modelName:"Qwen/Qwen2-VL-72B-Instruct",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.2,outputPricePerMillion:1.2}}}]},"meta-llama/LlamaGuard-2-8b":{modelName:"meta-llama/LlamaGuard-2-8b",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.2,outputPricePerMillion:.2}}}]},"cartesia/sonic-2":{modelName:"cartesia/sonic-2",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:65,outputPricePerMillion:0}}}]},"togethercomputer/m2-bert-80M-8k-retrieval":{modelName:"togethercomputer/m2-bert-80M-8k-retrieval",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.008,outputPricePerMillion:.008}}}]},"meta-llama/Llama-3.3-70B-Instruct-Turbo-Free":{modelName:"meta-llama/Llama-3.3-70B-Instruct-Turbo-Free",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"togethercomputer/MoA-1":{modelName:"togethercomputer/MoA-1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"meta-llama/Meta-Llama-3-70B-Instruct-Turbo":{modelName:"meta-llama/Meta-Llama-3-70B-Instruct-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.88,outputPricePerMillion:.88}}}]},"mistralai/Mistral-7B-Instruct-v0.2":{modelName:"mistralai/Mistral-7B-Instruct-v0.2",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.2,outputPricePerMillion:.2}}}]},"togethercomputer/m2-bert-80M-2k-retrieval":{modelName:"togethercomputer/m2-bert-80M-2k-retrieval",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.008,outputPricePerMillion:.008}}}]},"google/gemma-2b-it":{modelName:"google/gemma-2b-it",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.1}}}]},"black-forest-labs/FLUX.1-pro":{modelName:"black-forest-labs/FLUX.1-pro",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"mistralai/Mistral-Small-24B-Instruct-2501":{modelName:"mistralai/Mistral-Small-24B-Instruct-2501",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.8,outputPricePerMillion:.8}}}]},"Gryphe/MythoMax-L2-13b-Lite":{modelName:"Gryphe/MythoMax-L2-13b-Lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.1}}}]},"scb10x/scb10x-llama3-1-typhoon2-70b-instruct":{modelName:"scb10x/scb10x-llama3-1-typhoon2-70b-instruct",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.88,outputPricePerMillion:.88}}}]},"black-forest-labs/FLUX.1-redux":{modelName:"black-forest-labs/FLUX.1-redux",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"meta-llama/Meta-Llama-Guard-3-8B":{modelName:"meta-llama/Meta-Llama-Guard-3-8B",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.2,outputPricePerMillion:.2}}}]},"black-forest-labs/FLUX.1-depth":{modelName:"black-forest-labs/FLUX.1-depth",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"black-forest-labs/FLUX.1-canny":{modelName:"black-forest-labs/FLUX.1-canny",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"meta-llama/Llama-3-8b-chat-hf":{modelName:"meta-llama/Llama-3-8b-chat-hf",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.2,outputPricePerMillion:.2}}}]},"arcee-ai/caller":{modelName:"arcee-ai/caller",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.55,outputPricePerMillion:.85}}}]},"togethercomputer/MoA-1-Turbo":{modelName:"togethercomputer/MoA-1-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"mistralai/Mistral-7B-Instruct-v0.1":{modelName:"mistralai/Mistral-7B-Instruct-v0.1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.2,outputPricePerMillion:.2}}}]},"scb10x/scb10x-llama3-1-typhoon2-8b-instruct":{modelName:"scb10x/scb10x-llama3-1-typhoon2-8b-instruct",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.18000000000000002,outputPricePerMillion:.18000000000000002}}}]},"mistralai/Mixtral-8x7B-v0.1":{modelName:"mistralai/Mixtral-8x7B-v0.1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.6,outputPricePerMillion:.6}}}]},"black-forest-labs/FLUX.1-dev-lora":{modelName:"black-forest-labs/FLUX.1-dev-lora",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"deepseek-ai/DeepSeek-R1":{modelName:"deepseek-ai/DeepSeek-R1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3,outputPricePerMillion:7}}}]},"arcee-ai/arcee-blitz":{modelName:"arcee-ai/arcee-blitz",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.45,outputPricePerMillion:.75}}}]},"deepseek-ai/DeepSeek-V3-p-dp":{modelName:"deepseek-ai/DeepSeek-V3-p-dp",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:1.25}}}]},"deepseek-ai/DeepSeek-R1-Distill-Qwen-14B":{modelName:"deepseek-ai/DeepSeek-R1-Distill-Qwen-14B",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.6,outputPricePerMillion:1.6}}}]},"deepseek-ai/DeepSeek-V3":{modelName:"deepseek-ai/DeepSeek-V3",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.25,outputPricePerMillion:1.25}}}]},"Qwen/Qwen2.5-VL-72B-Instruct":{modelName:"Qwen/Qwen2.5-VL-72B-Instruct",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.95,outputPricePerMillion:8}}}]},"Qwen/Qwen2.5-Coder-32B-Instruct":{modelName:"Qwen/Qwen2.5-Coder-32B-Instruct",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.8,outputPricePerMillion:.8}}}]},"meta-llama/Llama-3.3-70B-Instruct-Turbo":{modelName:"meta-llama/Llama-3.3-70B-Instruct-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.88,outputPricePerMillion:.88}}}]},"Qwen/Qwen2-72B-Instruct":{modelName:"Qwen/Qwen2-72B-Instruct",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.9,outputPricePerMillion:.9}}}]},"microsoft/WizardLM-2-8x22B":{modelName:"microsoft/WizardLM-2-8x22B",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.2,outputPricePerMillion:1.2}}}]},"deepseek-ai/DeepSeek-R1-Distill-Llama-70B":{modelName:"deepseek-ai/DeepSeek-R1-Distill-Llama-70B",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:2,outputPricePerMillion:2}}}]},"meta-llama/Llama-3.2-11B-Vision-Instruct-Turbo":{modelName:"meta-llama/Llama-3.2-11B-Vision-Instruct-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.18000000000000002,outputPricePerMillion:.18000000000000002}}}]},"deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B":{modelName:"deepseek-ai/DeepSeek-R1-Distill-Qwen-1.5B",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.18000000000000002,outputPricePerMillion:.18000000000000002}}}]},"meta-llama/Llama-3.2-90B-Vision-Instruct-Turbo":{modelName:"meta-llama/Llama-3.2-90B-Vision-Instruct-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.2,outputPricePerMillion:1.2}}}]},"meta-llama/Meta-Llama-3-8B-Instruct-Lite":{modelName:"meta-llama/Meta-Llama-3-8B-Instruct-Lite",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.1}}}]},"black-forest-labs/FLUX.1-schnell":{modelName:"black-forest-labs/FLUX.1-schnell",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"mistralai/Mixtral-8x7B-Instruct-v0.1":{modelName:"mistralai/Mixtral-8x7B-Instruct-v0.1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.6,outputPricePerMillion:.6}}}]},"meta-llama/Llama-3-70b-chat-hf":{modelName:"meta-llama/Llama-3-70b-chat-hf",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.88,outputPricePerMillion:.88}}}]},"mistralai/Mistral-7B-Instruct-v0.3":{modelName:"mistralai/Mistral-7B-Instruct-v0.3",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.2,outputPricePerMillion:.2}}}]},"Salesforce/Llama-Rank-V1":{modelName:"Salesforce/Llama-Rank-V1",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.1,outputPricePerMillion:.1}}}]},"nvidia/Llama-3.1-Nemotron-70B-Instruct-HF":{modelName:"nvidia/Llama-3.1-Nemotron-70B-Instruct-HF",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.88,outputPricePerMillion:.88}}}]},"meta-llama/Llama-Vision-Free":{modelName:"meta-llama/Llama-Vision-Free",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"meta-llama/Llama-Guard-3-11B-Vision-Turbo":{modelName:"meta-llama/Llama-Guard-3-11B-Vision-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.18000000000000002,outputPricePerMillion:.18000000000000002}}}]},"meta-llama/Llama-3.2-3B-Instruct-Turbo":{modelName:"meta-llama/Llama-3.2-3B-Instruct-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.060000000000000005,outputPricePerMillion:.060000000000000005}}}]},"black-forest-labs/FLUX.1-dev":{modelName:"black-forest-labs/FLUX.1-dev",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:0,outputPricePerMillion:0}}}]},"Qwen/Qwen2.5-72B-Instruct-Turbo":{modelName:"Qwen/Qwen2.5-72B-Instruct-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.2,outputPricePerMillion:1.2}}}]},"arcee-ai/virtuoso-medium-v2":{modelName:"arcee-ai/virtuoso-medium-v2",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:.8}}}]},"arcee-ai/virtuoso-large":{modelName:"arcee-ai/virtuoso-large",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.75,outputPricePerMillion:1.2}}}]},"arcee-ai/maestro-reasoning":{modelName:"arcee-ai/maestro-reasoning",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.9,outputPricePerMillion:3.3}}}]},"arcee-ai/coder-large":{modelName:"arcee-ai/coder-large",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.5,outputPricePerMillion:.8}}}]},"arcee_ai/arcee-spotlight":{modelName:"arcee_ai/arcee-spotlight",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.18000000000000002,outputPricePerMillion:.18000000000000002}}}]},"Qwen/QwQ-32B":{modelName:"Qwen/QwQ-32B",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:1.2,outputPricePerMillion:1.2}}}]},"meta-llama/Llama-4-Scout-17B-16E-Instruct":{modelName:"meta-llama/Llama-4-Scout-17B-16E-Instruct",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.18000000000000002,outputPricePerMillion:.5900000000000001}}}]},"meta-llama/Llama-2-70b-hf":{modelName:"meta-llama/Llama-2-70b-hf",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.9,outputPricePerMillion:.9}}}]},"meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo":{modelName:"meta-llama/Meta-Llama-3.1-405B-Instruct-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:3.5,outputPricePerMillion:3.5}}}]},"meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo":{modelName:"meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.88,outputPricePerMillion:.88}}}]},"meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo":{modelName:"meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo",currency:"USD",tokenRanges:[{minTokens:0,maxTokens:null,prices:{base:{inputPricePerMillion:.18000000000000002,outputPricePerMillion:.18000000000000002}}}]}};var we=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string()}),Q=class{constructor(t,n){this.version="v1";let a=we.parse(n);this.modelSchema=t,this.modelName=a.modelName,this.apiKey=a.apiKey,this.baseUrl=N(L.baseUrl),this.streamChatUrl=N(`${this.baseUrl}/chat/completions`),this.completeChatUrl=N(`${this.baseUrl}/chat/completions`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"}}getDefaultParams(){return {model:this.modelName}}getRetryDelay(t){return {shouldRetry:!0,delayMs:0}}getTokenCount(t){return t.reduce((n,a)=>n+a.content.map(r=>r.modality==="text"?r.value:"").join(" ").length,0)}transformModelRequest(t){let n=Wt.safeParse(t);if(!n.success)throw new O({info:"Invalid model request",cause:n.error});let a=n.data,r=a.model;if(a.tool_choice&&(!a.tools||a.tools.length===0))throw new O({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'tool_choice' is specified")});let i={};a.response_format&&(i.responseFormat=a.response_format.type,a.response_format.type==="json_schema"&&(i.responseSchema={name:a.response_format.json_schema.name,description:a.response_format.json_schema.description||"",strict:a.response_format.json_schema.strict,schema:a.response_format.json_schema.schema})),a.tool_choice&&(typeof a.tool_choice=="string"?i.toolChoice=a.tool_choice:i.toolChoice=a.tool_choice.function.name),i.seed=a.seed,i.maxTokens=a.max_tokens,i.temperature=a.temperature,i.topP=a.top_p,i.minP=a.min_p,i.topK=a.top_k,i.repetitionPenalty=a.repetition_penalty,i.presencePenalty=a.presence_penalty,i.frequencyPenalty=a.frequency_penalty,i.repetitionPenalty=a.repetition_penalty,i.stop=a.stop,i.logProbs=a.logprobs!==0,i.echo=a.echo;let l=V().parse(H(i)),m=[],u={};a.messages.forEach(d=>{let y=d.role;switch(y){case"system":m.push({role:y,content:[{modality:M,value:d.content}]});break;case"user":m.push({role:y,content:[{modality:M,value:d.content}]});break;case"assistant":{let f=[];if(!d.content&&!d.tool_calls)throw new O({info:`Invalid model request for model : '${this.modelName}'`,cause:new Error("one of'content' or 'tool_calls' must be provided")});d.content&&f.push({modality:M,value:d.content}),d.tool_calls&&d.tool_calls.forEach((I,k)=>{let U={modality:x,id:I.id,index:k,name:I.function.name,arguments:I.function.arguments};f.push(U),u[U.id]=U;}),m.push({role:y,content:f});}break;case"tool":{let f=d;m.push({role:y,content:[{modality:w,id:f.tool_call_id,index:u[f.tool_call_id].index,name:u[f.tool_call_id].name,data:f.content}]});}break}});let g=[];return a.tools&&a.tools.forEach(d=>{g.push({type:"function",definition:{schema:{name:d.function.name,description:d.function.description||"",strict:d.function.strict,parameters:d.function.parameters}}});}),{modelName:r,config:l,messages:m,tools:g.length>0?g:void 0}}transformConfig(t,n,a){let r=t.toolChoice;delete t.toolChoice;let i=this.modelSchema.config.schema.safeParse(t);if(!i.success)throw new S({info:`Invalid config for model : '${this.modelName}'`,cause:i.error});let l=i.data;r!==void 0&&(l.toolChoice=r),Object.keys(l).forEach(u=>{if(!(u in this.modelSchema.config.def))throw new S({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${u}',
7
+ available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})});let m=Object.keys(l).reduce((u,g)=>{let d=this.modelSchema.config.def[g],y=d.param,f=l[g];return y==="max_tokens"&&d.type==="range"&&f===0?u[y]=d.max:y==="logprobs"&&d.type==="select-boolean"?f===!0?u[y]=1:u[y]=0:u[y]=f,u},{});if(m.top_logprobs&&!m.logprobs)throw new S({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'logprobs' must be 'true' when 'top_logprobs' is specified")});if("tool_choice"in m&&m.tool_choice!==void 0){let u=m.tool_choice;if(!a||a&&a.length===0)throw new S({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(a&&a.length>0){let g=this.modelSchema.config.def.toolChoice;if(!g.choices.includes(u))if(a.map(d=>d.definition.schema.name).includes(u))m.tool_choice={type:"function",function:{name:u}};else throw new S({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`toolChoice : '${u}' is not part of provided 'tools' names or
8
+ one of [${g.choices.join(", ")}]`)})}}if("response_format"in m&&m.response_format!==void 0){let u=m.response_format;if(u==="json_schema")if("response_schema"in m)m.response_format={type:"json_schema",json_schema:m.response_schema},delete m.response_schema;else throw new S({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'responseSchema' is required in config when 'responseFormat' is 'json_schema'")});else m.response_format={type:u};}return m}transformMessages(t){if(!t||t&&t.length===0)return {messages:[]};let n=t.map(r=>{let i=ee().safeParse(r);if(!i.success)throw new R({info:"Invalid messages",cause:i.error});return i.data});return n.forEach(r=>{r.content.forEach(i=>{if(!this.modelSchema.modalities.includes(i.modality))throw new R({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support modality : '${i.modality}',
9
+ available modalities : [${this.modelSchema.modalities.join(", ")}]`)})});}),n.forEach(r=>{if(!Object.keys(this.modelSchema.roles).includes(r.role))throw new R({info:`Invalid message content for model : '${this.modelName}'`,cause:new Error(`model : '${this.modelName}' does not support role : '${r.role}',
10
+ available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}),{messages:n.map(r=>{switch(r.role){case q:{let i="";return r.content.forEach(l=>{if(l.modality===M)i+=l.value+`
11
+ `;else throw new R({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' cannot have content with modality : '${l.modality}'`)})}),{role:this.modelSchema.roles[r.role],content:i}}case v:{let i="",l=[];return r.content.forEach(m=>{if(m.modality===M)i+=m.value+`
12
+ `;else if(m.modality===x)l.push({id:m.id,type:"function",function:{name:m.name,arguments:m.arguments}});else throw new R({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' cannot have content with modality : '${m.modality}'`)})}),T({role:this.modelSchema.roles[r.role],content:i},l.length>0?{tool_calls:l}:{})}case D:{let i="";return r.content.forEach(l=>{if(l.modality===M)i+=l.value+`
13
+ `;else throw new R({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' cannot have content with modality : '${l.modality}'`)})}),{role:this.modelSchema.roles[r.role],content:i}}case B:{if(r.content.length!==1)throw new R({info:`Invalid message for role : '${r.role}'`,cause:new Error(`role : '${r.role}' must have exactly one content item`)});if(r.content[0].modality!==w)throw new R({info:`Invalid message 'role' and 'modality' combination for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' must have content with modality : '${w}'`)});let i=r.content[0];return {role:this.modelSchema.roles[r.role],tool_call_id:i.id,content:i.data}}default:throw new R({info:`Invalid message 'role' for model : ${this.modelName}`,cause:new Error(`role : '${r.role}' is not supported,
14
+ available roles : [${Object.keys(this.modelSchema.roles).join(", ")}]`)})}})}}transformTools(t){if(!this.modelSchema.modalities.includes(x))throw new ae({info:`Invalid tool 'modality' for model : ${this.modelName}`,cause:new Error(`model : '${this.modelName}' does not support tool modality : '${x}'`)});return !t||t&&t.length===0?{tools:[]}:{tools:t.map(r=>{let i=pt().safeParse(r);if(!i.success)throw new ae({info:"Invalid tools",cause:i.error});return i.data}).map(r=>({type:"function",function:r.definition.schema}))}}getCompleteChatUrl(t,n,a){return P(this,null,function*(){return new Promise(r=>{r(this.completeChatUrl);})})}getCompleteChatHeaders(t,n,a){return P(this,null,function*(){return new Promise(r=>{r(this.getDefaultHeaders());})})}getCompleteChatData(t,n,a){return P(this,null,function*(){let r=this.transformConfig(t,n,a),i=this.transformMessages(n);if(i.messages&&i.messages.length===0)throw new R({info:"Messages are required",cause:new Error("Messages are required")});let l=a?this.transformTools(a):{};return new Promise(m=>{m(T(T(T(T({},this.getDefaultParams()),r),i),l));})})}transformCompleteChatResponse(t){let n=Kt.safeParse(t);if(n.success){if(n.data.choices.length===0)throw new _({info:"Invalid response from model",cause:new Error(`No choices in response : ${JSON.stringify(n.data)}`)});let a=n.data,r=[{role:v,content:[]}],i=a.choices[0].message;i.content&&r[0].content.push(ut(i.content)),i.tool_calls&&i.tool_calls.forEach((g,d)=>{r[0].content.push(dt(d,g.id,g.function.name,g.function.arguments));});let l;a.usage&&(l={promptTokens:a.usage.prompt_tokens,completionTokens:a.usage.completion_tokens,totalTokens:a.usage.total_tokens});let m=[],u=a.choices[0].logprobs;return u&&u.tokens.forEach((g,d)=>{m.push({token:g,logProb:u.token_logprobs[d],bytes:null,topLogProbs:[]});}),{messages:r,usage:l,logProbs:m}}throw new _({info:"Invalid response from model",cause:n.error})}getStreamChatUrl(t,n,a){return P(this,null,function*(){return new Promise(r=>{r(this.streamChatUrl);})})}getStreamChatHeaders(t,n,a){return P(this,null,function*(){return new Promise(r=>{r(this.getDefaultHeaders());})})}getStreamChatData(t,n,a){return P(this,null,function*(){let r=this.transformConfig(t,n,a),i=this.transformMessages(n);if(i.messages&&i.messages.length===0)throw new R({info:"Messages are required",cause:new Error("Messages are required")});let l=a?this.transformTools(a):{};return new Promise(m=>{m(T(T(T(T({stream:!0,stream_options:{include_usage:!0}},this.getDefaultParams()),r),i),l));})})}transformStreamChatResponseChunk(t,n){return K(this,null,function*(){var m,u;let a=n+t,r=[],i="",l=0;for(;l<a.length;){let g=a.indexOf(`
15
+ `,l);if(g===-1){i=a.substring(l);break}else {let d=a.substring(l,g).trim();d&&r.push(d),l=g+1;}}for(let g of r){if(g==="data: [DONE]")return;if(g.startsWith("data: ")){let d=g.substring(6);try{let y=JSON.parse(d),f=Xt.safeParse(y);if(f.success){let b={partialMessages:[]},I=f.data;if(I.choices.length>0){let k=I.choices[0].delta;if(k!==void 0&&Object.keys(k).length!==0){if("content"in k&&k.content!==null)b.partialMessages.push(oe(v,k.content));else if("refusal"in k&&k.refusal!==null)b.partialMessages.push(oe(v,k.refusal));else if("tool_calls"in k&&Array.isArray(k.tool_calls)&&k.tool_calls.length>0){let U=k.tool_calls[0];b.partialMessages.push(gt(v,U.index,U.id,(m=U.function)==null?void 0:m.name,(u=U.function)==null?void 0:u.arguments));}}}I.usage&&(b.usage={promptTokens:I.usage.prompt_tokens,completionTokens:I.usage.completion_tokens,totalTokens:I.usage.total_tokens}),yield {partialResponse:b,buffer:i};}else throw new _({info:"Invalid response from model",cause:f.error})}catch(y){throw new _({info:`Malformed JSON received in stream: ${d}`,cause:y})}}}yield {partialResponse:{partialMessages:[]},buffer:i};})}transformProxyStreamChatResponseChunk(t,n,a,r,i){return K(this,null,function*(){yield*De(this.transformStreamChatResponseChunk(t,n));})}getProxyStreamChatUrl(t,n,a){return P(this,null,function*(){return new Promise(r=>{r(this.streamChatUrl);})})}getProxyCompleteChatUrl(t,n,a){return P(this,null,function*(){return new Promise(r=>{r(this.completeChatUrl);})})}getProxyCompleteChatHeaders(t,n,a){return P(this,null,function*(){if(!n)return {};let r=T({},n);return delete r.host,delete r["content-length"],r})}getProxyStreamChatHeaders(t,n,a){return P(this,null,function*(){return yield this.getProxyCompleteChatHeaders(t,n,a)})}getModelPricing(){if(!(this.modelName in Ue))throw new _({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return Ue[this.modelName]}};var Jt=[j],Yt=zod.z.enum([j]);var Zt=zod.z.object({object:zod.z.literal("list"),model:zod.z.string(),data:zod.z.array(zod.z.object({index:zod.z.number(),object:zod.z.literal("embedding"),embedding:zod.z.array(zod.z.number()).or(zod.z.string().base64())})),usage:zod.z.object({prompt_tokens:zod.z.number().nonnegative(),total_tokens:zod.z.number().nonnegative()}).optional()});var ha=zod.z.string().min(1).or(zod.z.array(zod.z.string().min(1)).min(1)),en=zod.z.object({model:zod.z.string().min(1).optional(),input:ha});var je=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string()}),G=class{constructor(t,n){this.version="v1";let a=je.parse(n);this.modelSchema=t,this.modelName=a.modelName,this.apiKey=a.apiKey,this.baseUrl=N(L.baseUrl),this.getEmbeddingsUrl=N(`${this.baseUrl}/embeddings`);}getDefaultBaseUrl(){return this.baseUrl}getDefaultHeaders(){return {Authorization:`Bearer ${this.apiKey}`,"Content-Type":"application/json"}}getDefaultParams(){return {model:this.modelName}}getRetryDelay(t){return {shouldRetry:!0,delayMs:0}}getTokenCount(t){return t.requests.reduce((n,a)=>n+a.length,0)}transformModelRequest(t){let n=en.safeParse(t);if(!n.success)throw new O({info:"Invalid model request",cause:n.error});let a=n.data,r=a.model,i={},l=V().parse(H(i)),m={modality:j,requests:[...a.input]};return {modelName:r,config:l,embeddingRequests:m}}transformConfig(t,n){let a=this.modelSchema.config.schema.safeParse(t);if(!a.success)throw new S({info:`Invalid config for model : '${this.modelName}'`,cause:a.error});let r=a.data;return Object.keys(r).forEach(l=>{if(!this.modelSchema.config.def[l])throw new S({info:`Invalid config for model : '${this.modelName}'`,cause:new Error(`Invalid config key : '${l}',
16
+ available keys : [${Object.keys(this.modelSchema.config.def).join(", ")}]`)})}),Object.keys(r).reduce((l,m)=>{let g=this.modelSchema.config.def[m].param,d=r[m];return l[g]=d,l},{})}transformEmbeddingRequests(t){let n=mt().safeParse(t);if(!n.success)throw new re({info:"Invalid embedding requests",cause:n.error});if(t.modality!==j)throw new re({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Only '${j}' modality is supported for model : '${this.modelName}'`)});return {input:n.data.requests}}getGetEmbeddingsUrl(t,n){return P(this,null,function*(){return new Promise(a=>{a(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(t,n){return P(this,null,function*(){return new Promise(a=>{a(this.getDefaultHeaders());})})}getGetEmbeddingsData(t,n){return P(this,null,function*(){return new Promise(a=>{a(T(T(T({},this.getDefaultParams()),this.transformConfig(t,n)),this.transformEmbeddingRequests(n)));})})}transformGetEmbeddingsResponse(t){var a;let n=Zt.safeParse(t);if(n.success){let r=n.data,i=r.data.map(l=>({index:l.index,embedding:l.embedding}));return {encodingFormat:ne,embeddings:i,usage:{totalTokens:(a=r.usage)==null?void 0:a.total_tokens}}}throw new _({info:"Invalid response from model",cause:n.error})}};var Ee=Ft(Yt).parse({name:"__base__",description:"Base embedding model for Together AI",maxInputTokens:128e3,maxOutputTokens:128e3,modalities:Jt,config:{def:{},schema:zod.z.object({})}});
17
17
 
18
18
  exports.BaseChatModel = Q;
19
19
  exports.BaseChatModelOptions = we;
20
20
  exports.BaseChatModelSchema = Se;
21
21
  exports.BaseEmbeddingModel = G;
22
- exports.BaseEmbeddingModelOptions = Ue;
22
+ exports.BaseEmbeddingModelOptions = je;
23
23
  exports.BaseEmbeddingModelSchema = Ee;
24
- exports.ChatModelBaseConfigDef = qt;
25
- exports.ChatModelBaseConfigSchema = Lt;
24
+ exports.ChatModelBaseConfigDef = zt;
25
+ exports.ChatModelBaseConfigSchema = $t;
26
26
  exports.TogetherAI = L;
27
- exports.TogetherAIChatModelConfigs = Ie;
28
- exports.TogetherAIEmbeddingModelModalities = Ht;
29
- exports.TogetherAIEmbeddingModelModalitiesEnum = Qt;
30
- exports.TogetherAIEmbeddingRequest = Kt;
31
- exports.TogetherAIEmbeddingRequestInput = ta;
32
- exports.TogetherAIGetEmbeddingsResponse = Gt;
33
- exports.frequencyPenalty = Te;
27
+ exports.TogetherAIChatModelConfigs = xe;
28
+ exports.TogetherAIEmbeddingModelModalities = Jt;
29
+ exports.TogetherAIEmbeddingModelModalitiesEnum = Yt;
30
+ exports.TogetherAIEmbeddingRequest = en;
31
+ exports.TogetherAIEmbeddingRequestInput = ha;
32
+ exports.TogetherAIGetEmbeddingsResponse = Zt;
33
+ exports.frequencyPenalty = be;
34
34
  exports.logProbs = Me;
35
35
  exports.maxTokens = de;
36
- exports.minP = ye;
37
- exports.presencePenalty = be;
36
+ exports.minP = fe;
37
+ exports.presencePenalty = Te;
38
38
  exports.repetitionPenalty = Pe;
39
39
  exports.responseFormat = Re;
40
- exports.responseSchema = xe;
40
+ exports.responseSchema = ve;
41
41
  exports.seed = ke;
42
42
  exports.stop = ge;
43
43
  exports.temperature = ue;
44
44
  exports.toolChoice = Ce;
45
45
  exports.topK = he;
46
- exports.topP = fe;
46
+ exports.topP = ye;
47
47
  //# sourceMappingURL=index.js.map
48
48
  //# sourceMappingURL=index.js.map