@adaline/together-ai 1.2.2 → 1.2.3

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,8 +2,8 @@
2
2
 
3
3
  var zod = require('zod');
4
4
 
5
- var Qt=Object.defineProperty;var je=Object.getOwnPropertySymbols;var Gt=Object.prototype.hasOwnProperty,Kt=Object.prototype.propertyIsEnumerable;var z=(a,t)=>(t=Symbol[a])?t:Symbol.for("Symbol."+a),Xt=a=>{throw TypeError(a)};var Le=(a,t,n)=>t in a?Qt(a,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):a[t]=n,b=(a,t)=>{for(var n in t||(t={}))Gt.call(t,n)&&Le(a,n,t[n]);if(je)for(var n of je(t))Kt.call(t,n)&&Le(a,n,t[n]);return a};var P=(a,t,n)=>new Promise((o,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?o(u.value):Promise.resolve(u.value).then(s,l);m((n=n.apply(a,t)).next());}),qe=function(a,t){this[0]=a,this[1]=t;},K=(a,t,n)=>{var o=(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(T=>y?o(l==="return"?l:"next",m[1]?{done:T.done,value:T.value}:T,u,g):u({value:T,done:f})).catch(T=>o("throw",T,u,g));}catch(T){g(T);}},i=l=>s[l]=m=>new Promise((u,g)=>o(l,m,u,g)),s={};return n=n.apply(a,t),s[z("asyncIterator")]=()=>s,i("next"),i("throw"),i("return"),s},De=a=>{var t=a[z("asyncIterator")],n=!1,o,i={};return t==null?(t=a[z("iterator")](),o=s=>i[s]=l=>t[s](l)):(t=t.call(a),o=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||Xt("Object expected"),m(u);}),1)}}),i[z("iterator")]=()=>i,o("next"),"throw"in t?o("throw"):i.throw=s=>{throw s},"return"in t&&o("return"),i};var q="system",D="user",I="assistant",B="tool",Wt=[q,D,I,B],Y=zod.z.enum(Wt),Yt=[I],Jt=zod.z.enum(Yt),Fe="image",Zt="base64",en=["png","jpeg","webp","gif"],tn=zod.z.object({type:zod.z.literal(Zt),base64:zod.z.string(),mediaType:zod.z.enum(en)}),nn="url",on=zod.z.object({type:zod.z.literal(nn),url:zod.z.string()}),an=zod.z.discriminatedUnion("type",[tn,on]),sn=["low","medium","high","auto"],rn=zod.z.enum(sn),ln=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(Fe),detail:rn,value:an,metadata:a}),ze="reasoning",He="partial-reasoning",Ve="thinking",mn="redacted",W=zod.z.object({type:zod.z.literal(Ve),thinking:zod.z.string(),signature:zod.z.string()}),Qe=zod.z.object({type:zod.z.literal(mn),data:zod.z.string()}),cn=zod.z.discriminatedUnion("type",[W,Qe]),pn=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(ze),value:cn,metadata:a}),un=zod.z.object({type:zod.z.literal(Ve),thinking:W.shape.thinking.optional(),signature:W.shape.signature.optional()}),dn=zod.z.discriminatedUnion("type",[un,Qe]),gn=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(He),value:dn,metadata:a}),M="text",Ge=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(M),value:zod.z.string(),metadata:a}),J="partial-text",Ke=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(J),value:zod.z.string(),metadata:a}),x="tool-call",Xe=(a=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(),metadata:a}),Z="partial-tool-call",We=(a=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(),metadata:a}),w="tool-response",hn=(a=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:a}),yn=[M,Fe,x,w,ze],Ye=zod.z.enum(yn),fn=(a=zod.z.undefined(),t=zod.z.undefined(),n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[Ge(a),ln(t),Xe(n),hn(o),pn(i)]),Tn=[J,Z,He];zod.z.enum(Tn);var bn=(a=zod.z.undefined(),t=zod.z.undefined(),n=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[Ke(a),We(t),gn(n)]);var ee=(a=Y,t=zod.z.undefined(),n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),s=zod.z.undefined(),l=zod.z.undefined())=>zod.z.object({role:a,content:zod.z.array(fn(t,n,o,i,l)),metadata:s}),te=(a=Jt,t=zod.z.undefined(),n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined())=>zod.z.object({role:a,partialContent:bn(t,n,o),metadata:i}),Pn=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()}),kn=Be.extend({topLogProbs:zod.z.array(Be)}),Je=zod.z.array(kn);zod.z.object({messages:zod.z.array(ee()),usage:Pn.optional(),logProbs:Je.optional()});var Mn=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:Mn.optional(),logProbs:Je.optional()});var H=(a=zod.z.record(zod.z.string(),zod.z.any()).optional())=>a,Cn=["object","array","number","string","boolean","enum"],Oe=zod.z.enum(Cn),Rn=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()}),In=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(Rn),additionalProperties:zod.z.literal(!1)}),Ze=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:In}).optional(),_="text",et="token",xn=[_,et],tt=zod.z.enum(xn),vn=zod.z.array(zod.z.string().min(1)),Sn=zod.z.array(zod.z.array(zod.z.number().int().nonnegative())),nt=(a=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[zod.z.object({modality:zod.z.literal(_),metadata:a,requests:vn}),zod.z.object({modality:zod.z.literal(et),metadata:a,requests:Sn})]),ne="float",En=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),wn="base64",_n=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.string().base64()}),$e=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(En),usage:$e.optional()}),zod.z.object({encodingFormat:zod.z.literal(wn),embeddings:zod.z.array(_n),usage:$e.optional()})]);var An=a=>{let t=new WeakSet;return JSON.stringify(a,(n,o)=>{if(typeof o=="object"&&o!==null){if(t.has(o))return;t.add(o);}return o})},Un=a=>a==null?"unknown error":typeof a=="string"?a:a instanceof Error?a.message:An(a),X="GatewayBaseError",N=class ot extends Error{constructor({info:t,cause:n},o){super(`[${o!=null?o:X}]: ${t}
6
- Message: ${Un(n)}`),this.name=X,this.info=t,this.cause=n,this.name=o!=null?o:X,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(t){return t instanceof ot}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},Nn=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."),jn=zod.z.object({base:Nn.describe("Base (uncached, non\u2011reasoning) rates")}).describe("Holds the `ChatModelTokenPairPrice` for different categories (e.g., base) within a single pricing tier."),Ln=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:jn.describe("Price categories and rates for this specific token range.")}).refine(a=>a.maxTokens===null||typeof a.maxTokens=="number"&&a.maxTokens>a.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(Ln).min(1).describe("Pricing tiers (`ChatModelTokenRangePrice`) schedule, sorted by minTokens.")}).superRefine((a,t)=>{let{tokenRanges:n}=a;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 o=n[n.length-1];n.every(i=>i.maxTokens!==null||i===o)&&o.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 qn="function";var Dn=zod.z.enum(["object","array","number","string","boolean","null"]),Bn=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:Dn.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(Bn).optional(),required:zod.z.array(zod.z.string()).optional()});var On=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 $n=zod.z.enum(["function"]),Fn=zod.z.object({maxAttempts:zod.z.number().int().positive(),initialDelay:zod.z.number().int().positive(),exponentialFactor:zod.z.number().int().positive()}),zn=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:Fn.optional()}),Hn=zod.z.discriminatedUnion("type",[zn]),Vn=zod.z.object({type:$n,definition:zod.z.object({schema:On}),apiSettings:Hn.optional()}),Qn=[qn];zod.z.enum(Qn);var at=(a=zod.z.undefined())=>zod.z.discriminatedUnion("type",[Vn.extend({metadata:a})]),it=a=>Ge().parse({modality:M,value:a}),st=(a,t,n,o)=>Xe().parse({modality:x,index:a,id:t,name:n,arguments:o});var oe=(a,t)=>te().parse({role:a,partialContent:Ke().parse({modality:J,value:t})}),rt=(a,t,n,o,i)=>te().parse({role:a,partialContent:We().parse({modality:Z,index:t,id:n,name:o,arguments:i})});var Gn=Object.defineProperty,lt=Object.getOwnPropertySymbols,Kn=Object.prototype.hasOwnProperty,Xn=Object.prototype.propertyIsEnumerable,mt=(a,t,n)=>t in a?Gn(a,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):a[t]=n,$=(a,t)=>{for(var n in t||(t={}))Kn.call(t,n)&&mt(a,n,t[n]);if(lt)for(var n of lt(t))Xn.call(t,n)&&mt(a,n,t[n]);return a};var ct="ModelResponseError",U=class yt extends N{constructor({info:t,cause:n}){super({info:t,cause:n},ct),this.name=ct,this.cause=n,this.info=t;}static isModelResponseError(t){return t instanceof yt}},pt="InvalidModelRequestError",O=class ft extends N{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 isInvalidModelRequestError(t){return t instanceof ft}},ut="InvalidConfigError",S=class Tt 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 isInvalidConfigError(t){return t instanceof Tt}},dt="InvalidMessagesError",R=class bt 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 isInvalidMessagesError(t){return t instanceof bt}},gt="InvalidToolsError",ae=class Pt 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 isInvalidToolsError(t){return t instanceof Pt}},ht="InvalidEmbeddingRequestsError",ie=class kt extends N{constructor({info:t,cause:n}){super({info:t,cause:n},ht),this.name=ht,this.info=t,this.cause=n,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(t){return t instanceof kt}},se="multi-string",Mt=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()}),Wn=a=>zod.z.array(zod.z.string()).max(a).default([]).optional(),Ct=a=>({def:Mt.parse($({type:se},a)),schema:Wn(a.max)}),re="object-schema",Rt=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()}),Yn=a=>a.optional(),It=a=>({def:Rt.parse($({type:re},a)),schema:Yn(a.objectSchema)}),le="range",xt=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()}),Jn=(a,t,n,o)=>zod.z.number().min(a).max(t).step(n).default(o).optional(),E=a=>({def:xt.parse($({type:le},a)),schema:Jn(a.min,a.max,a.step,a.default)}),me="select-boolean",vt=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()}),Zn=a=>zod.z.boolean().nullable().default(a).optional(),St=a=>({def:vt.parse($({type:me},a)),schema:Zn(a.default)}),ce="select-string",Et=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=(a,t)=>zod.z.enum(t).nullable().default(a).optional(),pe=a=>({def:Et.parse($({type:ce},a)),schema:eo(a.default,a.choices)}),to=[le,se,ce,re,me];zod.z.enum(to);var wt=zod.z.discriminatedUnion("type",[xt,Mt,Et,vt,Rt]),_t=(a=Y,t=Ye)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(a,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),wt),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(n=>{var o,i;let s=Object.keys(n.def),l=Object.keys((i=(o=n.schema)==null?void 0:o.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()}),At=(a=tt)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),modalities:zod.z.array(a).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),wt),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(t=>{var n,o;let i=Object.keys(t.def),s=Object.keys((o=(n=t.schema)==null?void 0:n.shape)!=null?o:{});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 no={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."},oo={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."},ao={type:"range",title:"Max reasoning tokens",description:"Specify the total tokens for reasoning, where one token approximates four English characters."},io=a=>({type:"multi",title:"Stop sequence",description:`Enter up to ${a} sequences that will halt additional text output. The generated text will exclude these sequences.`}),so={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."},ro={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."},lo={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."},mo={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."},co={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."},po={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."},uo={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."},go={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."},ho={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."},yo={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."},fo={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},To={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."},bo={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."},Po={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."},h={TEMPERATURE:no,MAX_TOKENS:oo,STOP:io,TOP_A:so,TOP_P:ro,TOP_K:lo,MIN_P:mo,FREQUENCY_PENALTY:co,PRESENCE_PENALTY:po,REPETITION_PENALTY:go,SEED:uo,LOG_PROBS:ho,TOP_LOG_PROBS:yo,ECHO:fo,RESPONSE_FORMAT:To,RESPONSE_FORMAT_WITH_SCHEMA:bo,RESPONSE_SCHEMA:Po,MAX_REASONING_TOKENS:ao};var V=a=>Object.fromEntries(Object.entries(a).filter(([t,n])=>n!=null));var j=a=>a==null?void 0:a.replace(/\/$/,"");var ue=E({param:"temperature",title:h.TEMPERATURE.title,description:h.TEMPERATURE.description,min:0,max:1,step:.01,default:1}),de=a=>E({param:"max_tokens",title:h.MAX_TOKENS.title,description:h.MAX_TOKENS.description,min:0,max:a,step:1,default:0}),ge=a=>Ct({param:"stop",title:h.STOP(a).title,description:h.STOP(a).description,max:a}),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}),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=St({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"]}),Ie=It({param:"response_schema",title:h.RESPONSE_SCHEMA.title,description:h.RESPONSE_SCHEMA.description,objectSchema:Ze});var Ut=(a,t)=>zod.z.object({temperature:ue.schema,maxTokens:de(a).schema,stop:ge(t).schema,topP:ye.schema,topK:he.schema,minP:fe.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:Ie.schema,responseFormat:Re.schema}),Nt=(a,t)=>({temperature:ue.def,maxTokens:de(a).def,stop:ge(t).def,topP:ye.def,topK:he.def,minP:fe.def,frequencyPenalty:Te.def,presencePenalty:be.def,repetitionPenalty:Pe.def,seed:ke.def,logProbs:Me.def,toolChoice:Ce.def,responseSchema:Ie.def,responseFormat:Re.def});var xe={base:(a,t)=>({def:Nt(a,t),schema:Ut(a,t)})};var jt=zod.z.enum([q,D,I,B]),Lt={system:q,user:D,assistant:I,tool:B};var qt=[M,x,w],Dt=zod.z.enum([M,x,w]);var Ro=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())}),Io=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()})})),Bt=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:Io.optional()}),logprobs:Ro.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()}),xo=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()})),Ot=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:xo.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 vo=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()})}),So=zod.z.enum(["none","auto","required"]),Eo=zod.z.object({type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1)})}),wo=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(),_o=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)})}),Ao=zod.z.object({role:zod.z.literal("system"),content:ve}),Uo=zod.z.object({role:zod.z.literal("user"),content:ve}),No=zod.z.object({role:zod.z.literal("assistant"),content:ve.optional(),tool_calls:zod.z.array(_o).min(1).optional()}),jo=zod.z.object({role:zod.z.literal("tool"),tool_call_id:zod.z.string().min(1),content:zod.z.string().min(1)}),Lo=zod.z.union([Ao,Uo,No,jo]),$t=zod.z.object({model:zod.z.string().min(1).optional(),messages:zod.z.array(Lo).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:wo.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(vo).optional(),tool_choice:So.or(Eo).optional()});var Se=_t(jt,Dt).parse({name:"__base__",description:"Base chat model for Together AI",maxInputTokens:128e3,maxOutputTokens:128e3,roles:Lt,modalities:qt,config:{def:xe.base(128e3,4).def,schema:xe.base(128e3,4).schema}});var qo="together-ai",L=class{constructor(){this.version="v1";this.name=qo;}chatModelLiterals(){return ["__base__"]}chatModelSchemas(){return {__base__:Se}}chatModel(t){let n=Q,o=we.parse(t);return new n(Se,o)}embeddingModelLiterals(){return ["__base__"]}embeddingModelSchemas(){return {__base__:Ee}}embeddingModel(t){let n=G,o=_e.parse(t);return new n(Ee,o)}};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 o=we.parse(n);this.modelSchema=t,this.modelName=o.modelName,this.apiKey=o.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,o)=>n+o.content.map(i=>i.modality==="text"?i.value:"").join(" ").length,0)}transformModelRequest(t){let n=$t.safeParse(t);if(!n.success)throw new O({info:"Invalid model request",cause:n.error});let o=n.data,i=o.model;if(o.tool_choice&&(!o.tools||o.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={};o.response_format&&(s.responseFormat=o.response_format.type,o.response_format.type==="json_schema"&&(s.responseSchema={name:o.response_format.json_schema.name,description:o.response_format.json_schema.description||"",strict:o.response_format.json_schema.strict,schema:o.response_format.json_schema.schema})),o.tool_choice&&(typeof o.tool_choice=="string"?s.toolChoice=o.tool_choice:s.toolChoice=o.tool_choice.function.name),s.seed=o.seed,s.maxTokens=o.max_tokens,s.temperature=o.temperature,s.topP=o.top_p,s.minP=o.min_p,s.topK=o.top_k,s.repetitionPenalty=o.repetition_penalty,s.presencePenalty=o.presence_penalty,s.frequencyPenalty=o.frequency_penalty,s.repetitionPenalty=o.repetition_penalty,s.stop=o.stop,s.logProbs=o.logprobs!==0,s.echo=o.echo;let l=H().parse(V(s)),m=[],u={};o.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((v,k)=>{let A={modality:x,id:v.id,index:k,name:v.function.name,arguments:v.function.arguments};f.push(A),u[A.id]=A;}),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 o.tools&&o.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,o){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}',
5
+ var Qt=Object.defineProperty;var je=Object.getOwnPropertySymbols;var Gt=Object.prototype.hasOwnProperty,Kt=Object.prototype.propertyIsEnumerable;var z=(a,t)=>(t=Symbol[a])?t:Symbol.for("Symbol."+a),Xt=a=>{throw TypeError(a)};var Le=(a,t,n)=>t in a?Qt(a,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):a[t]=n,b=(a,t)=>{for(var n in t||(t={}))Gt.call(t,n)&&Le(a,n,t[n]);if(je)for(var n of je(t))Kt.call(t,n)&&Le(a,n,t[n]);return a};var P=(a,t,n)=>new Promise((o,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?o(u.value):Promise.resolve(u.value).then(s,l);m((n=n.apply(a,t)).next());}),qe=function(a,t){this[0]=a,this[1]=t;},K=(a,t,n)=>{var o=(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(T=>y?o(l==="return"?l:"next",m[1]?{done:T.done,value:T.value}:T,u,g):u({value:T,done:f})).catch(T=>o("throw",T,u,g));}catch(T){g(T);}},i=l=>s[l]=m=>new Promise((u,g)=>o(l,m,u,g)),s={};return n=n.apply(a,t),s[z("asyncIterator")]=()=>s,i("next"),i("throw"),i("return"),s},De=a=>{var t=a[z("asyncIterator")],n=!1,o,i={};return t==null?(t=a[z("iterator")](),o=s=>i[s]=l=>t[s](l)):(t=t.call(a),o=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||Xt("Object expected"),m(u);}),1)}}),i[z("iterator")]=()=>i,o("next"),"throw"in t?o("throw"):i.throw=s=>{throw s},"return"in t&&o("return"),i};var q="system",D="user",I="assistant",B="tool",Wt=[q,D,I,B],Y=zod.z.enum(Wt),Yt=[I],Jt=zod.z.enum(Yt),$e="image",Zt="base64",en=["png","jpeg","webp","gif"],tn=zod.z.object({type:zod.z.literal(Zt),base64:zod.z.string(),mediaType:zod.z.enum(en)}),nn="url",on=zod.z.object({type:zod.z.literal(nn),url:zod.z.string()}),an=zod.z.discriminatedUnion("type",[tn,on]),sn=["low","medium","high","auto"],rn=zod.z.enum(sn),ln=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal($e),detail:rn,value:an,metadata:a}),ze="reasoning",He="partial-reasoning",Ve="thinking",mn="redacted",W=zod.z.object({type:zod.z.literal(Ve),thinking:zod.z.string(),signature:zod.z.string()}),Qe=zod.z.object({type:zod.z.literal(mn),data:zod.z.string()}),cn=zod.z.discriminatedUnion("type",[W,Qe]),pn=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(ze),value:cn,metadata:a}),un=zod.z.object({type:zod.z.literal(Ve),thinking:W.shape.thinking.optional(),signature:W.shape.signature.optional()}),dn=zod.z.discriminatedUnion("type",[un,Qe]),gn=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(He),value:dn,metadata:a}),M="text",Ge=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(M),value:zod.z.string(),metadata:a}),J="partial-text",Ke=(a=zod.z.undefined())=>zod.z.object({modality:zod.z.literal(J),value:zod.z.string(),metadata:a}),x="tool-call",Xe=(a=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(),metadata:a}),Z="partial-tool-call",We=(a=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(),metadata:a}),w="tool-response",hn=(a=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:a}),yn=[M,$e,x,w,ze],Ye=zod.z.enum(yn),fn=(a=zod.z.undefined(),t=zod.z.undefined(),n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[Ge(a),ln(t),Xe(n),hn(o),pn(i)]),Tn=[J,Z,He];zod.z.enum(Tn);var bn=(a=zod.z.undefined(),t=zod.z.undefined(),n=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[Ke(a),We(t),gn(n)]);var ee=(a=Y,t=zod.z.undefined(),n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined(),s=zod.z.undefined(),l=zod.z.undefined())=>zod.z.object({role:a,content:zod.z.array(fn(t,n,o,i,l)),metadata:s}),te=(a=Jt,t=zod.z.undefined(),n=zod.z.undefined(),o=zod.z.undefined(),i=zod.z.undefined())=>zod.z.object({role:a,partialContent:bn(t,n,o),metadata:i}),Pn=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()}),kn=Be.extend({topLogProbs:zod.z.array(Be)}),Je=zod.z.array(kn);zod.z.object({messages:zod.z.array(ee()),usage:Pn.optional(),logProbs:Je.optional()});var Mn=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:Mn.optional(),logProbs:Je.optional()});var H=(a=zod.z.record(zod.z.string(),zod.z.any()).optional())=>a,Cn=["object","array","number","string","boolean","enum"],Oe=zod.z.enum(Cn),Rn=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()}),In=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(Rn),additionalProperties:zod.z.literal(!1)}),Ze=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:In}).optional(),_="text",et="token",xn=[_,et],tt=zod.z.enum(xn),vn=zod.z.array(zod.z.string().min(1)),Sn=zod.z.array(zod.z.array(zod.z.number().int().nonnegative())),nt=(a=zod.z.undefined())=>zod.z.discriminatedUnion("modality",[zod.z.object({modality:zod.z.literal(_),metadata:a,requests:vn}),zod.z.object({modality:zod.z.literal(et),metadata:a,requests:Sn})]),ne="float",En=zod.z.object({index:zod.z.number().int().nonnegative(),embedding:zod.z.array(zod.z.number())}),wn="base64",_n=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(En),usage:Fe.optional()}),zod.z.object({encodingFormat:zod.z.literal(wn),embeddings:zod.z.array(_n),usage:Fe.optional()})]);var An=a=>{let t=new WeakSet;return JSON.stringify(a,(n,o)=>{if(typeof o=="object"&&o!==null){if(t.has(o))return;t.add(o);}return o})},Un=a=>a==null?"unknown error":typeof a=="string"?a:a instanceof Error?a.message:An(a),X="GatewayBaseError",N=class ot extends Error{constructor({info:t,cause:n},o){super(`[${o!=null?o:X}]: ${t}
6
+ Message: ${Un(n)}`),this.name=X,this.info=t,this.cause=n,this.name=o!=null?o:X,Object.setPrototypeOf(this,new.target.prototype);}static isGatewayBaseError(t){return t instanceof ot}toJSON(){return {name:this.name,info:this.info,cause:this.cause,message:this.message,stack:this.stack}}},Nn=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."),jn=zod.z.object({base:Nn.describe("Base (uncached, non\u2011reasoning) rates")}).describe("Holds the `ChatModelTokenPairPrice` for different categories (e.g., base) within a single pricing tier."),Ln=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:jn.describe("Price categories and rates for this specific token range.")}).refine(a=>a.maxTokens===null||typeof a.maxTokens=="number"&&a.maxTokens>a.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(Ln).min(1).describe("Pricing tiers (`ChatModelTokenRangePrice`) schedule, sorted by minTokens.")}).superRefine((a,t)=>{let{tokenRanges:n}=a;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 o=n[n.length-1];n.every(i=>i.maxTokens!==null||i===o)&&o.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 qn="function";var Dn=zod.z.enum(["object","array","number","string","boolean","null"]),Bn=zod.z.object({anyOf:zod.z.array(zod.z.any()).optional(),type:Dn.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(Bn).optional(),required:zod.z.array(zod.z.string()).optional()});var On=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 Fn=zod.z.enum(["function"]),$n=zod.z.object({maxAttempts:zod.z.number().int().positive(),initialDelay:zod.z.number().int().positive(),exponentialFactor:zod.z.number().int().positive()}),zn=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:$n.optional()}),Hn=zod.z.discriminatedUnion("type",[zn]),Vn=zod.z.object({type:Fn,definition:zod.z.object({schema:On}),request:Hn.optional()}),Qn=[qn];zod.z.enum(Qn);var at=(a=zod.z.undefined())=>zod.z.discriminatedUnion("type",[Vn.extend({metadata:a})]),it=a=>Ge().parse({modality:M,value:a}),st=(a,t,n,o)=>Xe().parse({modality:x,index:a,id:t,name:n,arguments:o});var oe=(a,t)=>te().parse({role:a,partialContent:Ke().parse({modality:J,value:t})}),rt=(a,t,n,o,i)=>te().parse({role:a,partialContent:We().parse({modality:Z,index:t,id:n,name:o,arguments:i})});var Gn=Object.defineProperty,lt=Object.getOwnPropertySymbols,Kn=Object.prototype.hasOwnProperty,Xn=Object.prototype.propertyIsEnumerable,mt=(a,t,n)=>t in a?Gn(a,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):a[t]=n,F=(a,t)=>{for(var n in t||(t={}))Kn.call(t,n)&&mt(a,n,t[n]);if(lt)for(var n of lt(t))Xn.call(t,n)&&mt(a,n,t[n]);return a};var ct="ModelResponseError",U=class yt extends N{constructor({info:t,cause:n}){super({info:t,cause:n},ct),this.name=ct,this.cause=n,this.info=t;}static isModelResponseError(t){return t instanceof yt}},pt="InvalidModelRequestError",O=class ft extends N{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 isInvalidModelRequestError(t){return t instanceof ft}},ut="InvalidConfigError",S=class Tt 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 isInvalidConfigError(t){return t instanceof Tt}},dt="InvalidMessagesError",R=class bt 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 isInvalidMessagesError(t){return t instanceof bt}},gt="InvalidToolsError",ae=class Pt 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 isInvalidToolsError(t){return t instanceof Pt}},ht="InvalidEmbeddingRequestsError",ie=class kt extends N{constructor({info:t,cause:n}){super({info:t,cause:n},ht),this.name=ht,this.info=t,this.cause=n,Object.setPrototypeOf(this,new.target.prototype);}static isInvalidEmbeddingRequestsError(t){return t instanceof kt}},se="multi-string",Mt=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()}),Wn=a=>zod.z.array(zod.z.string()).max(a).default([]).optional(),Ct=a=>({def:Mt.parse(F({type:se},a)),schema:Wn(a.max)}),re="object-schema",Rt=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()}),Yn=a=>a.optional(),It=a=>({def:Rt.parse(F({type:re},a)),schema:Yn(a.objectSchema)}),le="range",xt=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()}),Jn=(a,t,n,o)=>zod.z.number().min(a).max(t).step(n).default(o).optional(),E=a=>({def:xt.parse(F({type:le},a)),schema:Jn(a.min,a.max,a.step,a.default)}),me="select-boolean",vt=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()}),Zn=a=>zod.z.boolean().nullable().default(a).optional(),St=a=>({def:vt.parse(F({type:me},a)),schema:Zn(a.default)}),ce="select-string",Et=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=(a,t)=>zod.z.enum(t).nullable().default(a).optional(),pe=a=>({def:Et.parse(F({type:ce},a)),schema:eo(a.default,a.choices)}),to=[le,se,ce,re,me];zod.z.enum(to);var wt=zod.z.discriminatedUnion("type",[xt,Mt,Et,vt,Rt]),_t=(a=Y,t=Ye)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),roles:zod.z.record(a,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),wt),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(n=>{var o,i;let s=Object.keys(n.def),l=Object.keys((i=(o=n.schema)==null?void 0:o.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()}),At=(a=tt)=>zod.z.object({name:zod.z.string().min(1),description:zod.z.string().min(1),modalities:zod.z.array(a).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),wt),schema:zod.z.instanceof(zod.z.ZodObject)}).refine(t=>{var n,o;let i=Object.keys(t.def),s=Object.keys((o=(n=t.schema)==null?void 0:n.shape)!=null?o:{});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 no={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."},oo={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."},ao={type:"range",title:"Max reasoning tokens",description:"Specify the total tokens for reasoning, where one token approximates four English characters."},io=a=>({type:"multi",title:"Stop sequence",description:`Enter up to ${a} sequences that will halt additional text output. The generated text will exclude these sequences.`}),so={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."},ro={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."},lo={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."},mo={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."},co={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."},po={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."},uo={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."},go={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."},ho={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."},yo={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."},fo={type:"boolean",title:"Echo",description:"If true, the response will contain the prompt."},To={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."},bo={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."},Po={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."},h={TEMPERATURE:no,MAX_TOKENS:oo,STOP:io,TOP_A:so,TOP_P:ro,TOP_K:lo,MIN_P:mo,FREQUENCY_PENALTY:co,PRESENCE_PENALTY:po,REPETITION_PENALTY:go,SEED:uo,LOG_PROBS:ho,TOP_LOG_PROBS:yo,ECHO:fo,RESPONSE_FORMAT:To,RESPONSE_FORMAT_WITH_SCHEMA:bo,RESPONSE_SCHEMA:Po,MAX_REASONING_TOKENS:ao};var V=a=>Object.fromEntries(Object.entries(a).filter(([t,n])=>n!=null));var j=a=>a==null?void 0:a.replace(/\/$/,"");var ue=E({param:"temperature",title:h.TEMPERATURE.title,description:h.TEMPERATURE.description,min:0,max:1,step:.01,default:1}),de=a=>E({param:"max_tokens",title:h.MAX_TOKENS.title,description:h.MAX_TOKENS.description,min:0,max:a,step:1,default:0}),ge=a=>Ct({param:"stop",title:h.STOP(a).title,description:h.STOP(a).description,max:a}),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}),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=St({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"]}),Ie=It({param:"response_schema",title:h.RESPONSE_SCHEMA.title,description:h.RESPONSE_SCHEMA.description,objectSchema:Ze});var Ut=(a,t)=>zod.z.object({temperature:ue.schema,maxTokens:de(a).schema,stop:ge(t).schema,topP:ye.schema,topK:he.schema,minP:fe.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:Ie.schema,responseFormat:Re.schema}),Nt=(a,t)=>({temperature:ue.def,maxTokens:de(a).def,stop:ge(t).def,topP:ye.def,topK:he.def,minP:fe.def,frequencyPenalty:Te.def,presencePenalty:be.def,repetitionPenalty:Pe.def,seed:ke.def,logProbs:Me.def,toolChoice:Ce.def,responseSchema:Ie.def,responseFormat:Re.def});var xe={base:(a,t)=>({def:Nt(a,t),schema:Ut(a,t)})};var jt=zod.z.enum([q,D,I,B]),Lt={system:q,user:D,assistant:I,tool:B};var qt=[M,x,w],Dt=zod.z.enum([M,x,w]);var Ro=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())}),Io=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()})})),Bt=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:Io.optional()}),logprobs:Ro.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()}),xo=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()})),Ot=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:xo.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 vo=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()})}),So=zod.z.enum(["none","auto","required"]),Eo=zod.z.object({type:zod.z.literal("function"),function:zod.z.object({name:zod.z.string().min(1)})}),wo=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(),_o=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)})}),Ao=zod.z.object({role:zod.z.literal("system"),content:ve}),Uo=zod.z.object({role:zod.z.literal("user"),content:ve}),No=zod.z.object({role:zod.z.literal("assistant"),content:ve.optional(),tool_calls:zod.z.array(_o).min(1).optional()}),jo=zod.z.object({role:zod.z.literal("tool"),tool_call_id:zod.z.string().min(1),content:zod.z.string().min(1)}),Lo=zod.z.union([Ao,Uo,No,jo]),Ft=zod.z.object({model:zod.z.string().min(1).optional(),messages:zod.z.array(Lo).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:wo.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(vo).optional(),tool_choice:So.or(Eo).optional()});var Se=_t(jt,Dt).parse({name:"__base__",description:"Base chat model for Together AI",maxInputTokens:128e3,maxOutputTokens:128e3,roles:Lt,modalities:qt,config:{def:xe.base(128e3,4).def,schema:xe.base(128e3,4).schema}});var qo="together-ai",L=class{constructor(){this.version="v1";this.name=qo;}chatModelLiterals(){return ["__base__"]}chatModelSchemas(){return {__base__:Se}}chatModel(t){let n=Q,o=we.parse(t);return new n(Se,o)}embeddingModelLiterals(){return ["__base__"]}embeddingModelSchemas(){return {__base__:Ee}}embeddingModel(t){let n=G,o=_e.parse(t);return new n(Ee,o)}};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 o=we.parse(n);this.modelSchema=t,this.modelName=o.modelName,this.apiKey=o.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,o)=>n+o.content.map(i=>i.modality==="text"?i.value:"").join(" ").length,0)}transformModelRequest(t){let n=Ft.safeParse(t);if(!n.success)throw new O({info:"Invalid model request",cause:n.error});let o=n.data,i=o.model;if(o.tool_choice&&(!o.tools||o.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={};o.response_format&&(s.responseFormat=o.response_format.type,o.response_format.type==="json_schema"&&(s.responseSchema={name:o.response_format.json_schema.name,description:o.response_format.json_schema.description||"",strict:o.response_format.json_schema.strict,schema:o.response_format.json_schema.schema})),o.tool_choice&&(typeof o.tool_choice=="string"?s.toolChoice=o.tool_choice:s.toolChoice=o.tool_choice.function.name),s.seed=o.seed,s.maxTokens=o.max_tokens,s.temperature=o.temperature,s.topP=o.top_p,s.minP=o.min_p,s.topK=o.top_k,s.repetitionPenalty=o.repetition_penalty,s.presencePenalty=o.presence_penalty,s.frequencyPenalty=o.frequency_penalty,s.repetitionPenalty=o.repetition_penalty,s.stop=o.stop,s.logProbs=o.logprobs!==0,s.echo=o.echo;let l=H().parse(V(s)),m=[],u={};o.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((v,k)=>{let A={modality:x,id:v.id,index:k,name:v.function.name,arguments:v.function.arguments};f.push(A),u[A.id]=A;}),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 o.tools&&o.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,o){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
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(!o||o&&o.length===0)throw new S({info:`Invalid config for model : '${this.modelName}'`,cause:new Error("'tools' are required when 'toolChoice' is specified")});if(o&&o.length>0){let g=this.modelSchema.config.def.toolChoice;if(!g.choices.includes(u))if(o.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
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
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}',
@@ -12,8 +12,8 @@ Message: ${Un(n)}`),this.name=X,this.info=t,this.cause=n,this.name=o!=null?o:X,O
12
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 : '${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
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
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(i=>{let s=at().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,o){return P(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getCompleteChatHeaders(t,n,o){return P(this,null,function*(){return new Promise(i=>{i(this.getDefaultHeaders());})})}getCompleteChatData(t,n,o){return P(this,null,function*(){let i=this.transformConfig(t,n,o),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=o?this.transformTools(o):{};return new Promise(m=>{m(b(b(b(b({},this.getDefaultParams()),i),s),l));})})}transformCompleteChatResponse(t){let n=Bt.safeParse(t);if(n.success){if(n.data.choices.length===0)throw new U({info:"Invalid response from model",cause:new Error(`No choices in response : ${JSON.stringify(n.data)}`)});let o=n.data,i=[{role:I,content:[]}],s=o.choices[0].message;s.content&&i[0].content.push(it(s.content)),s.tool_calls&&s.tool_calls.forEach((g,d)=>{i[0].content.push(st(d,g.id,g.function.name,g.function.arguments));});let l;o.usage&&(l={promptTokens:o.usage.prompt_tokens,completionTokens:o.usage.completion_tokens,totalTokens:o.usage.total_tokens});let m=[],u=o.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 U({info:"Invalid response from model",cause:n.error})}getStreamChatUrl(t,n,o){return P(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getStreamChatHeaders(t,n,o){return P(this,null,function*(){return new Promise(i=>{i(this.getDefaultHeaders());})})}getStreamChatData(t,n,o){return P(this,null,function*(){let i=this.transformConfig(t,n,o),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=o?this.transformTools(o):{};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 o=n+t,i=[],s="",l=0;for(;l<o.length;){let g=o.indexOf(`
15
- `,l);if(g===-1){s=o.substring(l);break}else {let d=o.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 y=JSON.parse(d),f=Ot.safeParse(y);if(f.success){let T={partialMessages:[]},v=f.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(I,k.content));else if("refusal"in k&&k.refusal!==null)T.partialMessages.push(oe(I,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(rt(I,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 U({info:"Invalid response from model",cause:f.error})}catch(y){throw new U({info:`Malformed JSON received in stream: ${d}`,cause:y})}}}yield {partialResponse:{partialMessages:[]},buffer:s};})}transformProxyStreamChatResponseChunk(t,n,o,i,s){return K(this,null,function*(){yield*De(this.transformStreamChatResponseChunk(t,n));})}getProxyStreamChatUrl(t,n,o){return P(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getProxyCompleteChatUrl(t,n,o){return P(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getProxyCompleteChatHeaders(t,n,o){return P(this,null,function*(){if(!n)return {};let i=b({},n);return delete i.host,delete i["content-length"],i})}getProxyStreamChatHeaders(t,n,o){return P(this,null,function*(){return yield this.getProxyCompleteChatHeaders(t,n,o)})}getModelPricing(){if(!(this.modelName in Ae))throw new U({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return Ae[this.modelName]}};var Ft=[_],zt=zod.z.enum([_]);var Ht=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 Oo=zod.z.string().min(1).or(zod.z.array(zod.z.string().min(1)).min(1)),Vt=zod.z.object({model:zod.z.string().min(1).optional(),input:Oo});var _e=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string()}),G=class{constructor(t,n){this.version="v1";let o=_e.parse(n);this.modelSchema=t,this.modelName=o.modelName,this.apiKey=o.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,o)=>n+o.length,0)}transformModelRequest(t){let n=Vt.safeParse(t);if(!n.success)throw new O({info:"Invalid model request",cause:n.error});let o=n.data,i=o.model,s={},l=H().parse(V(s)),m={modality:_,requests:[...o.input]};return {modelName:i,config:l,embeddingRequests:m}}transformConfig(t,n){let o=this.modelSchema.config.schema.safeParse(t);if(!o.success)throw new S({info:`Invalid config for model : '${this.modelName}'`,cause:o.error});let i=o.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=nt().safeParse(t);if(!n.success)throw new ie({info:"Invalid embedding requests",cause:n.error});if(t.modality!==_)throw new ie({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Only '${_}' modality is supported for model : '${this.modelName}'`)});return {input:n.data.requests}}getGetEmbeddingsUrl(t,n){return P(this,null,function*(){return new Promise(o=>{o(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(t,n){return P(this,null,function*(){return new Promise(o=>{o(this.getDefaultHeaders());})})}getGetEmbeddingsData(t,n){return P(this,null,function*(){return new Promise(o=>{o(b(b(b({},this.getDefaultParams()),this.transformConfig(t,n)),this.transformEmbeddingRequests(n)));})})}transformGetEmbeddingsResponse(t){var o;let n=Ht.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:(o=i.usage)==null?void 0:o.total_tokens}}}throw new U({info:"Invalid response from model",cause:n.error})}};var Ee=At(zt).parse({name:"__base__",description:"Base embedding model for Together AI",maxInputTokens:128e3,maxOutputTokens:128e3,modalities:Ft,config:{def:{},schema:zod.z.object({})}});
15
+ `,l);if(g===-1){s=o.substring(l);break}else {let d=o.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 y=JSON.parse(d),f=Ot.safeParse(y);if(f.success){let T={partialMessages:[]},v=f.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(I,k.content));else if("refusal"in k&&k.refusal!==null)T.partialMessages.push(oe(I,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(rt(I,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 U({info:"Invalid response from model",cause:f.error})}catch(y){throw new U({info:`Malformed JSON received in stream: ${d}`,cause:y})}}}yield {partialResponse:{partialMessages:[]},buffer:s};})}transformProxyStreamChatResponseChunk(t,n,o,i,s){return K(this,null,function*(){yield*De(this.transformStreamChatResponseChunk(t,n));})}getProxyStreamChatUrl(t,n,o){return P(this,null,function*(){return new Promise(i=>{i(this.streamChatUrl);})})}getProxyCompleteChatUrl(t,n,o){return P(this,null,function*(){return new Promise(i=>{i(this.completeChatUrl);})})}getProxyCompleteChatHeaders(t,n,o){return P(this,null,function*(){if(!n)return {};let i=b({},n);return delete i.host,delete i["content-length"],i})}getProxyStreamChatHeaders(t,n,o){return P(this,null,function*(){return yield this.getProxyCompleteChatHeaders(t,n,o)})}getModelPricing(){if(!(this.modelName in Ae))throw new U({info:`Invalid model pricing for model : '${this.modelName}'`,cause:new Error(`No pricing configuration found for model "${this.modelName}"`)});return Ae[this.modelName]}};var $t=[_],zt=zod.z.enum([_]);var Ht=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 Oo=zod.z.string().min(1).or(zod.z.array(zod.z.string().min(1)).min(1)),Vt=zod.z.object({model:zod.z.string().min(1).optional(),input:Oo});var _e=zod.z.object({modelName:zod.z.string(),apiKey:zod.z.string()}),G=class{constructor(t,n){this.version="v1";let o=_e.parse(n);this.modelSchema=t,this.modelName=o.modelName,this.apiKey=o.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,o)=>n+o.length,0)}transformModelRequest(t){let n=Vt.safeParse(t);if(!n.success)throw new O({info:"Invalid model request",cause:n.error});let o=n.data,i=o.model,s={},l=H().parse(V(s)),m={modality:_,requests:[...o.input]};return {modelName:i,config:l,embeddingRequests:m}}transformConfig(t,n){let o=this.modelSchema.config.schema.safeParse(t);if(!o.success)throw new S({info:`Invalid config for model : '${this.modelName}'`,cause:o.error});let i=o.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=nt().safeParse(t);if(!n.success)throw new ie({info:"Invalid embedding requests",cause:n.error});if(t.modality!==_)throw new ie({info:`Invalid embedding requests for model : '${this.modelName}'`,cause:new Error(`Only '${_}' modality is supported for model : '${this.modelName}'`)});return {input:n.data.requests}}getGetEmbeddingsUrl(t,n){return P(this,null,function*(){return new Promise(o=>{o(this.getEmbeddingsUrl);})})}getGetEmbeddingsHeaders(t,n){return P(this,null,function*(){return new Promise(o=>{o(this.getDefaultHeaders());})})}getGetEmbeddingsData(t,n){return P(this,null,function*(){return new Promise(o=>{o(b(b(b({},this.getDefaultParams()),this.transformConfig(t,n)),this.transformEmbeddingRequests(n)));})})}transformGetEmbeddingsResponse(t){var o;let n=Ht.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:(o=i.usage)==null?void 0:o.total_tokens}}}throw new U({info:"Invalid response from model",cause:n.error})}};var Ee=At(zt).parse({name:"__base__",description:"Base embedding model for Together AI",maxInputTokens:128e3,maxOutputTokens:128e3,modalities:$t,config:{def:{},schema:zod.z.object({})}});
17
17
 
18
18
  exports.BaseChatModel = Q;
19
19
  exports.BaseChatModelOptions = we;
@@ -25,7 +25,7 @@ exports.ChatModelBaseConfigDef = Nt;
25
25
  exports.ChatModelBaseConfigSchema = Ut;
26
26
  exports.TogetherAI = L;
27
27
  exports.TogetherAIChatModelConfigs = xe;
28
- exports.TogetherAIEmbeddingModelModalities = Ft;
28
+ exports.TogetherAIEmbeddingModelModalities = $t;
29
29
  exports.TogetherAIEmbeddingModelModalitiesEnum = zt;
30
30
  exports.TogetherAIEmbeddingRequest = Vt;
31
31
  exports.TogetherAIEmbeddingRequestInput = Oo;