@adaline/together-ai 1.10.0 → 1.10.2

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