@ax-llm/ax 24.0.0 → 24.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +1 -1
- package/index.cjs.map +1 -1
- package/index.d.cts +37 -4
- package/index.d.ts +37 -4
- package/index.global.js +1 -1
- package/index.global.js.map +1 -1
- package/index.js +1 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/skills/ax-agent-context.md +1 -1
- package/skills/ax-agent-memory-skills.md +1 -1
- package/skills/ax-agent-observability.md +1 -1
- package/skills/ax-agent-optimize.md +1 -1
- package/skills/ax-agent-rlm.md +1 -1
- package/skills/ax-agent.md +1 -1
- package/skills/ax-ai.md +2 -2
- package/skills/ax-audio.md +1 -1
- package/skills/ax-flow.md +1 -1
- package/skills/ax-gen.md +1 -1
- package/skills/ax-gepa.md +1 -1
- package/skills/ax-llm.md +1 -1
- package/skills/ax-mcp.md +1 -1
- package/skills/ax-playbook.md +1 -1
- package/skills/ax-refine.md +1 -1
- package/skills/ax-signature.md +1 -1
package/index.cjs
CHANGED
|
@@ -1261,7 +1261,7 @@ ${e}
|
|
|
1261
1261
|
`)}):t}createResponsesReqInternalInput(e,t=!1){let n=[];for(let o of e){if(t&&o.role==="system")continue;let i;if(o.role==="system"||o.role==="user"||o.role==="assistant"&&o.content)if(typeof o.content=="string")o.role==="system"?i=o.content:o.role==="assistant"?i=[{type:"output_text",text:o.content}]:i=[{type:"input_text",text:o.content}];else if(Array.isArray(o.content))i=this.mapInternalContentToResponsesInput(o.content,o.role==="assistant"?"assistant":"user");else{if(!(o.role==="assistant"&&!o.content&&o.functionCalls))throw new Error(`Invalid content type for role ${o.role}`);i=""}else o.role,i="";switch(o.role){case"system":n.push({type:"message",role:"system",content:i});break;case"user":n.push({type:"message",role:"user",content:i,name:o.name});break;case"assistant":if(o.thought||o.thoughtBlocks?.length){let s=o.thought??o.thoughtBlocks?.map(a=>a.data).join("");s&&n.push({type:"reasoning",content:s})}if(o.content||o.functionCalls){let s={type:"message",role:"assistant",content:""};if(o.content&&(s.content=i),o.name&&(s.name=o.name),o.content&&n.push(s),o.functionCalls)for(let a of o.functionCalls)n.push({type:"function_call",call_id:a.id,name:a.function.name,arguments:typeof a.function.params=="object"?JSON.stringify(a.function.params):a.function.params||""})}break;case"function":n.push({type:"function_call_output",call_id:o.functionId,output:this.mapFunctionResultContent(o.content,o.result)});break;default:{let s=o.role;throw new Error(`Invalid role in chat prompt: ${s}`)}}}return n}createChatReq(e,t){let n=e.model,o={name:"/responses"},i=null,s=!1;if(e.chatPrompt){for(let x of e.chatPrompt)if(x.role==="system"&&typeof x.content=="string"){i=x.content,s=!0;break}}let a=i??this.config.systemPrompt??null,c=e.functions?.map(x=>({type:"function",name:x.name,description:x.description,parameters:x.parameters??{}})),l=[],u=kP(n),d=this.config.reasoningSummary;t?.showThoughts?d||(d="auto"):d=void 0;let p=this.config.reasoningEffort;t?.thinkingTokenBudget&&(p=_b(n,t.thinkingTokenBudget));let m={model:n,input:"",instructions:a,tools:c?.length?c:void 0,tool_choice:e.functionCall==="none"||e.functionCall==="auto"||e.functionCall==="required"?e.functionCall:typeof e.functionCall=="object"&&e.functionCall.function?{type:"function",name:e.functionCall.function.name}:void 0,...u?{max_output_tokens:e.modelConfig?.maxTokens??this.config.maxTokens??void 0}:{...e.modelConfig?.temperature!==void 0?{temperature:e.modelConfig.temperature}:{},...e.modelConfig?.topP!==void 0?{top_p:e.modelConfig.topP}:{},presence_penalty:e.modelConfig?.presencePenalty??this.config.presencePenalty??void 0,frequency_penalty:e.modelConfig?.frequencyPenalty??this.config.frequencyPenalty??void 0,max_output_tokens:e.modelConfig?.maxTokens??this.config.maxTokens??void 0},stream:e.modelConfig?.stream??this.config.stream??!1,background:void 0,include:l.length>0?l:void 0,metadata:void 0,parallel_tool_calls:this.config.parallelToolCalls,previous_response_id:void 0,...p?{reasoning:{effort:p,...p==="none"?{}:{summary:d}}}:{},service_tier:this.config.serviceTier,store:this.config.store,text:void 0,truncation:void 0,user:this.config.user,seed:this.config.seed};this.config.user&&(m.user=this.config.user),this.config.parallelToolCalls!==void 0&&(m.parallel_tool_calls=this.config.parallelToolCalls),e.responseFormat?m.text={format:e.responseFormat.type==="json_schema"?{type:"json_schema",json_schema:e.responseFormat.schema}:{type:e.responseFormat.type}}:this.config.responseFormat&&(m.text={format:{type:this.config.responseFormat}}),this.config.seed&&(m.seed=this.config.seed);let g=e.chatPrompt?this.createResponsesReqInternalInput(e.chatPrompt,s):[];if(g.length>0)m.input=g;else if(e.chatPrompt&&e.chatPrompt.length===1&&e.chatPrompt[0]?.role==="user"&&e.chatPrompt[0]?.content&&typeof e.chatPrompt[0].content=="string"&&!a)m.input=e.chatPrompt[0].content;else if(g.length===0&&!a)throw new Error("Responses API request must have input or instructions.");m.reasoning?.effort||(m.reasoning=void 0);let h=m;return this.responsesReqUpdater&&(h=this.responsesReqUpdater(h)),[o,h]}createChatResp(e){let{id:t,output:n,usage:o}=e;this.tokensUsed=Ln(o);let i={},s=[];for(let a of n??[])switch(a.type){case"message":i.id=a.id,i.content=Hp(a.content,t),i.finishReason=a.status==="completed"?"stop":"content_filter",i.citations=Kc(a.content);break;case"reasoning":i.id=a.id;{let c=Vp(a);c&&(i.thought=i.thought?`${i.thought}${c}`:c,i.thoughtBlocks=[...i.thoughtBlocks??[],{data:c,encrypted:!!a.encrypted_content}])}break;case"file_search_call":i.id=a.id,i.functionCalls=[{id:a.id,type:"function",function:{name:"file_search",params:{queries:a.queries,results:a.results}}}],i.finishReason="function_call";break;case"web_search_call":i.id=a.id,i.functionCalls=[{id:a.id,type:"function",function:{name:"web_search",params:{queries:a.queries}}}],i.finishReason="function_call";break;case"computer_call":i.id=a.id,i.functionCalls=[{id:a.id,type:"function",function:{name:"computer_use",params:{action:a.action}}}],i.finishReason="function_call";break;case"code_interpreter_call":i.id=a.id,i.functionCalls=[{id:a.id,type:"function",function:{name:"code_interpreter",params:{code:a.code,results:a.results}}}],i.finishReason="function_call";break;case"image_generation_call":i.id=a.id,i.functionCalls=[{id:a.id,type:"function",function:{name:"image_generation",params:{result:a.result}}}],i.finishReason="function_call";break;case"local_shell_call":i.id=a.id,i.functionCalls=[{id:a.id,type:"function",function:{name:"local_shell",params:{action:a.action}}}],i.finishReason="function_call";break;case"mcp_call":i.id=a.id,i.functionCalls=[{id:a.id,type:"function",function:{name:"mcp",params:{name:a.name,args:a.args,serverLabel:a.server_label,output:a.output,error:a.error}}}],i.finishReason="function_call";break;case"function_call":i.id=a.id,s.push({id:a.call_id,type:"function",function:{name:a.name,params:a.arguments}}),i.finishReason="function_call";break}return s.length>0&&(i.functionCalls=s),{results:[{...i,index:0}],remoteId:t}}createChatStreamResp=(e,t)=>{let n=e,o=t,i={index:0,id:"",content:"",finishReason:"stop"},s=typeof n.response?.id=="string"?n.response.id:void 0;switch(n.type){case"response.created":case"response.in_progress":case"response.queued":s=n.response.id,i.id=`${n.response.id}_res_0`;break;case"response.output_item.added":switch(n.item.type){case"message":i.id=n.item.id,i.content=Hp(n.item.content,n.item.id),i.citations=Kc(n.item.content);break;case"function_call":{let a=n.item;o.functionCallIds??=new Map,o.functionCallIds.set(a.id,a.call_id),i.id=n.item.id,i.functionCalls=[{id:a.call_id,type:"function",function:{name:a.name,params:a.arguments}}]}break;case"file_search_call":{let a=n.item;i.id=n.item.id,i.functionCalls=[{id:a.id,type:"function",function:{name:"file_search",params:{queries:a.queries||[],results:a.results?.map(c=>({fileId:c.file_id,filename:c.filename,score:c.score,text:c.text,attributes:c.attributes}))}}}]}break;case"web_search_call":{let a=n.item;i.id=n.item.id,i.functionCalls=[{id:a.id,type:"function",function:{name:"web_search",params:{queries:a.queries||[]}}}]}break;case"computer_call":{let a=n.item;i.id=n.item.id,i.functionCalls=[{id:a.id,type:"function",function:{name:"computer_use",params:{action:a.action||{}}}}]}break;case"code_interpreter_call":{let a=n.item;i.id=n.item.id,i.functionCalls=[{id:a.id,type:"function",function:{name:"code_interpreter",params:{code:a.code||"",results:a.results}}}]}break;case"image_generation_call":{let a=n.item;i.id=n.item.id,i.functionCalls=[{id:a.id,type:"function",function:{name:"image_generation",params:{result:a.result}}}]}break;case"local_shell_call":{let a=n.item;i.id=n.item.id,i.functionCalls=[{id:a.id,type:"function",function:{name:"local_shell",params:{action:a.action||{}}}}]}break;case"mcp_call":{let a=n.item;i.id=n.item.id,i.functionCalls=[{id:a.id,type:"function",function:{name:"mcp",params:{name:a.name||"",args:a.args||"",serverLabel:a.server_label||"",output:a.output,error:a.error}}}]}break;case"reasoning":{i.id=n.item.id;let a=Vp(n.item);a&&(i.thought=a,i.thoughtBlocks=[{data:a,encrypted:!!n.item.encrypted_content}]);break}}break;case"response.content_part.added":i.id=n.item_id,i.content=Hp([n.part],n.item_id),i.citations=Kc([n.part]);break;case"response.output_text.delta":i.id=n.item_id,i.content=n.delta;break;case"response.output_text.done":break;case"response.function_call_arguments.delta":{let a=o.functionCallIds?.get(n.item_id)??n.item_id;i.id=n.item_id,i.functionCalls=[{id:a,type:"function",function:{name:"",params:n.delta}}]}break;case"response.reasoning_summary_text.delta":i.id=n.item_id,i.thought=n.delta,i.thoughtBlocks=[{data:n.delta,encrypted:!1}];break;case"response.reasoning_text.delta":i.id=n.item_id,i.thought=n.delta,i.thoughtBlocks=[{data:n.delta,encrypted:!1}];break;case"response.reasoning_text.done":i.id=n.item_id,i.thought=n.text,i.thoughtBlocks=[{data:n.text,encrypted:!1}];break;case"response.file_search_call.in_progress":case"response.file_search_call.searching":i.id=n.item_id,i.finishReason="function_call";break;case"response.file_search_call.completed":i.id=n.item_id,i.finishReason="function_call";break;case"response.web_search_call.in_progress":case"response.web_search_call.searching":i.id=n.item_id,i.finishReason="function_call";break;case"response.web_search_call.completed":i.id=n.item_id,i.finishReason="function_call";break;case"response.image_generation_call.in_progress":case"response.image_generation_call.generating":i.id=n.item_id,i.finishReason="function_call";break;case"response.image_generation_call.completed":i.id=n.item_id,i.finishReason="function_call";break;case"response.image_generation_call.partial_image":i.id=n.item_id,i.finishReason="function_call";break;case"response.mcp_call.in_progress":i.id=n.item_id,i.finishReason="function_call";break;case"response.mcp_call.arguments.delta":i.id=n.item_id,i.functionCalls=[{id:n.item_id,type:"function",function:{name:"",params:n.delta}}];break;case"response.mcp_call.arguments.done":i.id=n.item_id,i.functionCalls=[{id:n.item_id,type:"function",function:{name:"",params:n.arguments}}];break;case"response.mcp_call.completed":case"response.mcp_call.failed":i.id="mcp_call_event",i.finishReason="function_call";break;case"response.mcp_list_tools.in_progress":case"response.mcp_list_tools.completed":case"response.mcp_list_tools.failed":i.id="mcp_list_tools_event",i.finishReason="function_call";break;case"response.output_item.done":switch(n.item.type){case"message":if(i.id=n.item.id,i.finishReason=n.item.status==="completed"?"stop":"error",!i.citations||i.citations.length===0){let a=Kc(n.item.content||[]);a&&(i.citations=a)}break;case"function_call":case"file_search_call":case"web_search_call":case"computer_call":case"code_interpreter_call":case"image_generation_call":case"local_shell_call":case"mcp_call":i.id=n.item.id,i.finishReason="function_call";break;case"reasoning":{i.id=n.item.id;let a=Vp(n.item);a&&(i.thought=a,i.thoughtBlocks=[{data:a,encrypted:!!n.item.encrypted_content}]);break}}break;case"response.completed":this.tokensUsed=Ln(n.response.usage),s=n.response.id,i.id=`${n.response.id}_completed`,i.finishReason="stop";break;case"response.failed":s=n.response.id,i.id=`${n.response.id}_failed`,i.finishReason="error";break;case"response.incomplete":s=n.response.id,i.id=`${n.response.id}_incomplete`,i.finishReason="length";break;case"error":i.id="error",i.content=`Error: ${n.message}`,i.finishReason="error";break;default:i.id="unknown";break}return s?o.remoteId=s:s=o.remoteId,{results:[i],remoteId:s}};createEmbedReq(e){let t=e.embedModel;if(!t)throw new Error("Embed model not set");if(!e.texts||e.texts.length===0)throw new Error("Embed texts is empty");let n={name:"/embeddings"},o={model:t,input:e.texts,dimensions:this.config.dimensions};return[n,o]}},Vp=r=>{if(typeof r.content=="string")return r.content;if(Array.isArray(r.content)){let e=r.content.map(t=>t.text).join("");if(e)return e}return r.encrypted_content?r.encrypted_content:r.summary?.map(e=>e.text).join(`
|
|
1262
1262
|
`)??""},Hp=(r,e)=>{let t=r.filter(n=>n.type==="refusal");if(t.length>0){let n=t.map(o=>o.refusal).join(`
|
|
1263
1263
|
`);throw new Ve(n,void 0,e)}return r.filter(n=>n.type==="output_text").map(n=>n.text).join(`
|
|
1264
|
-
`)};function Kc(r){let e=[];for(let t of r??[])if(t?.type==="output_text"&&Array.isArray(t.annotations))for(let n of t.annotations)n&&n.type==="url_citation"&&typeof n.url=="string"&&e.push({url:n.url,title:n.title,description:n.description});return e.length?e:void 0}var vs=()=>({model:"gpt-4o",embedModel:"text-embedding-ada-002",temperature:.7,topP:1,stream:!0}),Bb=()=>({...vs(),model:"gpt-4o",temperature:.5}),qb=()=>({...vs(),model:"gpt-4o",temperature:.9}),Lr=class extends vt{constructor({apiKey:e,credentialProvider:t,credentialProfile:n,config:o,options:i,apiURL:s,modelInfo:a=[],models:c,responsesReqUpdater:l,supportFor:u={functions:!0,streaming:!0,media:{images:{supported:!1,formats:[]},audio:{supported:!1,formats:[]},files:{supported:!1,formats:[],uploadMethod:"none"},urls:{supported:!1,webSearch:!1,contextFetching:!1}},caching:{supported:!1,types:[]},thinking:!1,multiTurn:!0}}){if((!e||e==="")&&!t)throw new Error("OpenAI API key not set");let d=new Jc(o,i?.streamingUsage??!0,l),p=c?.map(m=>{let g=m,h=g?.config;if(!h)return m;let x={};h.maxTokens!==void 0&&(x.maxTokens=h.maxTokens),h.temperature!==void 0&&(x.temperature=h.temperature),h.topP!==void 0&&(x.topP=h.topP),h.presencePenalty!==void 0&&(x.presencePenalty=h.presencePenalty),h.frequencyPenalty!==void 0&&(x.frequencyPenalty=h.frequencyPenalty);let f=h.stopSequences??h.stop;f!==void 0&&(x.stopSequences=f),h.n!==void 0&&(x.n=h.n),h.stream!==void 0&&(x.stream=h.stream);let y={...g};Object.keys(x).length>0&&(y.modelConfig={...g.modelConfig??{},...x});let b=h?.thinking?.thinkingTokenBudget;if(typeof b=="number"){let A=[["minimal",200],["low",800],["medium",5e3],["high",1e4],["highest",24500]],R="minimal",w=Number.POSITIVE_INFINITY;for(let[N,k]of A){let E=Math.abs(b-k);E<w&&(w=E,R=N)}y.thinkingTokenBudget=R}return h?.thinking?.includeThoughts!==void 0&&(y.showThoughts=!!h.thinking.includeThoughts),y});super(d,{name:"OpenAI",apiURL:s||"https://api.openai.com/v1",headers:async()=>e?{Authorization:`Bearer ${e}`}:{},profile:n,credentialProvider:t,modelInfo:a,defaults:{model:o.model??"gpt-4o",embedModel:o.embedModel??"text-embedding-ada-002"},options:i,supportFor:u,models:p??c}),this.setChatCredentialOperation("responses")}},zo=class extends Lr{constructor({apiKey:e,credentialProvider:t,config:n,options:o,models:i,modelInfo:s}){if((!e||e==="")&&!t)throw new Error("OpenAI API key not set");s=[...Go,...s??[]];let a=c=>{let l=Gt({model:c,modelInfo:s,models:i}),u=l?.supported?.structuredOutputs??!0,d=l?.supported?.structuredOutputModes??(u?["native","function","json_object"]:["function","json_object"]);return{functions:!0,streaming:!0,hasThinkingBudget:l?.supported?.thinkingBudget??!1,hasShowThoughts:l?.supported?.showThoughts??!1,structuredOutputs:d.includes("native"),structuredOutputModes:d,media:{images:{supported:!1,formats:[]},audio:{supported:!1,formats:[]},files:{supported:!1,formats:[],uploadMethod:"none"},urls:{supported:!1,webSearch:!1,contextFetching:!1}},caching:{supported:!1,types:[]},thinking:!1,multiTurn:!0}};super({apiKey:e,credentialProvider:t,credentialProfile:"openai-responses",config:{...vs(),...n},options:o,modelInfo:s,models:i,supportFor:a})}};var Yc={openai:{id:"openai",name:"OpenAI",aliases:["openai"],transport:"openai-chat",baseURL:"https://api.openai.com/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:"gpt-5-mini",embedModel:"text-embedding-3-small"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!0,thinking:!0,multiTurn:!0,images:!0,audio:!0,audioOutput:!0,structuredOutputModes:["native","function","json_object"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"},embed:{path:"/embeddings",dialect:"openai-embeddings"},transcribe:{path:"/audio/transcriptions",dialect:"openai-transcription"},speak:{path:"/audio/speech",dialect:"openai-speech"},realtime:{path:"/realtime",dialect:"openai-realtime",modelMatch:{prefix:["gpt-realtime"]},url:"wss://api.openai.com/v1/realtime",grammar:"openai_realtime_compatible",audio:{input:{formats:["pcm16","pcm"],sampleRate:24e3},output:{formats:["pcm16","pcm"],sampleRate:24e3,voices:["alloy","ash","ballad","coral","echo","sage","shimmer","verse"],defaultVoice:"alloy"}},validation:{structuredOutputWithAudio:!1}}},modelRules:[],sources:["https://platform.openai.com/docs/api-reference/chat"],reviewedAt:"2026-08-17"},"openai-compatible":{id:"openai-compatible",name:"OpenAI Compatible",aliases:["openai-compatible","openai_compatible","compatible"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!1},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"},embed:{path:"/embeddings",dialect:"openai-embeddings"}},modelRules:[],sources:["https://platform.openai.com/docs/api-reference/chat"],reviewedAt:"2026-08-17"},"openai-responses":{id:"openai-responses",name:"OpenAI Responses",aliases:["openai-responses","openai_responses","responses"],transport:"openai-responses",baseURL:"https://api.openai.com/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:"gpt-5-mini",embedModel:"text-embedding-3-small"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!0,thinking:!0,multiTurn:!0,images:!0,audio:!0,audioOutput:!0,structuredOutputModes:["native","function","json_object"]},operations:{chat:{path:"/responses",dialect:"openai-responses"},embed:{path:"/embeddings",dialect:"openai-embeddings"},transcribe:{path:"/audio/transcriptions",dialect:"openai-transcription"},speak:{path:"/audio/speech",dialect:"openai-speech"},realtime:{path:"/realtime",dialect:"openai-realtime",modelMatch:{prefix:["gpt-realtime"]},url:"wss://api.openai.com/v1/realtime",grammar:"openai_realtime_compatible",audio:{input:{formats:["pcm16","pcm"],sampleRate:24e3},output:{formats:["pcm16","pcm"],sampleRate:24e3,voices:["alloy","ash","ballad","coral","echo","sage","shimmer","verse"],defaultVoice:"alloy"}},validation:{structuredOutputWithAudio:!1}}},modelRules:[],sources:["https://platform.openai.com/docs/api-reference/responses"],reviewedAt:"2026-08-17"},anthropic:{id:"anthropic",name:"Anthropic",aliases:["anthropic","claude"],transport:"anthropic-messages",baseURL:"https://api.anthropic.com",requiresApiURL:!1,auth:{type:"x-api-key",required:!0},headers:{"anthropic-version":"2023-06-01","anthropic-beta":"structured-outputs-2025-11-13, web-search-2025-03-05"},defaults:{model:"claude-sonnet-4-5"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!0,multiTurn:!0,images:!0,caching:{types:["ephemeral"],cacheBreakpoints:!0},structuredOutputModes:["function"]},operations:{chat:{path:"/v1/messages",dialect:"anthropic-messages"}},modelRules:[],sources:["https://docs.anthropic.com/en/api/messages"],reviewedAt:"2026-08-17"},"google-gemini":{id:"google-gemini",name:"Google Gemini",aliases:["google-gemini","google_gemini","gemini"],transport:"gemini-generate-content",baseURL:"https://generativelanguage.googleapis.com/v1beta",requiresApiURL:!1,auth:{type:"api-key-query",required:!0},defaults:{model:"gemini-3.5-flash",embedModel:"gemini-embedding-2"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!0,thinking:!0,multiTurn:!0,images:!0,audio:!0,audioOutput:!0,files:{uploadMethod:"cloud"},caching:{types:["persistent"]},structuredOutputModes:["native","function"]},operations:{chat:{path:"/models/{model}:generateContent",dialect:"gemini-generate-content"},stream_chat:{path:"/models/{model}:streamGenerateContent?alt=sse",dialect:"gemini-generate-content"},embed:{path:"/models/{model}:batchEmbedContents",dialect:"gemini-generate-content"},transcribe:{path:"/models/{model}:generateContent",dialect:"gemini-generate-content"},speak:{path:"/models/{model}:generateContent",dialect:"gemini-generate-content"},realtime:{path:"/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent",dialect:"gemini-live-bidi",modelMatch:{prefix:["gemini-live"],contains:["native-audio","-live-"]},url:"wss://generativelanguage.googleapis.com/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent",grammar:"gemini_live_bidi",defaultModel:"gemini-2.5-flash-native-audio-preview-12-2025",audio:{input:{formats:["pcm16","pcm"],sampleRate:16e3},output:{formats:["pcm16","pcm"],sampleRate:24e3,voices:["Kore","Puck","Charon","Fenrir","Aoede"],defaultVoice:"Kore"}},validation:{pcmInputOnly:!0,rejectStructuredOutputWithAudio:!0}}},modelRules:[],sources:["https://ai.google.dev/api/generate-content"],reviewedAt:"2026-08-17"},webllm:{id:"webllm",name:"WebLLM",aliases:["webllm"],transport:"webllm",baseURL:null,requiresApiURL:!1,auth:{type:"none",required:!1},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"",dialect:"webllm"}},modelRules:[],sources:["https://webllm.mlc.ai/docs/"],reviewedAt:"2026-08-17"},"azure-openai":{id:"azure-openai",name:"Azure OpenAI",aliases:["azure-openai","azure_openai","azure"],transport:"openai-chat",baseURL:null,requiresApiURL:!1,auth:{type:"api-key-header",header:"api-key",required:!0},defaults:{model:"gpt-5-mini",embedModel:"text-embedding-3-small"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!0,thinking:!0,multiTurn:!0,images:!0,structuredOutputModes:["native","function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"},embed:{path:"/embeddings",dialect:"openai-embeddings"}},endpoint:{scheme:"https",hostField:"resourceName",hostSuffix:".openai.azure.com",path:"/openai/deployments/{deploymentName}",fields:{resourceName:["resource_name","resourceName"],deploymentName:["deployment_name","deploymentName"],version:["api_version","apiVersion","version"]},required:["resourceName","deploymentName"],defaults:{version:"2024-02-15-preview"},normalizers:{version:"api-version"},apiVersionField:"version"},capabilityGates:{structuredOutputs:{option:"version",min:"2024-08-01"}},modelRules:[],sources:["https://learn.microsoft.com/en-us/azure/ai-services/openai/reference"],reviewedAt:"2026-08-17"},deepseek:{id:"deepseek",name:"DeepSeek",aliases:["deepseek"],transport:"openai-chat",baseURL:"https://api.deepseek.com",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:"deepseek-v4-flash"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[{match:{exact:["deepseek-v4-flash","deepseek-v4-pro"]},capabilities:{thinking:!0,thinkingBudget:!0,showThoughts:!0,structuredOutputs:!1,structuredOutputModes:["function"]},request:{reasoning:"thinking-object",toolChoice:"unforced",effortMap:{none:null,minimal:"low",low:"low",medium:"high",high:"high",highest:"max",xhigh:"max",max:"max"},dropWhenThinking:["temperature","top_p","presence_penalty","frequency_penalty"],defaultThinkingLevel:"max"},response:{reasoningFields:["reasoning_content","reasoning"]},replay:{assistantReasoningField:"reasoning_content"}},{match:{exact:["deepseek-reasoner"]},capabilities:{thinking:!0,thinkingBudget:!1,showThoughts:!0,structuredOutputs:!1,structuredOutputModes:["function"]},request:{toolChoice:"unforced"},response:{reasoningFields:["reasoning_content","reasoning"]},replay:{assistantReasoningField:"reasoning_content"}}],sources:["https://api-docs.deepseek.com/guides/thinking_mode/"],reviewedAt:"2026-08-18"},"deepseek-responses":{id:"deepseek-responses",name:"DeepSeek Responses",aliases:["deepseek-responses","deepseek_responses"],transport:"openai-responses",baseURL:"https://api.deepseek.com",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:"deepseek-v4-flash"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!0,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/responses",dialect:"openai-responses"}},request:{dropFields:["include","previous_response_id","store","parallel_tool_calls"],reasoningObjectFields:["effort"]},modelRules:[],sources:["https://api-docs.deepseek.com/api/create-chat-completion"],reviewedAt:"2026-08-17"},mistral:{id:"mistral",name:"Mistral AI",aliases:["mistral"],transport:"openai-chat",baseURL:"https://api.mistral.ai/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:"mistral-small-latest",embedModel:"mistral-embed"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!0,thinking:!1,multiTurn:!0,images:!0,audio:!0,audioOutput:!0,structuredOutputModes:["native","function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"},embed:{path:"/embeddings",dialect:"openai-embeddings"},transcribe:{path:"/audio/transcriptions",dialect:"openai-transcription"},speak:{path:"/audio/speech",dialect:"mistral-speech"}},request:{renameFields:{max_completion_tokens:"max_tokens"},imageURLShape:"object"},modelRules:[],sources:["https://docs.mistral.ai/api/"],reviewedAt:"2026-08-17"},cohere:{id:"cohere",name:"Cohere",aliases:["cohere"],transport:"openai-chat",baseURL:"https://api.cohere.ai/compatibility/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:"command-r-plus",embedModel:"embed-english-v3.0"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"},embed:{path:"/embeddings",dialect:"openai-embeddings"}},modelRules:[],sources:["https://docs.cohere.com/reference/compatibility-api"],reviewedAt:"2026-08-17"},grok:{id:"grok",name:"xAI Grok",aliases:["grok","xai","x-grok","x_grok"],transport:"openai-chat",baseURL:"https://api.x.ai/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:"grok-4.6"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!0,thinking:!1,multiTurn:!0,images:!0,audio:!0,audioOutput:!0,webSearch:!0,structuredOutputModes:["native","function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"},transcribe:{path:"/stt",dialect:"xai-transcription"},speak:{path:"/tts",dialect:"xai-speech"},realtime:{path:"/realtime",dialect:"xai-realtime",modelMatch:{prefix:["grok-voice"]},url:"wss://api.x.ai/v1/realtime",grammar:"openai_realtime_compatible",defaultModel:"grok-voice-think-fast-1.0",audio:{input:{formats:["pcm16","pcm"],sampleRate:24e3},output:{formats:["pcm16","pcm"],sampleRate:24e3,voices:["eve","ara","rex","sal","leo"],defaultVoice:"eve"}},validation:{structuredOutputWithAudio:!1}}},request:{optionDialect:"search-parameters"},modelRules:[{match:{exact:["grok-4.6"]},capabilities:{thinking:!0,thinkingBudget:!0,structuredOutputs:!0,structuredOutputModes:["native","function"]},request:{reasoning:"effort",defaultThinkingLevel:"max",effortMap:{none:null,minimal:"low",low:"low",medium:"medium",high:"high",highest:"xhigh",xhigh:"xhigh",max:"xhigh"},unsupportedThinkingLevels:{none:"xAI Grok 4.6 reasoning cannot be disabled"},dropFields:["presence_penalty","frequency_penalty","stop"]}},{match:{exact:["grok-4.5","grok-4.5-latest","grok-build-latest"]},capabilities:{thinking:!0,thinkingBudget:!0,structuredOutputs:!0,structuredOutputModes:["native","function"]},request:{reasoning:"effort",defaultThinkingLevel:"max",effortMap:{none:null,minimal:"low",low:"low",medium:"medium",high:"high",highest:"high",xhigh:"high",max:"high"},unsupportedThinkingLevels:{none:"xAI Grok 4.5 reasoning cannot be disabled"},dropFields:["presence_penalty","frequency_penalty","stop"]}},{match:{exact:["grok-4.3","grok-4.3-latest","grok-latest"]},capabilities:{thinking:!0,thinkingBudget:!0,showThoughts:!0,structuredOutputs:!0,structuredOutputModes:["native","function"]},request:{reasoning:"effort",defaultThinkingLevel:"max",effortMap:{none:"none",minimal:"low",low:"low",medium:"medium",high:"high",highest:"high",xhigh:"high",max:"high"},dropFields:["presence_penalty","frequency_penalty","stop"]}}],sources:["https://docs.x.ai/developers/model-capabilities/text/reasoning","https://docs.x.ai/developers/models/grok-4.5"],reviewedAt:"2026-08-18"},reka:{id:"reka",name:"Reka",aliases:["reka"],transport:"openai-chat",baseURL:"https://api.reka.ai/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:"reka-core"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.reka.ai/"],reviewedAt:"2026-08-17"},together:{id:"together",name:"Together AI",aliases:["together","together-ai","together_ai"],transport:"openai-chat",baseURL:"https://api.together.xyz/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"},embed:{path:"/embeddings",dialect:"openai-embeddings"}},modelRules:[{match:{prefix:["deepseek-ai/DeepSeek-V4"]},capabilities:{thinking:!0,thinkingBudget:!0,showThoughts:!0,structuredOutputs:!1,structuredOutputModes:["function"]},request:{reasoning:"effort",toolChoice:"unforced",effortMap:{none:null,minimal:"high",low:"high",medium:"high",high:"max",highest:"max",xhigh:"max",max:"max"},defaultThinkingLevel:"max"},response:{reasoningFields:["reasoning","reasoning_content"]},replay:{assistantReasoningField:"reasoning"}}],sources:["https://docs.together.ai/docs/inference/chat/reasoning"],reviewedAt:"2026-08-18"},openrouter:{id:"openrouter",name:"OpenRouter",aliases:["openrouter"],transport:"openai-chat",baseURL:"https://openrouter.ai/api/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[{match:{prefix:["deepseek/"]},capabilities:{thinking:!0,thinkingBudget:!0,showThoughts:!0,structuredOutputs:!1,structuredOutputModes:["function"]},request:{reasoning:"openrouter",toolChoice:"unforced",effortMap:{none:"none",minimal:"low",low:"low",medium:"medium",high:"high",highest:"max",xhigh:"xhigh",max:"max"},defaultThinkingLevel:"max"},response:{reasoningFields:["reasoning","reasoning_content"],reasoningDetailsFields:["reasoning_details"]},replay:{assistantReasoningField:"reasoning",assistantReasoningDetailsField:"reasoning_details"}}],sources:["https://openrouter.ai/docs/guides/best-practices/reasoning-tokens"],reviewedAt:"2026-08-18"},fireworks:{id:"fireworks",name:"Fireworks AI",aliases:["fireworks","fireworks-ai"],transport:"openai-chat",baseURL:"https://api.fireworks.ai/inference/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!0,thinking:!1,multiTurn:!0,structuredOutputModes:["native","function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"},embed:{path:"/embeddings",dialect:"openai-embeddings"}},modelRules:[{match:{contains:["deepseek-v4"]},capabilities:{thinking:!0,thinkingBudget:!0,showThoughts:!0,structuredOutputs:!1,structuredOutputModes:["function"]},request:{reasoning:"effort",toolChoice:"unforced",effortMap:{none:"none",minimal:"high",low:"high",medium:"high",high:"high",highest:"max",xhigh:"max",max:"max"},defaultThinkingLevel:"max"},response:{reasoningFields:["reasoning_content","reasoning"]},replay:{assistantReasoningField:"reasoning_content"}}],sources:["https://docs.fireworks.ai/api-reference/post-chatcompletions","https://docs.fireworks.ai/guides/reasoning"],reviewedAt:"2026-08-18"},"huggingface-router":{id:"huggingface-router",name:"Hugging Face Router",aliases:["huggingface-router","huggingface","hf-router"],transport:"openai-chat",baseURL:"https://router.huggingface.co/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://huggingface.co/docs/inference-providers/en/index","https://huggingface.co/docs/inference-providers/en/tasks/chat-completion"],reviewedAt:"2026-08-18"},"amazon-bedrock":{id:"amazon-bedrock",name:"Amazon Bedrock",aliases:["amazon-bedrock","bedrock"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.aws.amazon.com/bedrock/latest/userguide/inference-chat-completions-mantle.html"],reviewedAt:"2026-08-17"},"azure-foundry":{id:"azure-foundry",name:"Azure AI Foundry",aliases:["azure-foundry","azure-ai-foundry","microsoft-foundry"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"api-key-header",header:"api-key",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://learn.microsoft.com/en-us/rest/api/microsoft-foundry/azureopenai/chat"],reviewedAt:"2026-08-17"},"vertex-ai":{id:"vertex-ai",name:"Vertex AI OpenAI Compatibility",aliases:["vertex-ai","vertex-openai"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[{match:{exact:["google/gemma-4-26b-a4b-it-maas"]},capabilities:{structuredOutputs:!1,structuredOutputModes:["json_object","function"],thinking:!0},request:{defaultThinkingLevel:"max",thinkingBoolean:{path:["chat_template_kwargs","enable_thinking"]}},response:{reasoningFields:["reasoning_content"]},replay:{assistantReasoningField:"reasoning_content"}},{match:{prefix:["google/gemini-","gemini-"]},capabilities:{structuredOutputs:!0,structuredOutputModes:["native","function","json_object"]}}],sources:["https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/call-vertex-using-openai-library","https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/maas/capabilities/structured-output","https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/maas/capabilities/thinking"],reviewedAt:"2026-08-18"},databricks:{id:"databricks",name:"Databricks Model Serving",aliases:["databricks"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.databricks.com/aws/en/machine-learning/model-serving/query-chat-models"],reviewedAt:"2026-08-17"},baseten:{id:"baseten",name:"Baseten Model APIs",aliases:["baseten"],transport:"openai-chat",baseURL:"https://inference.baseten.co/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!0,thinking:!1,multiTurn:!0,structuredOutputModes:["native","function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.baseten.co/inference/model-apis/overview"],reviewedAt:"2026-08-17"},groq:{id:"groq",name:"Groq",aliases:["groq"],transport:"openai-chat",baseURL:"https://api.groq.com/openai/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!0,thinking:!1,multiTurn:!0,structuredOutputModes:["native","function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[{match:{exact:["openai/gpt-oss-20b","openai/gpt-oss-120b"]},capabilities:{thinking:!0,thinkingBudget:!0},request:{reasoning:"effort",defaultThinkingLevel:"max",effortMap:{none:null,minimal:"low",low:"low",medium:"medium",high:"high",highest:"high",xhigh:"high",max:"high"},unsupportedThinkingLevels:{none:"Groq GPT-OSS reasoning does not support the none effort level"}}},{match:{exact:["qwen/qwen3.6-27b"]},capabilities:{thinking:!0,thinkingBudget:!0},request:{reasoning:"effort",defaultThinkingLevel:"max",effortMap:{none:"none",minimal:"default",low:"default",medium:"default",high:"default",highest:"default",xhigh:"default",max:"default"}}}],sources:["https://console.groq.com/docs/reasoning","https://console.groq.com/docs/api-reference"],reviewedAt:"2026-08-18"},cerebras:{id:"cerebras",name:"Cerebras Inference",aliases:["cerebras"],transport:"openai-chat",baseURL:"https://api.cerebras.ai/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!0,thinking:!1,multiTurn:!0,structuredOutputModes:["native","function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[{match:{exact:["gpt-oss-120b"]},capabilities:{thinking:!0,thinkingBudget:!0},request:{reasoning:"effort",defaultThinkingLevel:"max",effortMap:{none:null,minimal:"low",low:"low",medium:"medium",high:"high",highest:"high",xhigh:"high",max:"high"},unsupportedThinkingLevels:{none:"Cerebras GPT-OSS reasoning does not support the none effort level"}}},{match:{exact:["gemma-4-31b"]},capabilities:{thinking:!0,thinkingBudget:!0},request:{reasoning:"effort",defaultThinkingLevel:"max",effortMap:{none:"none",minimal:"high",low:"high",medium:"high",high:"high",highest:"high",xhigh:"high",max:"high"}}}],sources:["https://inference-docs.cerebras.ai/capabilities/reasoning","https://inference-docs.cerebras.ai/api-reference/chat-completions"],reviewedAt:"2026-08-18"},deepinfra:{id:"deepinfra",name:"DeepInfra",aliases:["deepinfra"],transport:"openai-chat",baseURL:"https://api.deepinfra.com/v1/openai",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[{match:{prefix:["deepseek-ai/DeepSeek-R1"]},capabilities:{thinking:!0,thinkingBudget:!0},request:{reasoning:"effort",defaultThinkingLevel:"max",effortMap:{none:"none",minimal:"low",low:"low",medium:"medium",high:"high",highest:"high",xhigh:"high",max:"high"}}}],sources:["https://docs.deepinfra.com/chat/reasoning","https://docs.deepinfra.com/api-reference/introduction"],reviewedAt:"2026-08-18"},sambanova:{id:"sambanova",name:"SambaNova Cloud",aliases:["sambanova","sambanova-cloud"],transport:"openai-chat",baseURL:"https://api.sambanova.ai/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.sambanova.ai/docs/en/api-reference/overview"],reviewedAt:"2026-08-17"},nebius:{id:"nebius",name:"Nebius AI Studio",aliases:["nebius"],transport:"openai-chat",baseURL:"https://api.tokenfactory.nebius.com/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://api.studio.nebius.com/docs"],reviewedAt:"2026-08-17"},novita:{id:"novita",name:"Novita AI",aliases:["novita","novita-ai"],transport:"openai-chat",baseURL:"https://api.novita.ai/v3/openai",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://novita.ai/docs/guides/llm-api"],reviewedAt:"2026-08-17"},hyperbolic:{id:"hyperbolic",name:"Hyperbolic",aliases:["hyperbolic"],transport:"openai-chat",baseURL:"https://api.hyperbolic.xyz/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.hyperbolic.xyz/docs/inference-api"],reviewedAt:"2026-08-17"},siliconflow:{id:"siliconflow",name:"SiliconFlow",aliases:["siliconflow"],transport:"openai-chat",baseURL:"https://api.siliconflow.com/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.siliconflow.com/en/userguide/quickstart"],reviewedAt:"2026-08-17"},friendli:{id:"friendli",name:"FriendliAI",aliases:["friendli","friendli-ai"],transport:"openai-chat",baseURL:"https://api.friendli.ai/serverless/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://friendli.ai/docs/guides/tool-calling"],reviewedAt:"2026-08-17"},"cloudflare-workers-ai":{id:"cloudflare-workers-ai",name:"Cloudflare Workers AI",aliases:["cloudflare-workers-ai","workers-ai"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/"],reviewedAt:"2026-08-17"},featherless:{id:"featherless",name:"Featherless AI",aliases:["featherless","featherless-ai"],transport:"openai-chat",baseURL:"https://api.featherless.ai/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://featherless.ai/docs/quickstart-guide"],reviewedAt:"2026-08-17"},nscale:{id:"nscale",name:"Nscale",aliases:["nscale"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.nscale.com/docs/use-cases/chat"],reviewedAt:"2026-08-17"},ovhcloud:{id:"ovhcloud",name:"OVHcloud AI Endpoints",aliases:["ovhcloud","ovh"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.ovhcloud.com/en/guides/public-cloud/ai-machine-learning/ai-endpoints-capabilities"],reviewedAt:"2026-08-17"},scaleway:{id:"scaleway",name:"Scaleway Generative APIs",aliases:["scaleway"],transport:"openai-chat",baseURL:"https://api.scaleway.ai/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://www.scaleway.com/en/developers/api/generative-apis"],reviewedAt:"2026-08-17"},"nvidia-nim":{id:"nvidia-nim",name:"NVIDIA NIM",aliases:["nvidia-nim","nim"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!1},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.nvidia.com/nim/large-language-models/latest/getting-started.html"],reviewedAt:"2026-08-17"},"runpod-vllm":{id:"runpod-vllm",name:"RunPod vLLM",aliases:["runpod-vllm","runpod"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.runpod.io/serverless/vllm/openai-compatibility"],reviewedAt:"2026-08-17"},"sagemaker-vllm":{id:"sagemaker-vllm",name:"SageMaker vLLM",aliases:["sagemaker-vllm","sagemaker"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!1},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.aws.amazon.com/sagemaker/latest/dg/realtime-endpoints-openai-compatible.html"],reviewedAt:"2026-08-17"},vllm:{id:"vllm",name:"vLLM",aliases:["vllm"],transport:"openai-chat",baseURL:"http://localhost:8000/v1",requiresApiURL:!1,auth:{type:"bearer",required:!1},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.vllm.ai/en/latest/serving/openai_compatible_server/"],reviewedAt:"2026-08-17"},ollama:{id:"ollama",name:"Ollama",aliases:["ollama"],transport:"openai-chat",baseURL:"http://localhost:11434/v1",requiresApiURL:!1,auth:{type:"bearer",required:!1},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.ollama.com/api/openai-compatibility"],reviewedAt:"2026-08-17"},"lm-studio":{id:"lm-studio",name:"LM Studio",aliases:["lm-studio","lmstudio"],transport:"openai-chat",baseURL:"http://localhost:1234/v1",requiresApiURL:!1,auth:{type:"bearer",required:!1},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://lmstudio.ai/docs/developer/openai-compat"],reviewedAt:"2026-08-17"},"llama-cpp":{id:"llama-cpp",name:"llama.cpp Server",aliases:["llama-cpp","llama.cpp"],transport:"openai-chat",baseURL:"http://localhost:8080/v1",requiresApiURL:!1,auth:{type:"bearer",required:!1},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md"],reviewedAt:"2026-08-17"},localai:{id:"localai",name:"LocalAI",aliases:["localai","local-ai"],transport:"openai-chat",baseURL:"http://localhost:8080/v1",requiresApiURL:!1,auth:{type:"bearer",required:!1},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://localai.io/features/openai-functions/"],reviewedAt:"2026-08-17"},"baseten-engine":{id:"baseten-engine",name:"Baseten Inference Engine",aliases:["baseten-engine","truss"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!1},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.baseten.co/development/model/deployment/inference"],reviewedAt:"2026-08-17"}},Qc={openai:"openai","openai-compatible":"openai-compatible",openai_compatible:"openai-compatible",compatible:"openai-compatible","openai-responses":"openai-responses",openai_responses:"openai-responses",responses:"openai-responses",anthropic:"anthropic",claude:"anthropic","google-gemini":"google-gemini",google_gemini:"google-gemini",gemini:"google-gemini",webllm:"webllm","azure-openai":"azure-openai",azure_openai:"azure-openai",azure:"azure-openai",deepseek:"deepseek","deepseek-responses":"deepseek-responses",deepseek_responses:"deepseek-responses",mistral:"mistral",cohere:"cohere",grok:"grok",xai:"grok","x-grok":"grok",x_grok:"grok",reka:"reka",together:"together","together-ai":"together",together_ai:"together",openrouter:"openrouter",fireworks:"fireworks","fireworks-ai":"fireworks","huggingface-router":"huggingface-router",huggingface:"huggingface-router","hf-router":"huggingface-router","amazon-bedrock":"amazon-bedrock",bedrock:"amazon-bedrock","azure-foundry":"azure-foundry","azure-ai-foundry":"azure-foundry","microsoft-foundry":"azure-foundry","vertex-ai":"vertex-ai","vertex-openai":"vertex-ai",databricks:"databricks",baseten:"baseten",groq:"groq",cerebras:"cerebras",deepinfra:"deepinfra",sambanova:"sambanova","sambanova-cloud":"sambanova",nebius:"nebius",novita:"novita","novita-ai":"novita",hyperbolic:"hyperbolic",siliconflow:"siliconflow",friendli:"friendli","friendli-ai":"friendli","cloudflare-workers-ai":"cloudflare-workers-ai","workers-ai":"cloudflare-workers-ai",featherless:"featherless","featherless-ai":"featherless",nscale:"nscale",ovhcloud:"ovhcloud",ovh:"ovhcloud",scaleway:"scaleway","nvidia-nim":"nvidia-nim",nim:"nvidia-nim","runpod-vllm":"runpod-vllm",runpod:"runpod-vllm","sagemaker-vllm":"sagemaker-vllm",sagemaker:"sagemaker-vllm",vllm:"vllm",ollama:"ollama","lm-studio":"lm-studio",lmstudio:"lm-studio","llama-cpp":"llama-cpp","llama.cpp":"llama-cpp",localai:"localai","local-ai":"localai","baseten-engine":"baseten-engine",truss:"baseten-engine"},ws=["openai","openai-compatible","openai-responses","anthropic","google-gemini","webllm","azure-openai","deepseek","deepseek-responses","mistral","cohere","grok","reka","together","openrouter","fireworks","huggingface-router","amazon-bedrock","azure-foundry","vertex-ai","databricks","baseten","groq","cerebras","deepinfra","sambanova","nebius","novita","hyperbolic","siliconflow","friendli","cloudflare-workers-ai","featherless","nscale","ovhcloud","scaleway","nvidia-nim","runpod-vllm","sagemaker-vllm","vllm","ollama","lm-studio","llama-cpp","localai","baseten-engine"];var Vo=(R=>(R.Grok46="grok-4.6",R.Grok45="grok-4.5",R.Grok45Latest="grok-4.5-latest",R.GrokBuildLatest="grok-build-latest",R.Grok43="grok-4.3",R.Grok43Latest="grok-4.3-latest",R.GrokLatest="grok-latest",R.Grok420Reasoning="grok-4.20-reasoning",R.Grok420Reasoning0309="grok-4.20-0309-reasoning",R.Grok420NonReasoning="grok-4.20-non-reasoning",R.Grok420NonReasoning0309="grok-4.20-0309-non-reasoning",R.Grok420MultiAgent="grok-4.20-multi-agent",R.Grok420MultiAgent0309="grok-4.20-multi-agent-0309",R.Grok41FastReasoning="grok-4-1-fast-reasoning",R.Grok41FastNonReasoning="grok-4-1-fast-non-reasoning",R.GrokVoiceThinkFast="grok-voice-think-fast-1.0",R.GrokVoiceFast="grok-voice-fast-1.0",R.Grok3="grok-3",R.Grok3Mini="grok-3-mini",R.Grok3Fast="grok-3-fast",R.Grok3MiniFast="grok-3-mini-fast",R))(Vo||{}),Wp=(e=>(e.GrokEmbedSmall="grok-embed-small",e))(Wp||{});var zb=()=>({input:{format:"pcm16",mimeType:"audio/pcm",sampleRate:24e3,channels:1},output:{enabled:!0,voice:"eve",format:"pcm16",mimeType:"audio/pcm",sampleRate:24e3,channels:1,includeTranscript:!0},live:{turnTimeoutMs:3e4}}),Kp=()=>structuredClone({model:"grok-4.6",...Qe()}),Vb=()=>structuredClone({...Kp(),model:"grok-4.6"}),Hb=()=>structuredClone({...Qe(),model:"grok-voice-think-fast-1.0",audio:zb(),stream:!1}),Jp=r=>r==="grok-voice-think-fast-1.0"||r==="grok-voice-fast-1.0"||r.startsWith("grok-voice-"),Ss=(r,e)=>At(At(zb(),r),e),Zc=(r,e,t)=>Jp(r)&&Bt(Ss(e,t)),Xc=r=>Bo({...r,apiName:"grok-realtime-audio",providerName:"Grok Realtime",wsURL:e=>`wss://api.x.ai/v1/realtime?model=${encodeURIComponent(e)}`,createSessionUpdate:({request:e,audio:t})=>{let n=e.messages.filter(s=>s.role==="system").map(s=>s.content).join(`
|
|
1264
|
+
`)};function Kc(r){let e=[];for(let t of r??[])if(t?.type==="output_text"&&Array.isArray(t.annotations))for(let n of t.annotations)n&&n.type==="url_citation"&&typeof n.url=="string"&&e.push({url:n.url,title:n.title,description:n.description});return e.length?e:void 0}var vs=()=>({model:"gpt-4o",embedModel:"text-embedding-ada-002",temperature:.7,topP:1,stream:!0}),Bb=()=>({...vs(),model:"gpt-4o",temperature:.5}),qb=()=>({...vs(),model:"gpt-4o",temperature:.9}),Lr=class extends vt{constructor({apiKey:e,credentialProvider:t,credentialProfile:n,config:o,options:i,apiURL:s,modelInfo:a=[],models:c,responsesReqUpdater:l,supportFor:u={functions:!0,streaming:!0,media:{images:{supported:!1,formats:[]},audio:{supported:!1,formats:[]},files:{supported:!1,formats:[],uploadMethod:"none"},urls:{supported:!1,webSearch:!1,contextFetching:!1}},caching:{supported:!1,types:[]},thinking:!1,multiTurn:!0}}){if((!e||e==="")&&!t)throw new Error("OpenAI API key not set");let d=new Jc(o,i?.streamingUsage??!0,l),p=c?.map(m=>{let g=m,h=g?.config;if(!h)return m;let x={};h.maxTokens!==void 0&&(x.maxTokens=h.maxTokens),h.temperature!==void 0&&(x.temperature=h.temperature),h.topP!==void 0&&(x.topP=h.topP),h.presencePenalty!==void 0&&(x.presencePenalty=h.presencePenalty),h.frequencyPenalty!==void 0&&(x.frequencyPenalty=h.frequencyPenalty);let f=h.stopSequences??h.stop;f!==void 0&&(x.stopSequences=f),h.n!==void 0&&(x.n=h.n),h.stream!==void 0&&(x.stream=h.stream);let y={...g};Object.keys(x).length>0&&(y.modelConfig={...g.modelConfig??{},...x});let b=h?.thinking?.thinkingTokenBudget;if(typeof b=="number"){let A=[["minimal",200],["low",800],["medium",5e3],["high",1e4],["highest",24500]],R="minimal",w=Number.POSITIVE_INFINITY;for(let[N,k]of A){let E=Math.abs(b-k);E<w&&(w=E,R=N)}y.thinkingTokenBudget=R}return h?.thinking?.includeThoughts!==void 0&&(y.showThoughts=!!h.thinking.includeThoughts),y});super(d,{name:"OpenAI",apiURL:s||"https://api.openai.com/v1",headers:async()=>e?{Authorization:`Bearer ${e}`}:{},profile:n,credentialProvider:t,modelInfo:a,defaults:{model:o.model??"gpt-4o",embedModel:o.embedModel??"text-embedding-ada-002"},options:i,supportFor:u,models:p??c}),this.setChatCredentialOperation("responses")}},zo=class extends Lr{constructor({apiKey:e,credentialProvider:t,config:n,options:o,models:i,modelInfo:s}){if((!e||e==="")&&!t)throw new Error("OpenAI API key not set");s=[...Go,...s??[]];let a=c=>{let l=Gt({model:c,modelInfo:s,models:i}),u=l?.supported?.structuredOutputs??!0,d=l?.supported?.structuredOutputModes??(u?["native","function","json_object"]:["function","json_object"]);return{functions:!0,streaming:!0,hasThinkingBudget:l?.supported?.thinkingBudget??!1,hasShowThoughts:l?.supported?.showThoughts??!1,structuredOutputs:d.includes("native"),structuredOutputModes:d,media:{images:{supported:!1,formats:[]},audio:{supported:!1,formats:[]},files:{supported:!1,formats:[],uploadMethod:"none"},urls:{supported:!1,webSearch:!1,contextFetching:!1}},caching:{supported:!1,types:[]},thinking:!1,multiTurn:!0}};super({apiKey:e,credentialProvider:t,credentialProfile:"openai-responses",config:{...vs(),...n},options:o,modelInfo:s,models:i,supportFor:a})}};var Yc={openai:{id:"openai",name:"OpenAI",aliases:["openai"],transport:"openai-chat",baseURL:"https://api.openai.com/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:"gpt-5-mini",embedModel:"text-embedding-3-small"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!0,thinking:!0,multiTurn:!0,images:!0,audio:!0,audioOutput:!0,structuredOutputModes:["native","function","json_object"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"},embed:{path:"/embeddings",dialect:"openai-embeddings"},transcribe:{path:"/audio/transcriptions",dialect:"openai-transcription"},speak:{path:"/audio/speech",dialect:"openai-speech"},realtime:{path:"/realtime",dialect:"openai-realtime",modelMatch:{prefix:["gpt-realtime"]},url:"wss://api.openai.com/v1/realtime",grammar:"openai_realtime_compatible",audio:{input:{formats:["pcm16","pcm"],sampleRate:24e3},output:{formats:["pcm16","pcm"],sampleRate:24e3,voices:["alloy","ash","ballad","coral","echo","sage","shimmer","verse"],defaultVoice:"alloy"}},validation:{structuredOutputWithAudio:!1}}},modelRules:[],sources:["https://platform.openai.com/docs/api-reference/chat"],reviewedAt:"2026-08-17"},"openai-compatible":{id:"openai-compatible",name:"OpenAI Compatible",aliases:["openai-compatible","openai_compatible","compatible"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!1},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"},embed:{path:"/embeddings",dialect:"openai-embeddings"}},modelRules:[],sources:["https://platform.openai.com/docs/api-reference/chat"],reviewedAt:"2026-08-17"},"openai-responses":{id:"openai-responses",name:"OpenAI Responses",aliases:["openai-responses","openai_responses","responses"],transport:"openai-responses",baseURL:"https://api.openai.com/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:"gpt-5-mini",embedModel:"text-embedding-3-small"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!0,thinking:!0,multiTurn:!0,images:!0,audio:!0,audioOutput:!0,structuredOutputModes:["native","function","json_object"]},operations:{chat:{path:"/responses",dialect:"openai-responses"},embed:{path:"/embeddings",dialect:"openai-embeddings"},transcribe:{path:"/audio/transcriptions",dialect:"openai-transcription"},speak:{path:"/audio/speech",dialect:"openai-speech"},realtime:{path:"/realtime",dialect:"openai-realtime",modelMatch:{prefix:["gpt-realtime"]},url:"wss://api.openai.com/v1/realtime",grammar:"openai_realtime_compatible",audio:{input:{formats:["pcm16","pcm"],sampleRate:24e3},output:{formats:["pcm16","pcm"],sampleRate:24e3,voices:["alloy","ash","ballad","coral","echo","sage","shimmer","verse"],defaultVoice:"alloy"}},validation:{structuredOutputWithAudio:!1}}},modelRules:[],sources:["https://platform.openai.com/docs/api-reference/responses"],reviewedAt:"2026-08-17"},anthropic:{id:"anthropic",name:"Anthropic",aliases:["anthropic","claude"],transport:"anthropic-messages",baseURL:"https://api.anthropic.com",requiresApiURL:!1,auth:{type:"x-api-key",required:!0},headers:{"anthropic-version":"2023-06-01","anthropic-beta":"structured-outputs-2025-11-13, web-search-2025-03-05"},defaults:{model:"claude-sonnet-4-5"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!0,multiTurn:!0,images:!0,caching:{types:["ephemeral"],cacheBreakpoints:!0},structuredOutputModes:["function"]},operations:{chat:{path:"/v1/messages",dialect:"anthropic-messages"}},modelRules:[],sources:["https://docs.anthropic.com/en/api/messages"],reviewedAt:"2026-08-17"},"google-gemini":{id:"google-gemini",name:"Google Gemini",aliases:["google-gemini","google_gemini","gemini"],transport:"gemini-generate-content",baseURL:"https://generativelanguage.googleapis.com/v1beta",requiresApiURL:!1,auth:{type:"api-key-query",required:!0},defaults:{model:"gemini-3.5-flash",embedModel:"gemini-embedding-2"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!0,thinking:!0,multiTurn:!0,images:!0,audio:!0,audioOutput:!0,files:{uploadMethod:"cloud"},caching:{types:["persistent"]},structuredOutputModes:["native","function"]},operations:{chat:{path:"/models/{model}:generateContent",dialect:"gemini-generate-content"},stream_chat:{path:"/models/{model}:streamGenerateContent?alt=sse",dialect:"gemini-generate-content"},embed:{path:"/models/{model}:batchEmbedContents",dialect:"gemini-generate-content"},transcribe:{path:"/models/{model}:generateContent",dialect:"gemini-generate-content"},speak:{path:"/models/{model}:generateContent",dialect:"gemini-generate-content"},realtime:{path:"/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent",dialect:"gemini-live-bidi",modelMatch:{prefix:["gemini-live"],contains:["native-audio","-live-"]},url:"wss://generativelanguage.googleapis.com/ws/google.ai.generativelanguage.v1beta.GenerativeService.BidiGenerateContent",grammar:"gemini_live_bidi",defaultModel:"gemini-2.5-flash-native-audio-preview-12-2025",audio:{input:{formats:["pcm16","pcm"],sampleRate:16e3},output:{formats:["pcm16","pcm"],sampleRate:24e3,voices:["Kore","Puck","Charon","Fenrir","Aoede"],defaultVoice:"Kore"}},validation:{pcmInputOnly:!0,rejectStructuredOutputWithAudio:!0}}},modelRules:[],sources:["https://ai.google.dev/api/generate-content"],reviewedAt:"2026-08-17"},webllm:{id:"webllm",name:"WebLLM",aliases:["webllm"],transport:"webllm",baseURL:null,requiresApiURL:!1,auth:{type:"none",required:!1},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"",dialect:"webllm"}},modelRules:[],sources:["https://webllm.mlc.ai/docs/"],reviewedAt:"2026-08-17"},"azure-openai":{id:"azure-openai",name:"Azure OpenAI",aliases:["azure-openai","azure_openai","azure"],transport:"openai-chat",baseURL:null,requiresApiURL:!1,auth:{type:"api-key-header",header:"api-key",required:!0},defaults:{model:"gpt-5-mini",embedModel:"text-embedding-3-small"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!0,thinking:!0,multiTurn:!0,images:!0,structuredOutputModes:["native","function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"},embed:{path:"/embeddings",dialect:"openai-embeddings"}},endpoint:{scheme:"https",hostField:"resourceName",hostSuffix:".openai.azure.com",path:"/openai/deployments/{deploymentName}",fields:{resourceName:["resource_name","resourceName"],deploymentName:["deployment_name","deploymentName"],version:["api_version","apiVersion","version"]},required:["resourceName","deploymentName"],defaults:{version:"2024-02-15-preview"},normalizers:{version:"api-version"},apiVersionField:"version"},capabilityGates:{structuredOutputs:{option:"version",min:"2024-08-01"}},modelRules:[],sources:["https://learn.microsoft.com/en-us/azure/ai-services/openai/reference"],reviewedAt:"2026-08-17"},deepseek:{id:"deepseek",name:"DeepSeek",aliases:["deepseek"],transport:"openai-chat",baseURL:"https://api.deepseek.com",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:"deepseek-v4-flash"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function","json_object"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[{match:{exact:["deepseek-v4-flash","deepseek-v4-pro"]},capabilities:{thinking:!0,thinkingBudget:!0,showThoughts:!0,structuredOutputs:!1,structuredOutputModes:["function"]},request:{reasoning:"thinking-object",toolChoice:"unforced",effortMap:{none:null,minimal:"low",low:"low",medium:"high",high:"high",highest:"max",xhigh:"max",max:"max"},dropWhenThinking:["temperature","top_p","presence_penalty","frequency_penalty"],defaultThinkingLevel:"max"},response:{reasoningFields:["reasoning_content","reasoning"]},replay:{assistantReasoningField:"reasoning_content"}},{match:{exact:["deepseek-reasoner"]},capabilities:{thinking:!0,thinkingBudget:!1,showThoughts:!0,structuredOutputs:!1,structuredOutputModes:["function"]},request:{toolChoice:"unforced"},response:{reasoningFields:["reasoning_content","reasoning"]},replay:{assistantReasoningField:"reasoning_content"}}],sources:["https://api-docs.deepseek.com/guides/thinking_mode/"],reviewedAt:"2026-08-18"},"deepseek-responses":{id:"deepseek-responses",name:"DeepSeek Responses",aliases:["deepseek-responses","deepseek_responses"],transport:"openai-responses",baseURL:"https://api.deepseek.com",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:"deepseek-v4-flash"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!0,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/responses",dialect:"openai-responses"}},request:{dropFields:["include","previous_response_id","store","parallel_tool_calls"],reasoningObjectFields:["effort"]},modelRules:[],sources:["https://api-docs.deepseek.com/api/create-chat-completion"],reviewedAt:"2026-08-17"},mistral:{id:"mistral",name:"Mistral AI",aliases:["mistral"],transport:"openai-chat",baseURL:"https://api.mistral.ai/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:"mistral-small-latest",embedModel:"mistral-embed"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!0,thinking:!1,multiTurn:!0,images:!0,audio:!0,audioOutput:!0,structuredOutputModes:["native","function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"},embed:{path:"/embeddings",dialect:"openai-embeddings"},transcribe:{path:"/audio/transcriptions",dialect:"openai-transcription"},speak:{path:"/audio/speech",dialect:"mistral-speech"}},request:{renameFields:{max_completion_tokens:"max_tokens"},imageURLShape:"object"},modelRules:[],sources:["https://docs.mistral.ai/api/"],reviewedAt:"2026-08-17"},cohere:{id:"cohere",name:"Cohere",aliases:["cohere"],transport:"openai-chat",baseURL:"https://api.cohere.ai/compatibility/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:"command-r-plus",embedModel:"embed-english-v3.0"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"},embed:{path:"/embeddings",dialect:"openai-embeddings"}},modelRules:[],sources:["https://docs.cohere.com/reference/compatibility-api"],reviewedAt:"2026-08-17"},grok:{id:"grok",name:"xAI Grok",aliases:["grok","xai","x-grok","x_grok"],transport:"openai-chat",baseURL:"https://api.x.ai/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:"grok-4.6"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!0,thinking:!1,multiTurn:!0,images:!0,audio:!0,audioOutput:!0,webSearch:!0,structuredOutputModes:["native","function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"},transcribe:{path:"/stt",dialect:"xai-transcription"},speak:{path:"/tts",dialect:"xai-speech"},realtime:{path:"/realtime",dialect:"xai-realtime",modelMatch:{prefix:["grok-voice"]},url:"wss://api.x.ai/v1/realtime",grammar:"openai_realtime_compatible",defaultModel:"grok-voice-think-fast-1.0",audio:{input:{formats:["pcm16","pcm"],sampleRate:24e3},output:{formats:["pcm16","pcm"],sampleRate:24e3,voices:["eve","ara","rex","sal","leo"],defaultVoice:"eve"}},validation:{structuredOutputWithAudio:!1}}},request:{optionDialect:"search-parameters"},modelRules:[{match:{exact:["grok-4.6"]},capabilities:{thinking:!0,thinkingBudget:!0,structuredOutputs:!0,structuredOutputModes:["native","function"]},request:{reasoning:"effort",defaultThinkingLevel:"max",effortMap:{none:null,minimal:"low",low:"low",medium:"medium",high:"high",highest:"xhigh",xhigh:"xhigh",max:"xhigh"},unsupportedThinkingLevels:{none:"xAI Grok 4.6 reasoning cannot be disabled"},dropFields:["presence_penalty","frequency_penalty","stop"]}},{match:{exact:["grok-4.5","grok-4.5-latest","grok-build-latest"]},capabilities:{thinking:!0,thinkingBudget:!0,structuredOutputs:!0,structuredOutputModes:["native","function"]},request:{reasoning:"effort",defaultThinkingLevel:"max",effortMap:{none:null,minimal:"low",low:"low",medium:"medium",high:"high",highest:"high",xhigh:"high",max:"high"},unsupportedThinkingLevels:{none:"xAI Grok 4.5 reasoning cannot be disabled"},dropFields:["presence_penalty","frequency_penalty","stop"]}},{match:{exact:["grok-4.3","grok-4.3-latest","grok-latest"]},capabilities:{thinking:!0,thinkingBudget:!0,showThoughts:!0,structuredOutputs:!0,structuredOutputModes:["native","function"]},request:{reasoning:"effort",defaultThinkingLevel:"max",effortMap:{none:"none",minimal:"low",low:"low",medium:"medium",high:"high",highest:"high",xhigh:"high",max:"high"},dropFields:["presence_penalty","frequency_penalty","stop"]}}],sources:["https://docs.x.ai/developers/model-capabilities/text/reasoning","https://docs.x.ai/developers/models/grok-4.5"],reviewedAt:"2026-08-18"},reka:{id:"reka",name:"Reka",aliases:["reka"],transport:"openai-chat",baseURL:"https://api.reka.ai/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:"reka-core"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.reka.ai/"],reviewedAt:"2026-08-17"},together:{id:"together",name:"Together AI",aliases:["together","together-ai","together_ai"],transport:"openai-chat",baseURL:"https://api.together.xyz/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!0,thinking:!1,multiTurn:!0,structuredOutputModes:["native","function","json_object"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"},embed:{path:"/embeddings",dialect:"openai-embeddings"}},modelRules:[{match:{prefix:["deepseek-ai/DeepSeek-V4"]},capabilities:{thinking:!0,thinkingBudget:!0,showThoughts:!0,structuredOutputs:!1,structuredOutputModes:["function"]},request:{reasoning:"effort",toolChoice:"unforced",effortMap:{none:null,minimal:"high",low:"high",medium:"high",high:"max",highest:"max",xhigh:"max",max:"max"},defaultThinkingLevel:"max"},response:{reasoningFields:["reasoning","reasoning_content"]},replay:{assistantReasoningField:"reasoning"}}],sources:["https://docs.together.ai/docs/inference/chat/reasoning"],reviewedAt:"2026-08-18"},openrouter:{id:"openrouter",name:"OpenRouter",aliases:["openrouter"],transport:"openai-chat",baseURL:"https://openrouter.ai/api/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[{match:{prefix:["deepseek/"]},capabilities:{thinking:!0,thinkingBudget:!0,showThoughts:!0,structuredOutputs:!1,structuredOutputModes:["function"]},request:{reasoning:"openrouter",toolChoice:"unforced",effortMap:{none:"none",minimal:"low",low:"low",medium:"medium",high:"high",highest:"max",xhigh:"xhigh",max:"max"},defaultThinkingLevel:"max"},response:{reasoningFields:["reasoning","reasoning_content"],reasoningDetailsFields:["reasoning_details"]},replay:{assistantReasoningField:"reasoning",assistantReasoningDetailsField:"reasoning_details"}}],sources:["https://openrouter.ai/docs/guides/best-practices/reasoning-tokens"],reviewedAt:"2026-08-18"},orcarouter:{id:"orcarouter",name:"OrcaRouter",aliases:["orcarouter"],transport:"openai-chat",baseURL:"https://api.orcarouter.ai/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:"orcarouter/auto"},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://www.orcarouter.ai"],reviewedAt:"2026-08-19"},fireworks:{id:"fireworks",name:"Fireworks AI",aliases:["fireworks","fireworks-ai"],transport:"openai-chat",baseURL:"https://api.fireworks.ai/inference/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!0,thinking:!1,multiTurn:!0,structuredOutputModes:["native","function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"},embed:{path:"/embeddings",dialect:"openai-embeddings"}},modelRules:[{match:{contains:["deepseek-v4"]},capabilities:{thinking:!0,thinkingBudget:!0,showThoughts:!0,structuredOutputs:!1,structuredOutputModes:["function"]},request:{reasoning:"effort",toolChoice:"unforced",effortMap:{none:"none",minimal:"high",low:"high",medium:"high",high:"high",highest:"max",xhigh:"max",max:"max"},defaultThinkingLevel:"max"},response:{reasoningFields:["reasoning_content","reasoning"]},replay:{assistantReasoningField:"reasoning_content"}}],sources:["https://docs.fireworks.ai/api-reference/post-chatcompletions","https://docs.fireworks.ai/guides/reasoning"],reviewedAt:"2026-08-18"},"huggingface-router":{id:"huggingface-router",name:"Hugging Face Router",aliases:["huggingface-router","huggingface","hf-router"],transport:"openai-chat",baseURL:"https://router.huggingface.co/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://huggingface.co/docs/inference-providers/en/index","https://huggingface.co/docs/inference-providers/en/tasks/chat-completion"],reviewedAt:"2026-08-18"},"amazon-bedrock":{id:"amazon-bedrock",name:"Amazon Bedrock",aliases:["amazon-bedrock","bedrock"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.aws.amazon.com/bedrock/latest/userguide/inference-chat-completions-mantle.html"],reviewedAt:"2026-08-17"},"azure-foundry":{id:"azure-foundry",name:"Azure AI Foundry",aliases:["azure-foundry","azure-ai-foundry","microsoft-foundry"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"api-key-header",header:"api-key",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://learn.microsoft.com/en-us/rest/api/microsoft-foundry/azureopenai/chat"],reviewedAt:"2026-08-17"},"vertex-ai":{id:"vertex-ai",name:"Vertex AI OpenAI Compatibility",aliases:["vertex-ai","vertex-openai"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[{match:{exact:["google/gemma-4-26b-a4b-it-maas"]},capabilities:{structuredOutputs:!1,structuredOutputModes:["json_object","function"],thinking:!0},request:{defaultThinkingLevel:"max",thinkingBoolean:{path:["chat_template_kwargs","enable_thinking"]}},response:{reasoningFields:["reasoning_content"]},replay:{assistantReasoningField:"reasoning_content"}},{match:{prefix:["google/gemini-","gemini-"]},capabilities:{structuredOutputs:!0,structuredOutputModes:["native","function","json_object"]}}],sources:["https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/call-vertex-using-openai-library","https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/maas/capabilities/structured-output","https://docs.cloud.google.com/gemini-enterprise-agent-platform/models/maas/capabilities/thinking"],reviewedAt:"2026-08-18"},databricks:{id:"databricks",name:"Databricks Model Serving",aliases:["databricks"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.databricks.com/aws/en/machine-learning/model-serving/query-chat-models"],reviewedAt:"2026-08-17"},baseten:{id:"baseten",name:"Baseten Model APIs",aliases:["baseten"],transport:"openai-chat",baseURL:"https://inference.baseten.co/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!0,thinking:!1,multiTurn:!0,structuredOutputModes:["native","function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.baseten.co/inference/model-apis/overview"],reviewedAt:"2026-08-17"},groq:{id:"groq",name:"Groq",aliases:["groq"],transport:"openai-chat",baseURL:"https://api.groq.com/openai/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!0,thinking:!1,multiTurn:!0,structuredOutputModes:["native","function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[{match:{exact:["openai/gpt-oss-20b","openai/gpt-oss-120b"]},capabilities:{thinking:!0,thinkingBudget:!0},request:{reasoning:"effort",defaultThinkingLevel:"max",effortMap:{none:null,minimal:"low",low:"low",medium:"medium",high:"high",highest:"high",xhigh:"high",max:"high"},unsupportedThinkingLevels:{none:"Groq GPT-OSS reasoning does not support the none effort level"}}},{match:{exact:["qwen/qwen3.6-27b"]},capabilities:{thinking:!0,thinkingBudget:!0},request:{reasoning:"effort",defaultThinkingLevel:"max",effortMap:{none:"none",minimal:"default",low:"default",medium:"default",high:"default",highest:"default",xhigh:"default",max:"default"}}}],sources:["https://console.groq.com/docs/reasoning","https://console.groq.com/docs/api-reference"],reviewedAt:"2026-08-18"},cerebras:{id:"cerebras",name:"Cerebras Inference",aliases:["cerebras"],transport:"openai-chat",baseURL:"https://api.cerebras.ai/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!0,thinking:!1,multiTurn:!0,structuredOutputModes:["native","function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[{match:{exact:["gpt-oss-120b"]},capabilities:{thinking:!0,thinkingBudget:!0},request:{reasoning:"effort",defaultThinkingLevel:"max",effortMap:{none:null,minimal:"low",low:"low",medium:"medium",high:"high",highest:"high",xhigh:"high",max:"high"},unsupportedThinkingLevels:{none:"Cerebras GPT-OSS reasoning does not support the none effort level"}}},{match:{exact:["gemma-4-31b"]},capabilities:{thinking:!0,thinkingBudget:!0},request:{reasoning:"effort",defaultThinkingLevel:"max",effortMap:{none:"none",minimal:"high",low:"high",medium:"high",high:"high",highest:"high",xhigh:"high",max:"high"}}}],sources:["https://inference-docs.cerebras.ai/capabilities/reasoning","https://inference-docs.cerebras.ai/api-reference/chat-completions"],reviewedAt:"2026-08-18"},deepinfra:{id:"deepinfra",name:"DeepInfra",aliases:["deepinfra"],transport:"openai-chat",baseURL:"https://api.deepinfra.com/v1/openai",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[{match:{prefix:["deepseek-ai/DeepSeek-R1"]},capabilities:{thinking:!0,thinkingBudget:!0},request:{reasoning:"effort",defaultThinkingLevel:"max",effortMap:{none:"none",minimal:"low",low:"low",medium:"medium",high:"high",highest:"high",xhigh:"high",max:"high"}}}],sources:["https://docs.deepinfra.com/chat/reasoning","https://docs.deepinfra.com/api-reference/introduction"],reviewedAt:"2026-08-18"},sambanova:{id:"sambanova",name:"SambaNova Cloud",aliases:["sambanova","sambanova-cloud"],transport:"openai-chat",baseURL:"https://api.sambanova.ai/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.sambanova.ai/docs/en/api-reference/overview"],reviewedAt:"2026-08-17"},nebius:{id:"nebius",name:"Nebius AI Studio",aliases:["nebius"],transport:"openai-chat",baseURL:"https://api.tokenfactory.nebius.com/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://api.studio.nebius.com/docs"],reviewedAt:"2026-08-17"},novita:{id:"novita",name:"Novita AI",aliases:["novita","novita-ai"],transport:"openai-chat",baseURL:"https://api.novita.ai/v3/openai",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://novita.ai/docs/guides/llm-api"],reviewedAt:"2026-08-17"},hyperbolic:{id:"hyperbolic",name:"Hyperbolic",aliases:["hyperbolic"],transport:"openai-chat",baseURL:"https://api.hyperbolic.xyz/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.hyperbolic.xyz/docs/inference-api"],reviewedAt:"2026-08-17"},siliconflow:{id:"siliconflow",name:"SiliconFlow",aliases:["siliconflow"],transport:"openai-chat",baseURL:"https://api.siliconflow.com/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.siliconflow.com/en/userguide/quickstart"],reviewedAt:"2026-08-17"},friendli:{id:"friendli",name:"FriendliAI",aliases:["friendli","friendli-ai"],transport:"openai-chat",baseURL:"https://api.friendli.ai/serverless/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://friendli.ai/docs/guides/tool-calling"],reviewedAt:"2026-08-17"},"cloudflare-workers-ai":{id:"cloudflare-workers-ai",name:"Cloudflare Workers AI",aliases:["cloudflare-workers-ai","workers-ai"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/"],reviewedAt:"2026-08-17"},featherless:{id:"featherless",name:"Featherless AI",aliases:["featherless","featherless-ai"],transport:"openai-chat",baseURL:"https://api.featherless.ai/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://featherless.ai/docs/quickstart-guide"],reviewedAt:"2026-08-17"},nscale:{id:"nscale",name:"Nscale",aliases:["nscale"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.nscale.com/docs/use-cases/chat"],reviewedAt:"2026-08-17"},ovhcloud:{id:"ovhcloud",name:"OVHcloud AI Endpoints",aliases:["ovhcloud","ovh"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.ovhcloud.com/en/guides/public-cloud/ai-machine-learning/ai-endpoints-capabilities"],reviewedAt:"2026-08-17"},scaleway:{id:"scaleway",name:"Scaleway Generative APIs",aliases:["scaleway"],transport:"openai-chat",baseURL:"https://api.scaleway.ai/v1",requiresApiURL:!1,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://www.scaleway.com/en/developers/api/generative-apis"],reviewedAt:"2026-08-17"},"nvidia-nim":{id:"nvidia-nim",name:"NVIDIA NIM",aliases:["nvidia-nim","nim"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!1},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.nvidia.com/nim/large-language-models/latest/getting-started.html"],reviewedAt:"2026-08-17"},"runpod-vllm":{id:"runpod-vllm",name:"RunPod vLLM",aliases:["runpod-vllm","runpod"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!0},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.runpod.io/serverless/vllm/openai-compatibility"],reviewedAt:"2026-08-17"},"sagemaker-vllm":{id:"sagemaker-vllm",name:"SageMaker vLLM",aliases:["sagemaker-vllm","sagemaker"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!1},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.aws.amazon.com/sagemaker/latest/dg/realtime-endpoints-openai-compatible.html"],reviewedAt:"2026-08-17"},vllm:{id:"vllm",name:"vLLM",aliases:["vllm"],transport:"openai-chat",baseURL:"http://localhost:8000/v1",requiresApiURL:!1,auth:{type:"bearer",required:!1},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.vllm.ai/en/latest/serving/openai_compatible_server/"],reviewedAt:"2026-08-17"},ollama:{id:"ollama",name:"Ollama",aliases:["ollama"],transport:"openai-chat",baseURL:"http://localhost:11434/v1",requiresApiURL:!1,auth:{type:"bearer",required:!1},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.ollama.com/api/openai-compatibility"],reviewedAt:"2026-08-17"},"lm-studio":{id:"lm-studio",name:"LM Studio",aliases:["lm-studio","lmstudio"],transport:"openai-chat",baseURL:"http://localhost:1234/v1",requiresApiURL:!1,auth:{type:"bearer",required:!1},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://lmstudio.ai/docs/developer/openai-compat"],reviewedAt:"2026-08-17"},"llama-cpp":{id:"llama-cpp",name:"llama.cpp Server",aliases:["llama-cpp","llama.cpp"],transport:"openai-chat",baseURL:"http://localhost:8080/v1",requiresApiURL:!1,auth:{type:"bearer",required:!1},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://github.com/ggml-org/llama.cpp/blob/master/tools/server/README.md"],reviewedAt:"2026-08-17"},localai:{id:"localai",name:"LocalAI",aliases:["localai","local-ai"],transport:"openai-chat",baseURL:"http://localhost:8080/v1",requiresApiURL:!1,auth:{type:"bearer",required:!1},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://localai.io/features/openai-functions/"],reviewedAt:"2026-08-17"},"baseten-engine":{id:"baseten-engine",name:"Baseten Inference Engine",aliases:["baseten-engine","truss"],transport:"openai-chat",baseURL:null,requiresApiURL:!0,auth:{type:"bearer",required:!1},defaults:{model:""},capabilities:{functions:!0,streaming:!0,structuredOutputs:!1,thinking:!1,multiTurn:!0,structuredOutputModes:["function"]},operations:{chat:{path:"/chat/completions",dialect:"openai-chat"}},modelRules:[],sources:["https://docs.baseten.co/development/model/deployment/inference"],reviewedAt:"2026-08-17"}},Qc={openai:"openai","openai-compatible":"openai-compatible",openai_compatible:"openai-compatible",compatible:"openai-compatible","openai-responses":"openai-responses",openai_responses:"openai-responses",responses:"openai-responses",anthropic:"anthropic",claude:"anthropic","google-gemini":"google-gemini",google_gemini:"google-gemini",gemini:"google-gemini",webllm:"webllm","azure-openai":"azure-openai",azure_openai:"azure-openai",azure:"azure-openai",deepseek:"deepseek","deepseek-responses":"deepseek-responses",deepseek_responses:"deepseek-responses",mistral:"mistral",cohere:"cohere",grok:"grok",xai:"grok","x-grok":"grok",x_grok:"grok",reka:"reka",together:"together","together-ai":"together",together_ai:"together",openrouter:"openrouter",orcarouter:"orcarouter",fireworks:"fireworks","fireworks-ai":"fireworks","huggingface-router":"huggingface-router",huggingface:"huggingface-router","hf-router":"huggingface-router","amazon-bedrock":"amazon-bedrock",bedrock:"amazon-bedrock","azure-foundry":"azure-foundry","azure-ai-foundry":"azure-foundry","microsoft-foundry":"azure-foundry","vertex-ai":"vertex-ai","vertex-openai":"vertex-ai",databricks:"databricks",baseten:"baseten",groq:"groq",cerebras:"cerebras",deepinfra:"deepinfra",sambanova:"sambanova","sambanova-cloud":"sambanova",nebius:"nebius",novita:"novita","novita-ai":"novita",hyperbolic:"hyperbolic",siliconflow:"siliconflow",friendli:"friendli","friendli-ai":"friendli","cloudflare-workers-ai":"cloudflare-workers-ai","workers-ai":"cloudflare-workers-ai",featherless:"featherless","featherless-ai":"featherless",nscale:"nscale",ovhcloud:"ovhcloud",ovh:"ovhcloud",scaleway:"scaleway","nvidia-nim":"nvidia-nim",nim:"nvidia-nim","runpod-vllm":"runpod-vllm",runpod:"runpod-vllm","sagemaker-vllm":"sagemaker-vllm",sagemaker:"sagemaker-vllm",vllm:"vllm",ollama:"ollama","lm-studio":"lm-studio",lmstudio:"lm-studio","llama-cpp":"llama-cpp","llama.cpp":"llama-cpp",localai:"localai","local-ai":"localai","baseten-engine":"baseten-engine",truss:"baseten-engine"},ws=["openai","openai-compatible","openai-responses","anthropic","google-gemini","webllm","azure-openai","deepseek","deepseek-responses","mistral","cohere","grok","reka","together","openrouter","orcarouter","fireworks","huggingface-router","amazon-bedrock","azure-foundry","vertex-ai","databricks","baseten","groq","cerebras","deepinfra","sambanova","nebius","novita","hyperbolic","siliconflow","friendli","cloudflare-workers-ai","featherless","nscale","ovhcloud","scaleway","nvidia-nim","runpod-vllm","sagemaker-vllm","vllm","ollama","lm-studio","llama-cpp","localai","baseten-engine"];var Vo=(R=>(R.Grok46="grok-4.6",R.Grok45="grok-4.5",R.Grok45Latest="grok-4.5-latest",R.GrokBuildLatest="grok-build-latest",R.Grok43="grok-4.3",R.Grok43Latest="grok-4.3-latest",R.GrokLatest="grok-latest",R.Grok420Reasoning="grok-4.20-reasoning",R.Grok420Reasoning0309="grok-4.20-0309-reasoning",R.Grok420NonReasoning="grok-4.20-non-reasoning",R.Grok420NonReasoning0309="grok-4.20-0309-non-reasoning",R.Grok420MultiAgent="grok-4.20-multi-agent",R.Grok420MultiAgent0309="grok-4.20-multi-agent-0309",R.Grok41FastReasoning="grok-4-1-fast-reasoning",R.Grok41FastNonReasoning="grok-4-1-fast-non-reasoning",R.GrokVoiceThinkFast="grok-voice-think-fast-1.0",R.GrokVoiceFast="grok-voice-fast-1.0",R.Grok3="grok-3",R.Grok3Mini="grok-3-mini",R.Grok3Fast="grok-3-fast",R.Grok3MiniFast="grok-3-mini-fast",R))(Vo||{}),Wp=(e=>(e.GrokEmbedSmall="grok-embed-small",e))(Wp||{});var zb=()=>({input:{format:"pcm16",mimeType:"audio/pcm",sampleRate:24e3,channels:1},output:{enabled:!0,voice:"eve",format:"pcm16",mimeType:"audio/pcm",sampleRate:24e3,channels:1,includeTranscript:!0},live:{turnTimeoutMs:3e4}}),Kp=()=>structuredClone({model:"grok-4.6",...Qe()}),Vb=()=>structuredClone({...Kp(),model:"grok-4.6"}),Hb=()=>structuredClone({...Qe(),model:"grok-voice-think-fast-1.0",audio:zb(),stream:!1}),Jp=r=>r==="grok-voice-think-fast-1.0"||r==="grok-voice-fast-1.0"||r.startsWith("grok-voice-"),Ss=(r,e)=>At(At(zb(),r),e),Zc=(r,e,t)=>Jp(r)&&Bt(Ss(e,t)),Xc=r=>Bo({...r,apiName:"grok-realtime-audio",providerName:"Grok Realtime",wsURL:e=>`wss://api.x.ai/v1/realtime?model=${encodeURIComponent(e)}`,createSessionUpdate:({request:e,audio:t})=>{let n=e.messages.filter(s=>s.role==="system").map(s=>s.content).join(`
|
|
1265
1265
|
`),o=t.input,i=t.output;return{type:"session.update",session:{voice:typeof i?.voice=="object"?i.voice.id:i?.voice??"eve",...n?{instructions:n}:{},turn_detection:null,audio:{input:{format:{type:"audio/pcm",rate:o?.sampleRate??24e3}},output:{format:{type:"audio/pcm",rate:i?.sampleRate??24e3}}}}}}});var Wb=Yc,TP=Qc,ks=()=>ws.map(r=>{let e=Wb[r];return{id:r,name:e.name,aliases:e.aliases,transport:e.transport,...e.baseURL?{baseURL:e.baseURL}:{},requiresApiURL:e.requiresApiURL,...e.endpoint?{endpoint:e.endpoint}:{},...e.defaults.model?{defaultModel:e.defaults.model}:{},...e.defaults.embedModel?{defaultEmbedModel:e.defaults.embedModel}:{},authentication:e.auth,operations:e.operations,modelRules:e.modelRules,capabilities:e.capabilities,sources:e.sources,reviewedAt:e.reviewedAt}}),el=r=>{let e=tl(r);return ks().find(t=>t.id===e.id)},Zp=r=>{let e=TP[r.toLowerCase()];if(!e)throw new Error(`Unknown AI profile "${r}". Use one of: ${ws.join(", ")}`);return e},tl=r=>Wb[Zp(r)],PP=(r,e)=>(e.match.exact?.includes(r)??!1)||(e.match.prefix?.some(t=>r.startsWith(t))??!1)||(e.match.contains?.some(t=>r.toLowerCase().includes(t.toLowerCase()))??!1),Kb=(r,e)=>r.modelRules.find(t=>PP(e,t)),IP=r=>({images:{supported:r.images??!1,formats:r.images?["image/jpeg","image/png"]:[]},audio:{supported:r.audio??!1,formats:r.audio?["wav","mp3","pcm16"]:[],output:{supported:r.audioOutput??!1,formats:r.audioOutput?["wav","mp3","pcm16"]:[]}},files:r.files?{supported:!0,formats:["application/pdf","text/plain"],uploadMethod:r.files.uploadMethod}:{supported:!1,formats:[],uploadMethod:"none"},urls:{supported:!1,webSearch:r.webSearch??!1,contextFetching:!1}}),Ts=(r,e)=>{let t=tl(r),n=Kb(t,e),o={...t.capabilities,...n?.capabilities};return{functions:o.functions,streaming:o.streaming,structuredOutputs:o.structuredOutputs,structuredOutputModes:o.structuredOutputModes,hasThinkingBudget:o.thinkingBudget??o.thinking??!1,hasShowThoughts:o.showThoughts??o.thinking??!1,media:IP(o),caching:o.caching?{supported:!0,types:[...o.caching.types],cacheBreakpoints:o.caching.cacheBreakpoints}:{supported:!1,types:[]},thinking:o.thinking,multiTurn:o.multiTurn}},MP=r=>{let e=r.modelRules.flatMap(i=>i.response?.reasoningFields??[]),t=r.modelRules.flatMap(i=>i.response?.reasoningDetailsFields??[]),n=r.modelRules.find(i=>i.replay?.assistantReasoningField)?.replay?.assistantReasoningField,o=r.modelRules.find(i=>i.replay?.assistantReasoningDetailsField)?.replay?.assistantReasoningDetailsField;return!n&&!o&&e.length===0&&t.length===0?"none":{...n||e[0]?{assistantField:n??e[0]}:{},responseFields:[...new Set(e)],...o?{assistantDetailsField:o}:{},responseDetailsFields:[...new Set(t)]}},EP=r=>{let e=r.messages;if(Array.isArray(e))for(let t of e){if(!t||typeof t!="object")continue;let n=t.content;if(Array.isArray(n))for(let o of n){if(!o||typeof o!="object")continue;let i=o;if(i.type!=="image_url")continue;let s=i.image_url;typeof s=="string"?i.image_url={url:s}:s&&typeof s=="object"&&(i.image_url={url:s.url})}}},Yp=r=>Array.isArray(r)?r.map(Yp):!r||typeof r!="object"?r:Object.fromEntries(Object.entries(r).map(([e,t])=>[e.replace(/[A-Z]/g,n=>`_${n.toLowerCase()}`),Yp(t)])),Qp=(r,e,t)=>{if(!e)return;let o=t.thinkingTokenBudget??(typeof r.reasoning_effort=="string"?r.reasoning_effort:e.defaultThinkingLevel),i=o?e.unsupportedThinkingLevels?.[o]:void 0;if(i)throw new Error(i);let s=o?e.effortMap?.[o]:void 0;o&&e.effortMap&&(s===null?delete r.reasoning_effort:s!==void 0&&(r.reasoning_effort=s));let a=o!==void 0&&o!=="none"&&(s!==null||!e.effortMap),c=o!==void 0&&s!==null;if(e.thinkingBoolean){let l=r,u=e.thinkingBoolean.path;for(let d of u.slice(0,-1)){let p=l[d],m=p&&typeof p=="object"&&!Array.isArray(p)?{...p}:{};l[d]=m,l=m}l[u[u.length-1]]=o!=="none"}if(e.reasoning==="thinking-object"?r.thinking={type:a?"enabled":"disabled"}:e.reasoning==="openrouter"&&(c&&typeof r.reasoning_effort=="string"&&(r.reasoning={effort:r.reasoning_effort}),delete r.reasoning_effort),e.toolChoice==="unforced"){let l=r.tool_choice,u=l&&typeof l=="object"?l.function?.name:void 0,d=t.functionCallSource==="ax"&&u==="__axOutput";if(l==="required"||l!==void 0&&l!=="auto"&&l!=="none"&&!d)throw new Error("This deployment profile does not support explicitly forced tool choices");l==="none"&&delete r.tools,delete r.tool_choice}if(a)for(let l of e.dropWhenThinking??[])delete r[l];for(let l of e.dropFields??[])delete r[l];for(let[l,u]of Object.entries(e.copyFields??{}))r[l]!==void 0&&(r[u]=r[l]);for(let[l,u]of Object.entries(e.renameFields??{}))r[l]!==void 0&&(r[u]=r[l],delete r[l]);for(let[l,u]of Object.entries(e.enumMaps??{})){let d=r[l];typeof d=="string"&&d in u&&(r[l]=u[d])}for(let[l,u]of Object.entries(e.constructObjects??{})){let d=Object.fromEntries(Object.entries(u).filter(([,p])=>r[p]!==void 0).map(([p,m])=>[p,r[m]]));Object.keys(d).length>0&&(r[l]=d)}if(e.imageURLShape==="object"&&EP(r),e.optionDialect==="search-parameters"){let l=t.searchParameters??t.search_parameters;l!==void 0&&(r.search_parameters=Yp(l))}},Xp=(r,e,t)=>{let n=t?.find(s=>s.name===e||s.aliases?.includes(e))?.supported;if(!n)return r;let o=n.thinkingBudget!==void 0||n.showThoughts!==void 0,i=r.structuredOutputModes;if(n.structuredOutputModes!==void 0)i=[...n.structuredOutputModes];else if(n.structuredOutputs!==void 0){let s=(i??[]).filter(a=>a!=="native");i=n.structuredOutputs?["native",...s]:s}return{...r,hasThinkingBudget:n.thinkingBudget??r.hasThinkingBudget??!1,hasShowThoughts:n.showThoughts??r.hasShowThoughts??!1,structuredOutputs:i?i.includes("native"):n.structuredOutputs??r.structuredOutputs??!1,...i?{structuredOutputModes:i}:{},thinking:o?!!(n.thinkingBudget||n.showThoughts):r.thinking}},OP=(r,e,t,n,o)=>{let i={...e},s=String(e.model),a=Kb(r,s),c=Xp(em(r,Ts(r.id,s),o),s,n);if(t.thinkingTokenBudget&&t.thinkingTokenBudget!=="none"&&!c.thinking)throw new Error(`Thinking is not verified for profile ${r.id} and model ${s}; add an exact modelInfo override to opt in`);let l=i.response_format;if(l?.type==="json_schema"&&!c.structuredOutputs)throw new Error(`Structured output is not verified for profile ${r.id} and model ${s}: native JSON Schema is unsupported`);if(l?.type==="json_object"&&!c.structuredOutputModes?.includes("json_object"))throw new Error(`Structured output is not verified for profile ${r.id} and model ${s}: JSON object mode is unsupported`);return Qp(i,r.request,t),Qp(i,a?.request,t),i},Jb=(r,e)=>{if(typeof e.apiURL=="string"&&e.apiURL.length>0)return e.apiURL;if(r.endpoint){let t={...r.endpoint.defaults};for(let[a,c]of Object.entries(r.endpoint.fields??{}))for(let l of c)e[l]!==void 0&&e[l]!==""&&(t[a]=e[l]);for(let a of r.endpoint.required)if(t[a]===void 0||t[a]==="")throw new Error(`${r.name} endpoint field ${a} is required`);let n=String(t[r.endpoint.hostField]),o=n.includes("://")?n.replace(/\/$/,""):`${r.endpoint.scheme??"https"}://${n}${r.endpoint.hostSuffix}`,i=r.endpoint.path;for(let[a,c]of Object.entries(t)){let l=String(c);r.endpoint.normalizers?.[a]==="api-version"&&(l=new URLSearchParams(l.includes("api-version=")?l:"").get("api-version")??l),i=i.replaceAll(`{${a}}`,encodeURIComponent(l)),t[a]=l}let s=new URL(`${o}${i}`);if(r.endpoint.apiVersionField){let a=r.endpoint.apiVersionField,c=r.endpoint.normalizers?.[a],l=t[a];c&&l!==void 0&&l!==""&&s.searchParams.set(c,String(l))}return s.toString().replace(/\/$/,"")}if(r.baseURL)return r.baseURL;throw new Error(`${r.name} requires apiURL`)},em=(r,e,t)=>{let n=r.capabilityGates?.structuredOutputs;if(!n)return e;let s=(String(t[n.option]??"").match(/\d{4}-\d{2}-\d{2}/)?.[0]??"")>=n.min,a=(e.structuredOutputModes??[]).filter(c=>c!=="native");return{...e,structuredOutputs:s,structuredOutputModes:s?["native",...a]:a}},Yb=(r,e,t)=>{if(r.auth.required&&!e&&!t)throw new Error(`${r.name} API key not set`);return e??""},FP=r=>r?.map(e=>{let t=e;return t.config?{...e,modelConfig:{...t.config,...t.modelConfig}}:e}),Qb=(r,e)=>!e||r.auth.type==="none"?{}:r.auth.type==="api-key-header"?{[r.auth.header??"api-key"]:e}:r.auth.type==="x-api-key"?{"x-api-key":e}:{Authorization:`Bearer ${e}`},Ho=class extends _r{profileSpec;profileApiURL;constructor(e){let t=tl(e.name);if(t.transport!=="openai-chat")throw new Error(`${t.id} is not an OpenAI Chat profile`);let n=Yb(t,e.apiKey,e.credentialProvider),o=Jb(t,e),i={model:t.defaults.model,...t.defaults.embedModel?{embedModel:t.defaults.embedModel}:{},...Qe(),...e.config},a=t.operations.realtime?.dialect==="xai-realtime"?{apiName:`${t.name} Realtime`,shouldUse:Zc,resolveAudioConfig:Ss,createApi:Xc}:void 0;super({apiKey:n||"local-no-key",credentialProvider:e.credentialProvider,credentialProfile:t.id,apiURL:o,config:i,options:e.options,modelInfo:e.modelInfo??[],models:FP(e.models),supportFor:c=>Xp(em(t,Ts(t.id,c),e),c,e.modelInfo),reasoningContentMode:MP(t),realtime:a,chatReqUpdater:(c,l)=>OP(t,c,{...e.options??{},...l},e.modelInfo,e)}),this.setName(t.name),this.setHeaders(async()=>Qb(t,n)),this.profileSpec=t,this.profileApiURL=o}async transcribe(e,t){let n=this.profileSpec.operations.transcribe;if(!n)throw new Error(`Transcription is not supported by profile ${this.profileSpec.id}`);let o=this.getOptions(),i=typeof e.model=="string"?e.model:void 0,s=n.dialect==="xai-transcription"?{language:e.language,keyterm:e.prompt,format:!0}:{model:i,language:e.language,prompt:e.prompt,temperature:e.temperature,response_format:e.responseFormat??"json"};return await $o({url:`${this.profileApiURL.replace(/\/$/,"")}${n.path}`,headers:await this.buildHeaders({},{operation:"transcribe",method:"POST",url:`${this.profileApiURL.replace(/\/$/,"")}${n.path}`}),audio:e.audio,fields:s,fetch:t?.fetch??o.fetch,abortSignal:t?.abortSignal??o.abortSignal})}async speak(e,t){let n=this.profileSpec.operations.speak;if(!n)throw new Error(`Speech is not supported by profile ${this.profileSpec.id}`);let o=this.getOptions(),i=e.format??"mp3",s=typeof e.model=="string"?e.model:void 0,a=typeof e.voice=="object"?e.voice.id:e.voice,c;if(n.dialect==="xai-speech"){let l=i==="pcm16"||i==="raw"?"pcm":i==="ulaw"?"mulaw":i;c={text:e.text,voice_id:a??"eve",language:e.language??"auto",output_format:{codec:l,...e.sampleRate?{sample_rate:e.sampleRate}:{}},...e.speed!==void 0?{speed:e.speed}:{}}}else n.dialect==="mistral-speech"?c={model:s??"voxtral-mini-tts-2603",input:e.text,response_format:i,...a?{voice_id:a}:{}}:c={model:s,input:e.text,voice:a??"alloy",response_format:i==="pcm"?"pcm16":i,...e.speed!==void 0?{speed:e.speed}:{}};return await er({url:`${this.profileApiURL.replace(/\/$/,"")}${n.path}`,headers:await this.buildHeaders({},{operation:"speak",method:"POST",url:`${this.profileApiURL.replace(/\/$/,"")}${n.path}`}),body:c,format:i,transcript:e.text,fetch:t?.fetch??o.fetch,abortSignal:t?.abortSignal??o.abortSignal})}},Wo=class extends Lr{constructor(e){let t=tl(e.name);if(t.transport!=="openai-responses")throw new Error(`${t.id} is not an OpenAI Responses profile`);let n=Yb(t,e.apiKey,e.credentialProvider),o=Jb(t,e),i={model:t.defaults.model,...t.defaults.embedModel?{embedModel:t.defaults.embedModel}:{},stream:!0,...e.config};super({apiKey:n||"local-no-key",credentialProvider:e.credentialProvider,credentialProfile:t.id,apiURL:o,config:i,options:e.options,modelInfo:e.modelInfo??[],models:e.models,supportFor:s=>Xp(em(t,Ts(t.id,s),e),s,e.modelInfo),responsesReqUpdater:s=>{let a={...s};if(Qp(a,t.request,e.options??{}),t.request?.reasoningObjectFields&&a.reasoning){let c=a.reasoning;a.reasoning=Object.fromEntries(t.request.reasoningObjectFields.filter(l=>c[l]!==void 0).map(l=>[l,c[l]]))}return a}}),this.setName(t.name),this.setHeaders(async()=>Qb(t,n))}};var Ps=(n=>(n.RekaCore="reka-core",n.RekaFlash="reka-flash",n.RekaEdge="reka-edge",n))(Ps||{});var nl=[{name:"reka-core",currency:"usd",promptTokenCostPer1M:3,completionTokenCostPer1M:15},{name:"reka-flash",currency:"usd",promptTokenCostPer1M:.8,completionTokenCostPer1M:2},{name:"reka-edge",currency:"usd",promptTokenCostPer1M:.4,completionTokenCostPer1M:1}];var Ko=(p=>(p.Llama31_8B_Instruct="Llama-3.1-8B-Instruct-q4f32_1-MLC",p.Llama31_70B_Instruct="Llama-3.1-70B-Instruct-q4f16_1-MLC",p.Llama32_1B_Instruct="Llama-3.2-1B-Instruct-q4f32_1-MLC",p.Llama32_3B_Instruct="Llama-3.2-3B-Instruct-q4f32_1-MLC",p.Mistral7B_Instruct="Mistral-7B-Instruct-v0.3-q4f32_1-MLC",p.Phi35_Mini_Instruct="Phi-3.5-mini-instruct-q4f32_1-MLC",p.Gemma2_2B_Instruct="gemma-2-2b-it-q4f32_1-MLC",p.Gemma2_9B_Instruct="gemma-2-9b-it-q4f32_1-MLC",p.Qwen2_5_0_5B_Instruct="Qwen2.5-0.5B-Instruct-q4f32_1-MLC",p.Qwen2_5_1_5B_Instruct="Qwen2.5-1.5B-Instruct-q4f32_1-MLC",p.Qwen2_5_3B_Instruct="Qwen2.5-3B-Instruct-q4f32_1-MLC",p.Qwen2_5_7B_Instruct="Qwen2.5-7B-Instruct-q4f32_1-MLC",p))(Ko||{});var Jo=[{name:"Llama-3.1-8B-Instruct-q4f32_1-MLC",currency:"usd",promptTokenCostPer1M:0,completionTokenCostPer1M:0,contextWindow:128e3,maxTokens:4096},{name:"Llama-3.1-70B-Instruct-q4f16_1-MLC",currency:"usd",promptTokenCostPer1M:0,completionTokenCostPer1M:0,contextWindow:128e3,maxTokens:4096,isExpensive:!0},{name:"Llama-3.2-1B-Instruct-q4f32_1-MLC",currency:"usd",promptTokenCostPer1M:0,completionTokenCostPer1M:0,contextWindow:128e3,maxTokens:2048},{name:"Llama-3.2-3B-Instruct-q4f32_1-MLC",currency:"usd",promptTokenCostPer1M:0,completionTokenCostPer1M:0,contextWindow:128e3,maxTokens:2048},{name:"Mistral-7B-Instruct-v0.3-q4f32_1-MLC",currency:"usd",promptTokenCostPer1M:0,completionTokenCostPer1M:0,contextWindow:32768,maxTokens:4096},{name:"Phi-3.5-mini-instruct-q4f32_1-MLC",currency:"usd",promptTokenCostPer1M:0,completionTokenCostPer1M:0,contextWindow:128e3,maxTokens:4096},{name:"gemma-2-2b-it-q4f32_1-MLC",currency:"usd",promptTokenCostPer1M:0,completionTokenCostPer1M:0,contextWindow:8192,maxTokens:2048},{name:"gemma-2-9b-it-q4f32_1-MLC",currency:"usd",promptTokenCostPer1M:0,completionTokenCostPer1M:0,contextWindow:8192,maxTokens:2048},{name:"Qwen2.5-0.5B-Instruct-q4f32_1-MLC",currency:"usd",promptTokenCostPer1M:0,completionTokenCostPer1M:0,contextWindow:32768,maxTokens:2048},{name:"Qwen2.5-1.5B-Instruct-q4f32_1-MLC",currency:"usd",promptTokenCostPer1M:0,completionTokenCostPer1M:0,contextWindow:32768,maxTokens:2048},{name:"Qwen2.5-3B-Instruct-q4f32_1-MLC",currency:"usd",promptTokenCostPer1M:0,completionTokenCostPer1M:0,contextWindow:32768,maxTokens:2048},{name:"Qwen2.5-7B-Instruct-q4f32_1-MLC",currency:"usd",promptTokenCostPer1M:0,completionTokenCostPer1M:0,contextWindow:32768,maxTokens:4096}];var rl=[{name:"grok-4.6",currency:"USD",supported:{thinkingBudget:!0,structuredOutputs:!0}},{name:"grok-4.5",currency:"USD",promptTokenCostPer1M:2,cacheReadTokenCostPer1M:.3,completionTokenCostPer1M:6,contextWindow:5e5,aliases:["grok-4.5-latest","grok-build-latest"],supported:{thinkingBudget:!0,structuredOutputs:!0}},{name:"grok-4.3",currency:"USD",promptTokenCostPer1M:1.25,cacheReadTokenCostPer1M:.2,completionTokenCostPer1M:2.5,contextWindow:1e6,aliases:["grok-4.3-latest","grok-latest"],supported:{thinkingBudget:!0,structuredOutputs:!0}},{name:"grok-4.20-reasoning",currency:"USD",promptTokenCostPer1M:1.25,cacheReadTokenCostPer1M:.2,completionTokenCostPer1M:2.5,contextWindow:2e6,aliases:["grok-4.20-0309-reasoning","grok-4.20-reasoning-latest","grok-4.20","grok-4.20-0309"],supported:{structuredOutputs:!0}},{name:"grok-4.20-non-reasoning",currency:"USD",promptTokenCostPer1M:1.25,cacheReadTokenCostPer1M:.2,completionTokenCostPer1M:2.5,contextWindow:2e6,aliases:["grok-4.20-0309-non-reasoning","grok-4.20-non-reasoning-latest"],supported:{structuredOutputs:!0}},{name:"grok-4.20-multi-agent",currency:"USD",promptTokenCostPer1M:1.25,cacheReadTokenCostPer1M:.2,completionTokenCostPer1M:2.5,contextWindow:2e6,aliases:["grok-4.20-multi-agent-0309","grok-4.20-multi-agent-latest"],supported:{structuredOutputs:!0}},{name:"grok-4-1-fast-reasoning",currency:"USD",promptTokenCostPer1M:.2,cacheReadTokenCostPer1M:.05,completionTokenCostPer1M:.5,contextWindow:2e6,aliases:["grok-4-1-fast-reasoning-latest"],supported:{structuredOutputs:!0}},{name:"grok-4-1-fast-non-reasoning",currency:"USD",promptTokenCostPer1M:.2,cacheReadTokenCostPer1M:.05,completionTokenCostPer1M:.5,contextWindow:2e6,aliases:["grok-4-1-fast-non-reasoning-latest"],supported:{structuredOutputs:!0}},{name:"grok-voice-think-fast-1.0",currency:"USD"},{name:"grok-voice-fast-1.0",currency:"USD"},{name:"grok-3",currency:"USD",promptTokenCostPer1M:3,completionTokenCostPer1M:15},{name:"grok-3-mini",currency:"USD",promptTokenCostPer1M:.3,completionTokenCostPer1M:.5,supported:{thinkingBudget:!0}},{name:"grok-3-fast",currency:"USD",promptTokenCostPer1M:5,completionTokenCostPer1M:25},{name:"grok-3-mini-fast",currency:"USD",promptTokenCostPer1M:.6,completionTokenCostPer1M:4,supported:{thinkingBudget:!0}}];var _P={openai:{displayName:"OpenAI",defaultModel:"gpt-5-mini",defaultEmbedModel:"text-embedding-3-small",isDynamic:!1,modelInfo:jo},"openai-responses":{displayName:"OpenAI Responses",defaultModel:"gpt-4o",defaultEmbedModel:"text-embedding-ada-002",isDynamic:!1,modelInfo:Go},"azure-openai":{displayName:"Azure OpenAI",isDynamic:!0,modelInfo:[]},anthropic:{displayName:"Anthropic",defaultModel:"claude-3-7-sonnet-latest",isDynamic:!1,modelInfo:Tr},"google-gemini":{displayName:"Google Gemini",defaultModel:"gemini-2.5-flash",defaultEmbedModel:"gemini-embedding-2",isDynamic:!1,modelInfo:Do},cohere:{displayName:"Cohere",defaultModel:"command-r-plus",isDynamic:!1,modelInfo:Nc},deepseek:{displayName:"DeepSeek",defaultModel:"deepseek-v4-flash",isDynamic:!1,modelInfo:hs},"deepseek-responses":{displayName:"DeepSeek Responses",defaultModel:"deepseek-v4-flash",isDynamic:!1,modelInfo:hs},mistral:{displayName:"Mistral AI",defaultModel:"mistral-small-latest",isDynamic:!1,modelInfo:Dc},reka:{displayName:"Reka",defaultModel:"reka-core",isDynamic:!1,modelInfo:nl},grok:{displayName:"xAI Grok",defaultModel:"grok-4.6",isDynamic:!1,modelInfo:rl},webllm:{displayName:"WebLLM",defaultModel:"Llama-3.2-3B-Instruct-q4f32_1-MLC",isDynamic:!1,modelInfo:Jo}},LP={...Object.fromEntries(ks().map(r=>[r.id,{displayName:r.name,isDynamic:!0,modelInfo:[]}])),..._P},NP=r=>{let e={...r};return r.aliases&&(e.aliases=[...r.aliases]),r.supported&&(e.supported={...r.supported}),r.notSupported&&(e.notSupported={...r.notSupported}),r.audio&&(e.audio={...r.audio}),e},$P=r=>{let e=Zb(r),t=r.name.toLowerCase();return{thinkingBudget:r.supported?.thinkingBudget??!1,showThoughts:r.supported?.showThoughts??!1,structuredOutputs:r.supported?.structuredOutputs??!1,temperature:!(r.notSupported?.temperature??!1),topP:!(r.notSupported?.topP??!1),audioInput:r.audio?.input??e==="audio",audioOutput:r.audio?.output??(e==="audio"&&!t.includes("whisper")&&!t.includes("transcription"))}},Zb=r=>{let e=r.name.toLowerCase();return r.audio?.input||r.audio?.output||e.includes("audio")||e.includes("realtime")||e.includes("voice")||e.includes("whisper")||e.includes("native-audio")?"audio":e.includes("embedding")||e.includes("embed")?"embeddings":e.includes("code")||e.includes("codex")||e.includes("coder")||e.includes("codestral")?"code":"text"},UP=r=>{if(r===void 0)return;let e=Array.isArray(r)?r:[r];if(!e.includes("all"))return new Set(e)},DP=(r,e)=>!e||e.has(r.type)?!0:e.has("text")&&r.type==="code",ol=r=>{let e=typeof r?.promptTokenCostPer1M=="number",t=typeof r?.completionTokenCostPer1M=="number";return!e&&!t?Number.POSITIVE_INFINITY:(r?.promptTokenCostPer1M??0)+(r?.completionTokenCostPer1M??0)},jP=(r,e)=>{let t=ol(r)-ol(e);return t!==0?t:r.name.localeCompare(e.name)},GP=(r,e,t,n)=>{let o=NP(n),i=[e,t].filter(s=>s!==void 0);return{...o,provider:r,type:Zb(n),isDefault:i.some(s=>n.name===s||(n.aliases?.includes(s)??!1)),capabilities:$P(n)}},Xb=r=>{let e=UP(r?.type);return Object.entries(LP).map(([t,{displayName:n,defaultModel:o,defaultEmbedModel:i,isDynamic:s,modelInfo:a}])=>{let c=a.map(l=>GP(t,o,i,l)).filter(l=>DP(l,e)).sort(jP);return{name:t,displayName:n,...o!==void 0?{defaultModel:o}:void 0,...i!==void 0?{defaultEmbedModel:i}:void 0,isDynamic:s,models:c}}).sort((t,n)=>{let o=ol(t.models[0])-ol(n.models[0]);return o!==0?o:t.displayName.localeCompare(n.displayName)})};var BP=r=>`wss://generativelanguage.googleapis.com/ws/google.ai.generativelanguage.${r.live?.enableAffectiveDialog||r.live?.proactiveAudio?"v1alpha":"v1beta"}.GenerativeService.BidiGenerateContent`,nm=()=>structuredClone({...Qe(),model:"gemini-2.5-flash-native-audio-preview-12-2025",embedModel:"text-embedding-005",audio:ms(),stream:!1}),rm=r=>r==="gemini-2.5-flash-native-audio-preview-12-2025"||r==="gemini-3.1-flash-live-preview"||r.includes("native-audio")||r.includes("-live-")||r.startsWith("gemini-live-"),Ms=(r,e)=>{let t=At(r,e);return Bt(t)?At(ms(),t):t},Es=(r,e,t)=>rm(r)&&Bt(Ms(e,t)),om=r=>{if(!("inlineData"in r))return;let{mimeType:e}=r.inlineData;if(!e.startsWith("audio/"))return;let t=yt(e);if(t!=="pcm"&&t!=="pcm16")throw new Error(`Gemini Live audio output requires PCM audio input, received ${e}`)},il=r=>{if(!("inlineData"in r)||!r.inlineData.mimeType.startsWith("audio/"))return;let e=yt(r.inlineData.mimeType),t=r.inlineData.mimeType.match(/rate=(\d+)/)?.[1];return{data:r.inlineData.data,mimeType:r.inlineData.mimeType,format:e==="pcm"?"pcm16":e,sampleRate:t?Number.parseInt(t,10):void 0,channels:1,isDelta:r.isDelta===!0}},sl=r=>({name:"gemini-live-audio",localCall:async(e,t)=>t?KP(r):await eC(r)}),qP=({model:r,request:e,audio:t})=>{let n=t.output,o=t.live,i=typeof n?.voice=="string"?{voiceConfig:{prebuiltVoiceConfig:{voiceName:n.voice}}}:void 0,s={temperature:e.generationConfig.temperature,topP:e.generationConfig.topP,topK:e.generationConfig.topK,frequencyPenalty:e.generationConfig.frequencyPenalty,maxOutputTokens:e.generationConfig.maxOutputTokens,thinkingConfig:e.generationConfig.thinkingConfig,responseModalities:["AUDIO"],...i?{speechConfig:i}:{}};return{setup:{model:`models/${r}`,generationConfig:s,...e.systemInstruction?{systemInstruction:e.systemInstruction}:{},...e.tools?{tools:e.tools}:{},...e.toolConfig?{toolConfig:e.toolConfig}:{},...n?.includeTranscript!==!1?{outputAudioTranscription:{}}:{},...o?.enableAffectiveDialog?{enableAffectiveDialog:!0}:{},...o?.proactiveAudio?{proactivity:{proactiveAudio:!0}}:{}}}},zP=r=>{let e=[],t=[];for(let n of r){let o=[];for(let i of n.parts){if("inlineData"in i&&i.inlineData.mimeType.startsWith("audio/")){om(i),t.push({data:i.inlineData.data,mimeType:i.inlineData.mimeType});continue}o.push(i)}o.length>0&&e.push({...n,parts:o})}return{clientContents:e,audioParts:t}},VP=(r,e)=>{let{clientContents:t,audioParts:n}=zP(e.contents);t.length>0&&r.send(JSON.stringify({clientContent:{turns:t,turnComplete:n.length===0}}));for(let o of n)r.send(JSON.stringify({realtimeInput:{audio:o}}));n.length>0&&r.send(JSON.stringify({realtimeInput:{audioStreamEnd:!0}}))},Is=({audioData:r,audio:e,transcript:t,text:n,functionCalls:o,usageMetadata:i,isDelta:s})=>{let a=e.output,c=a?.mimeType??_t(a?.format,a?.sampleRate,"audio/pcm;rate=24000"),l=[];(n||t)&&l.push({text:n??t??""}),r&&l.push({inlineData:{mimeType:c,data:r},...s?{isDelta:!0}:{}});for(let u of o??[])l.push({functionCall:{name:u.name,args:u.args}});return{candidates:[{content:{role:"model",parts:l},finishReason:"STOP",citationMetadata:{citations:[]}}],usageMetadata:i??{promptTokenCount:0,candidatesTokenCount:0,totalTokenCount:0,thoughtsTokenCount:0}}},HP=r=>{if(r)return{promptTokenCount:r.promptTokenCount??0,candidatesTokenCount:r.candidatesTokenCount??r.responseTokenCount??0,totalTokenCount:r.totalTokenCount??0,thoughtsTokenCount:r.thoughtsTokenCount??0,cachedContentTokenCount:r.cachedContentTokenCount}},WP=r=>{let e=r?.data??r;return typeof e=="string"?JSON.parse(e):e},tm=(r,e,t)=>{if(r.addEventListener){r.addEventListener(e,t);return}r[`on${e}`]=t},eC=async(r,e)=>{let t=globalThis.WebSocket;if(!t)throw new Error("Gemini Live audio requires globalThis.WebSocket");let n=r.audio,o=n.live?.turnTimeoutMs??3e4,i={audioChunks:[],textChunks:[],outputTranscripts:[],functionCalls:[]},s=new t(`${BP(n)}?key=${encodeURIComponent(r.apiKey)}`);return await new Promise((a,c)=>{let l=!1,u=m=>{if(!l){l=!0,clearTimeout(p);try{s.close()}catch{}a(m)}},d=m=>{if(!l){l=!0,clearTimeout(p);try{s.close()}catch{}c(m instanceof Error?m:new Error(String(m)))}},p=setTimeout(()=>{d(new Error(`Gemini Live audio turn timed out after ${o}ms`))},o);tm(s,"open",()=>{s.send(JSON.stringify(qP(r)))}),tm(s,"error",m=>{d(m?.error??m?.message??"Gemini Live WebSocket error")}),tm(s,"message",m=>{try{let g=WP(m);if(g.setupComplete){VP(s,r.request);return}g.usageMetadata&&(i.usageMetadata=HP(g.usageMetadata));let h=g.toolCall?.functionCalls;if(Array.isArray(h)){for(let b of h)if(typeof b?.name=="string"){let A={name:b.name,args:b.args??{}};i.functionCalls.push(A),e?.(Is({audio:n,functionCalls:[A],isDelta:!0}))}}let x=g.serverContent;if(!x)return;let f=x.outputTranscription?.text;typeof f=="string"&&(i.outputTranscripts.push(f),e?.(Is({audio:n,transcript:f,isDelta:!0})));let y=x.modelTurn?.parts;if(Array.isArray(y))for(let b of y){if(typeof b.text=="string"){i.textChunks.push(b.text),e?.(Is({audio:n,text:b.text,isDelta:!0}));continue}let A=b.inlineData??b.inline_data,R=A?.mimeType??A?.mime_type;A?.data&&typeof R=="string"&&R.startsWith("audio/")&&(i.audioChunks.push(A.data),e?.(Is({audio:n,audioData:A.data,isDelta:!0})))}if(x.turnComplete){let b=i.outputTranscripts.join(""),A=i.textChunks.join("");u(Is({audio:n,audioData:Pr(i.audioChunks),transcript:b||void 0,text:A||void 0,functionCalls:i.functionCalls,usageMetadata:i.usageMetadata}))}}catch(g){d(g)}})})},KP=r=>new ReadableStream({start(e){eC(r,t=>e.enqueue(t)).then(t=>{e.enqueue(t),e.close()}).catch(t=>e.error(t))}});var Nr=r=>r.includes("gemini-3"),tC=r=>r.includes("gemini-3")&&r.includes("pro"),nC=r=>r==="gemini-3.7-flash"||r==="gemini-3.6-flash"||r==="gemini-3.5-flash-lite",JP=(r,e)=>e?"v1beta1":"v1",al=r=>{if(!r||typeof r!="object")return r;let e={...r},t=Array.isArray(e.type)&&e.type.length===2&&e.type.includes("null");return delete e.default,delete e.optional,delete e.oneOf,delete e.anyOf,Array.isArray(e.type)&&!t&&(e.type=e.type.includes("object")?"object":e.type[0]??"string"),e.properties&&typeof e.properties=="object"&&(e.properties=Object.fromEntries(Object.entries(e.properties).map(([n,o])=>[n,al(o)]))),e.items&&(e.items=al(e.items)),e},YP=(r,e,t)=>{for(let n=e-1;n>=0;n--){let o=r[n];if(o?.role!=="assistant"||!o.functionCalls)continue;let i=o.functionCalls.find(s=>s.id===t);if(i?.function?.name)return i.function.name}return t},im=(r,e,t)=>{let n=t.protocolResult?.value,o=[{functionResponse:{name:YP(r,e,t.functionId),response:{result:t.result,...n?.structuredContent?{structuredContent:n.structuredContent}:{}}}}];for(let i of t.content??[])i.type==="text"?o.push({text:i.text}):i.type==="image"?o.push({inlineData:{mimeType:i.mimeType,data:i.image}}):i.type==="audio"?o.push({inlineData:{mimeType:i.mimeType??"application/octet-stream",data:i.data}}):i.type==="file"?o.push({inlineData:{mimeType:i.mimeType,data:i.data}}):o.push({text:i.cachedContent??[i.title,i.description,i.url].filter(Boolean).join(`
|
|
1266
1266
|
`)});return o},rC=[{category:"HARM_CATEGORY_HARASSMENT",threshold:"BLOCK_NONE"},{category:"HARM_CATEGORY_HATE_SPEECH",threshold:"BLOCK_NONE"},{category:"HARM_CATEGORY_SEXUALLY_EXPLICIT",threshold:"BLOCK_NONE"},{category:"HARM_CATEGORY_DANGEROUS_CONTENT",threshold:"BLOCK_NONE"}],am=()=>structuredClone({model:"gemini-2.5-flash",embedModel:"text-embedding-005",safetySettings:rC,thinkingTokenBudgetLevels:{minimal:200,low:800,medium:5e3,high:1e4,highest:24500},thinkingLevelMapping:{minimal:"minimal",low:"low",medium:"medium",high:"high",highest:"high"},...Qe()}),oC=()=>structuredClone({model:"gemini-2.0-flash",embedModel:"text-embedding-005",safetySettings:rC,thinkingTokenBudgetLevels:{minimal:200,low:800,medium:5e3,high:1e4,highest:24500},thinkingLevelMapping:{minimal:"minimal",low:"low",medium:"medium",high:"high",highest:"high"},...Zn()}),sm=class{constructor(e,t,n,o,i,s,a){this.config=e;this.vertexConfig=t;this.endpointId=n;this.apiKey=o;this.credentialProvider=i;this.options=s;this.vertexApiURLForModel=a;if(!this.isVertex&&this.config.autoTruncate)throw new Error("Auto truncate is not supported for GoogleGemini");let c=this.config.model;if(Nr(c)){if(this.config.thinking?.thinkingTokenBudget!==void 0&&typeof this.config.thinking.thinkingTokenBudget=="number")throw new Error(`Gemini 3 models (${c}) do not support numeric thinkingTokenBudget. Use thinkingLevel ('low', 'medium', 'high') instead, or pass thinkingTokenBudget as a string level via options.`);if(tC(c)&&this.config.thinking?.thinkingLevel){let l=this.config.thinking.thinkingLevel;if(l!=="low"&&l!=="high")throw new Error(`Gemini 3 Pro (${c}) only supports thinkingLevel 'low' or 'high', got '${l}'. Use 'low' for less thinking or 'high' for more thinking.`)}}}tokensUsed;models;setModels(e){this.models=e}getEffectiveMappings(e){let t=this.models?.find(n=>n.model===e);return{thinkingLevelMapping:{...this.config.thinkingLevelMapping,...t?.thinkingLevelMapping??{}},thinkingTokenBudgetLevels:{...this.config.thinkingTokenBudgetLevels,...t?.thinkingTokenBudgetLevels??{}}}}getTokenUsage(){return this.tokensUsed}get isVertex(){return this.vertexConfig!==void 0}getVertexApiURL(e,t){return this.isVertex?this.vertexApiURLForModel?.(e,t):void 0}async transcribe(e,t){let n=e.model??"gemini-2.5-flash",o=typeof this.apiKey=="function"?await this.apiKey():this.apiKey,i=this.isVertex?`${this.getVertexApiURL(n,t?.beta)}/models/${n}:generateContent`:`https://generativelanguage.googleapis.com/v1beta/models/${n}:generateContent${o?`?key=${o}`:""}`,s={contents:[{role:"user",parts:[{inlineData:{mimeType:e.audio.mimeType??_t(e.audio.format,e.audio.sampleRate),data:e.audio.data}},{text:e.prompt??"Generate a transcript of the speech in this audio."}]}]},a={"Content-Type":"application/json",...this.isVertex&&o?{Authorization:`Bearer ${o}`}:{}},c=await(t?.fetch??globalThis.fetch)(i,{method:"POST",headers:this.credentialProvider?{...a,...await this.credentialProvider({profile:"google-gemini",operation:"transcribe",method:"POST",url:i})}:a,body:JSON.stringify(s),signal:t?.abortSignal});if(!c.ok)throw new Error(`Gemini transcription failed: ${c.status} ${c.statusText}`);return{text:(await c.json()).candidates?.[0]?.content?.parts?.map(d=>"text"in d?d.text:"").join("").trim()??""}}async speak(e,t){let n=e.model??"gemini-2.5-flash-preview-tts",o=typeof this.apiKey=="function"?await this.apiKey():this.apiKey,i=this.isVertex?`${this.getVertexApiURL(n,t?.beta)}/models/${n}:generateContent`:`https://generativelanguage.googleapis.com/v1beta/models/${n}:generateContent${o?`?key=${o}`:""}`,s=typeof e.voice=="object"?e.voice.id:e.voice??"Kore";return await er({url:i,headers:{...this.isVertex&&o?{Authorization:`Bearer ${o}`}:{},...this.credentialProvider?await this.credentialProvider({profile:"google-gemini",operation:"speak",method:"POST",url:i}):{}},body:{contents:[{role:"user",parts:[{text:e.text}]}],generationConfig:{responseModalities:["AUDIO"],speechConfig:{voiceConfig:{prebuiltVoiceConfig:{voiceName:s}}}}},format:e.format??"wav",transcript:e.text,fetch:t?.fetch,abortSignal:t?.abortSignal})}getVertexCacheContext(){if(!this.vertexConfig)return;let{projectId:e,region:t}=this.vertexConfig,o=`https://${ds(t)}/v1`,i=`projects/${e}/locations/${t}`;return{baseUrl:o,parent:i,modelResource:s=>`${i}/publishers/google/models/${s}`}}getModelConfig(){let{config:e}=this;return{maxTokens:e.maxTokens,temperature:e.temperature,topP:e.topP,topK:e.topK,presencePenalty:e.presencePenalty,frequencyPenalty:e.frequencyPenalty,stopSequences:e.stopSequences,endSequences:e.endSequences,stream:e.stream,n:e.n}}hasProviderDeclaredTools(){return!!(this.options?.codeExecution||this.options?.googleSearchRetrieval||this.options?.googleSearch||this.options?.googleMaps||this.options?.urlContext)}buildToolState(e,t){let n=[];if(e.functions&&e.functions.length>0){let l=e.functions.map(u=>{let d={type:"object",properties:{dummy:{type:"string",description:"An optional dummy parameter, do not use"}},required:[]},p=u.parameters?al(u.parameters):void 0;return p===void 0||p&&typeof p=="object"&&Object.keys(p).length===0?p={...d}:p&&typeof p=="object"&&p.type==="object"&&(!("properties"in p)||!p.properties||Object.keys(p.properties).length===0)&&(p={...p,properties:{dummy:{type:"string",description:"An optional dummy parameter, do not use"}},required:[]}),{name:u.name,description:u.description,parameters:p}});n.push({function_declarations:l})}if(this.options?.codeExecution&&n.push({code_execution:{}}),this.options?.googleSearchRetrieval&&n.push({google_search_retrieval:{dynamic_retrieval_config:this.options.googleSearchRetrieval}}),this.options?.googleSearch&&n.push({google_search:{}}),this.options?.googleMaps){let l=this.options.googleMaps,u=l?.enableWidget!==void 0?{enableWidget:l.enableWidget}:{};n.push({google_maps:u})}this.options?.urlContext&&n.push({url_context:{}}),n.length===0&&(n=void 0);let o,i=Array.isArray(n)?n.some(l=>l&&Array.isArray(l.function_declarations)&&l.function_declarations.length>0):!1;if(e.functionCall)if(e.functionCall==="none")o={function_calling_config:{mode:"NONE"}};else if(e.functionCall==="auto")o={function_calling_config:{mode:"AUTO"}};else if(e.functionCall==="required")o={function_calling_config:{mode:"ANY"}};else{let l=e.functionCall.function?.name?{allowedFunctionNames:[e.functionCall.function.name]}:{};o={function_calling_config:{mode:"ANY"},...l}}else i&&(o={function_calling_config:{mode:"AUTO"}});this.options?.retrievalConfig&&(o={...o??{},retrievalConfig:{...this.options.retrievalConfig.latLng?{latLng:this.options.retrievalConfig.latLng}:{}}});let s=e.functions?.some(l=>l.cache)??!1,a=!!(n&&n.length>0)||!!o,c=!!t?.contextCache&&a;return{tools:n,toolConfig:o,cacheableTools:s||c}}createChatReq=async(e,t)=>{let n=e.model,o=e.modelConfig?.stream??this.config.stream,i=Ms(this.config.audio,e.modelConfig?.audio),s=Es(n,this.config.audio,e.modelConfig?.audio);if(!e.chatPrompt||e.chatPrompt.length===0)throw new Error("Chat prompt is empty");let a;if(s){if(this.isVertex)throw new Error("Gemini Live audio currently supports Google AI API-key WebSocket sessions only");a={name:"gemini-live-audio"}}else this.endpointId?a={name:o?`/${this.endpointId}:streamGenerateContent?alt=sse`:`/${this.endpointId}:generateContent`}:a={name:o?`/models/${n}:streamGenerateContent?alt=sse`:`/models/${n}:generateContent`};if(!s&&this.isVertex&&(a.url=this.getVertexApiURL(n,t?.beta)),!s&&!this.isVertex){let A=o?"&":"?",R=typeof this.apiKey=="function"?await this.apiKey():this.apiKey;R&&(a.name+=`${A}key=${R}`)}let c=e.chatPrompt.filter(A=>A.role==="system").map(A=>A.content),l=c.length>0?{role:"user",parts:[{text:c.join(" ")}]}:void 0,u=[],d=e.chatPrompt.filter(A=>A.role!=="system");for(let A=0;A<d.length;A++){let R=d[A];switch(R.role){case"user":{let w=Array.isArray(R.content)?R.content.map((N,k)=>{switch(N.type){case"text":return{text:N.text};case"image":return{inlineData:{mimeType:N.mimeType,data:N.image}};case"audio":return{inlineData:{mimeType:N.mimeType??_t(N.format,N.sampleRate),data:N.data}};case"file":return"fileUri"in N?{fileData:{mimeType:N.mimeType,fileUri:N.fileUri}}:{inlineData:{mimeType:N.mimeType,data:N.data}};default:throw new Error(`Chat prompt content type not supported (index: ${k})`)}}):[{text:R.content}];u.push({role:"user",parts:w});break}case"assistant":{let w=[],N=R.thoughtBlocks,k=R.functionCalls&&R.functionCalls.length>0,E=N?.[0],F=N?.map(P=>P.data).join("")??"",L=E?.signature;if(F&&w.push({...k?{}:{thought:!0},text:F,...L&&!k?{thought_signature:L}:{}}),R.functionCalls){let P=R.functionCalls.map(($,S)=>{let z;if(typeof $.function.params=="string"){let H=$.function.params;if(H.trim().length===0)z={};else try{z=JSON.parse(H)}catch{throw new Error(`Failed to parse function params JSON: ${H}`)}}else z=$.function.params;let _={functionCall:{name:$.function.name,args:z}};return L&&S===0&&(_.thought_signature=L),_});w.push(...P)}let D=R.audio?.transcript;if((R.content||D)&&w.push({text:R.content??D??""}),w.length===0)throw new Error("Assistant content is empty");u.push({role:"model",parts:w});break}case"function":{let w=[],N=R,k=A;for(;;){if(!("functionId"in N))throw new Error(`Chat prompt functionId is empty (index: ${k})`);if(w.push(...im(d,k,N)),k+1<d.length&&d[k+1].role==="function")k++,N=d[k];else break}A=k,u.push({role:"user",parts:w});break}default:throw new Error(`Invalid role: ${JSON.stringify(R)} (index: ${A})`)}}let{tools:p,toolConfig:m}=this.buildToolState(e,t),g={};if(this.config.thinking?.includeThoughts&&(g.includeThoughts=!0),this.config.thinking?.thinkingTokenBudget&&(g.thinkingBudget=this.config.thinking.thinkingTokenBudget),this.config.thinking?.thinkingLevel&&Nr(n)&&(g.thinkingLevel=this.config.thinking.thinkingLevel),t?.thinkingTokenBudget){let A=this.getEffectiveMappings(n),R=A.thinkingTokenBudgetLevels;if(Nr(n)){let N=tC(n),k=A.thinkingLevelMapping;if(t.thinkingTokenBudget==="none")g.thinkingLevel=k?.minimal??"minimal";else{let E=t.thinkingTokenBudget,F=k?.[E];F||(F=E==="highest"?"high":E),g.thinkingLevel=F}if(N&&g.thinkingLevel){let E=g.thinkingLevel;E!=="low"&&E!=="high"&&(g.thinkingLevel=E==="minimal"?"low":"high")}}else switch(t.thinkingTokenBudget){case"none":g.thinkingBudget=0,g.includeThoughts=!1,delete g.thinkingLevel;break;case"minimal":g.thinkingBudget=R?.minimal??200;break;case"low":g.thinkingBudget=R?.low??800;break;case"medium":g.thinkingBudget=R?.medium??5e3;break;case"high":g.thinkingBudget=R?.high??1e4;break;case"highest":g.thinkingBudget=R?.highest??24500;break}}g.thinkingLevel&&delete g.thinkingBudget,Nr(n)||delete g.thinkingLevel,Nr(n)&&delete g.thinkingBudget;let h=e.modelConfig?.maxTokens??this.config.maxTokens;if(g.thinkingLevel&&h!==void 0)throw new Error("Cannot set maxTokens when using thinkingLevel with Gemini models. When thinking is enabled, the model manages output tokens automatically. Remove the maxTokens setting or disable thinking.");t?.showThoughts!==void 0&&t?.thinkingTokenBudget!=="none"&&(g.includeThoughts=t.showThoughts);let x=nC(n),f={maxOutputTokens:e.modelConfig?.maxTokens??this.config.maxTokens,...x?{}:{temperature:e.modelConfig?.temperature??this.config.temperature},...!x&&e.modelConfig?.topP!==void 0?{topP:e.modelConfig.topP}:{},...x?{}:{topK:e.modelConfig?.topK??this.config.topK},frequencyPenalty:e.modelConfig?.frequencyPenalty??this.config.frequencyPenalty,candidateCount:e.modelConfig?.n??this.config.n??1,stopSequences:e.modelConfig?.stopSequences??this.config.stopSequences,responseMimeType:"text/plain",...Object.keys(g).length>0?{thinkingConfig:g}:{}};if(!x&&Nr(n)&&(f.temperature===void 0||f.temperature<1)&&(f.temperature=1),s&&(e.responseFormat||this.config.responseFormat))throw new Error("Gemini Live audio models do not support structured response formats with audio output");if(e.responseFormat)if(e.responseFormat.type==="json_schema"&&e.responseFormat.schema){let A=e.responseFormat.schema.schema||e.responseFormat.schema;f.responseMimeType="application/json",f.responseJsonSchema=al(A)}else f.responseMimeType="application/json";else this.config.responseFormat&&this.config.responseFormat==="json_object"&&(f.responseMimeType="application/json");let y=this.config.safetySettings,b={contents:u,tools:p,toolConfig:m,systemInstruction:l,generationConfig:f,safetySettings:y};if(s){let A=typeof this.apiKey=="function"?await this.apiKey():this.apiKey;if(!A)throw new Error("GoogleGemini AI API key not set");a=sl({model:n,request:b,apiKey:A,audio:i})}return[a,b]};createEmbedReq=async(e,t)=>{let n=e.embedModel;if(!n)throw new Error("Embed model not set");if(!e.texts||e.texts.length===0)throw new Error("Embed texts is empty");let o,i;if(this.isVertex)this.endpointId?o={name:`/${this.endpointId}:predict`}:o={name:`/models/${n}:predict`},o.url=this.getVertexApiURL(n,t?.beta),i={instances:e.texts.map(s=>({content:s,...this.config.embedType&&{taskType:this.config.embedType}})),parameters:{autoTruncate:this.config.autoTruncate,outputDimensionality:this.config.dimensions}};else{let s=typeof this.apiKey=="function"?await this.apiKey():this.apiKey;o={name:`/models/${n}:batchEmbedContents${s?`?key=${s}`:""}`},i={requests:e.texts.map(a=>({model:`models/${n}`,content:{parts:[{text:a}]},outputDimensionality:this.config.dimensions,...this.config.embedType&&{taskType:this.config.embedType}}))}}return[o,i]};createChatResp=e=>{let t,n=e.candidates?.map(i=>{let s={index:0};switch(i.finishReason){case"MAX_TOKENS":s.finishReason="length";break;case"STOP":s.finishReason="stop";break;case"SAFETY":throw new Ve("Content was blocked due to safety settings",void 0,void 0);case"RECITATION":throw new Ve("Content was blocked due to recitation policy",void 0,void 0);case"MALFORMED_FUNCTION_CALL":throw new Ve("Function call was malformed and blocked",void 0,void 0);case"UNEXPECTED_TOOL_CALL":throw new Ve("Unexpected tool call",void 0,void 0);case"FINISH_REASON_UNSPECIFIED":throw new Ve("Finish reason unspecified",void 0,void 0);case"BLOCKLIST":throw new Ve("Content was blocked due to blocklist",void 0,void 0);case"PROHIBITED_CONTENT":throw new Ve("Content was blocked due to prohibited content",void 0,void 0);case"SPII":throw new Ve("Content was blocked due to SPII",void 0,void 0);case"OTHER":throw new Ve("Other finish reason",void 0,void 0)}if(!i.content||!i.content.parts)return s;for(let l of i.content.parts){if("text"in l){if("thought"in l&&l.thought||l.thought===!0){s.thought=l.text;let d=l.thoughtSignature||l.thought_signature;s.thoughtBlocks||(s.thoughtBlocks=[]),s.thoughtBlocks.push({data:l.text,encrypted:!1,...d?{signature:d}:{}})}else s.content=l.text;continue}if("functionCall"in l){let d=l.thoughtSignature||l.thought_signature;if(d)if(!s.thoughtBlocks||s.thoughtBlocks.length===0)s.thoughtBlocks=[{data:"",encrypted:!1,signature:d}];else{let p=s.thoughtBlocks[s.thoughtBlocks.length-1];p&&!p.signature&&(p.signature=d)}s.functionCalls=[...s.functionCalls??[],{id:ze(),type:"function",function:{name:l.functionCall.name,params:l.functionCall.args}}]}let u=il(l);u&&(s.audio=u)}let a=i.citationMetadata?.citations;if(Array.isArray(a)&&a.length){let l=u=>u?`${u.year}-${String(u.month).padStart(2,"0")}-${String(u.day).padStart(2,"0")}`:void 0;s.citations=a.filter(u=>typeof u?.uri=="string").map(u=>({url:u.uri,title:u.title,license:u.license,publicationDate:l(u.publicationDate)}))}let c=i.groundingMetadata;if(c){if(Array.isArray(c.groundingChunks)){let l=c.groundingChunks.map(d=>d?.maps).filter(d=>d&&typeof d.uri=="string").map(d=>({url:d.uri,title:d.title}));l.length&&(s.citations=[...s.citations??[],...l]);let u=c.groundingChunks.map(d=>d?.retrievedContext).filter(d=>d&&(typeof d.uri=="string"||typeof d.media_id=="string")).map(d=>({url:d.uri??"",title:d.title,...typeof d.media_id=="string"?{mediaId:d.media_id}:{},...Array.isArray(d.page_numbers)?{pageNumbers:d.page_numbers}:{}}));u.length&&(s.citations=[...s.citations??[],...u])}typeof c.googleMapsWidgetContextToken=="string"&&(t=c.googleMapsWidgetContextToken)}return s});if(e.usageMetadata){let i=e.usageMetadata.cachedContentTokenCount??0;this.tokensUsed={totalTokens:e.usageMetadata.totalTokenCount,promptTokens:e.usageMetadata.promptTokenCount-i,completionTokens:e.usageMetadata.candidatesTokenCount,thoughtsTokens:e.usageMetadata.thoughtsTokenCount,...i>0?{cacheReadTokens:i}:{}}}let o={results:n,...e.responseId?{remoteId:e.responseId}:{},...e.modelVersion?{providerMetadata:{google:{modelVersion:e.modelVersion}}}:{}};return t&&(o.providerMetadata={...o.providerMetadata,google:{...o.providerMetadata?.google??{},mapsWidgetContextToken:t}}),o};createChatStreamResp=e=>this.createChatResp(e);createEmbedResp=e=>{let t;return this.isVertex?t=e.predictions.map(n=>n.embeddings.values):t=e.embeddings.map(n=>n.values),{embeddings:t}};supportsContextCache=e=>{let t=e;return Sb.some(n=>t.includes(n)||n.includes(t))};buildCacheCreateOp=(e,t)=>{let n=e.model,o=t.contextCache?.ttlSeconds??3600,{tools:i,toolConfig:s,cacheableTools:a}=this.buildToolState(e,t),{systemInstruction:c,contents:l}=this.extractCacheableContent(e.chatPrompt);if(!c&&(!l||l.length===0)&&!a)return;let u=this.getVertexCacheContext(),d={model:u?u.modelResource(n):`models/${n}`,ttl:`${o}s`,displayName:`ax-cache-${Date.now()}`};c&&(d.systemInstruction=c),l&&l.length>0&&(d.contents=l),a&&(i&&i.length>0&&(d.tools=i),s&&(d.toolConfig=s));let p;if(u)p=`/${u.parent}/cachedContents`;else{let m=typeof this.apiKey=="function"?"ASYNC_KEY":this.apiKey;p=`/cachedContents${m?`?key=${m}`:""}`}return{type:"create",apiConfig:{name:p,...u?{url:u.baseUrl}:{}},request:d,parseResponse:m=>{let g=m;if(g?.name)return{name:g.name,expiresAt:g.expireTime,tokenCount:g.usageMetadata?.totalTokenCount}}}};getContextCacheToolState=(e,t)=>{let{tools:n,toolConfig:o,cacheableTools:i}=this.buildToolState(e,t);if(!i)return;let s=e.functions?.map(({cache:c,...l})=>l);if(!!(s&&s.length>0)||!!e.functionCall)return{functions:s,functionCall:e.functionCall};if(n||o)return{functions:[{name:"__gemini_tool_state__",description:JSON.stringify({tools:n,toolConfig:o})}]}};buildCacheUpdateTTLOp=(e,t)=>{let n={ttl:`${t}s`},o=new URLSearchParams({updateMask:"ttl"});if(!this.isVertex&&this.apiKey){let a=typeof this.apiKey=="function"?"ASYNC_KEY":this.apiKey;o.set("key",a)}let i=`/${e}?${o.toString()}`,s=this.getVertexCacheContext();return{type:"update",apiConfig:{name:i,method:"PATCH",headers:{"Content-Type":"application/json"},...s?{url:s.baseUrl}:{}},request:n,parseResponse:a=>{let c=a;if(c?.name)return{name:c.name,expiresAt:c.expireTime,tokenCount:c.usageMetadata?.totalTokenCount}}}};buildCacheDeleteOp=e=>{let t=`/${e}`;if(!this.isVertex&&this.apiKey){let o=typeof this.apiKey=="function"?"ASYNC_KEY":this.apiKey;t+=`?key=${o}`}let n=this.getVertexCacheContext();return{type:"delete",apiConfig:{name:t,headers:{"Content-Type":"application/json"},...n?{url:n.baseUrl}:{}},request:{},parseResponse:()=>{}}};prepareCachedChatReq=async(e,t,n)=>{let o=e.model,i=e.modelConfig?.stream??this.config.stream,{tools:s,toolConfig:a,cacheableTools:c}=this.buildToolState(e,t),{dynamicContents:l,dynamicSystemInstruction:u}=this.extractDynamicContent(e.chatPrompt),d;if(this.endpointId?d={name:i?`/${this.endpointId}:streamGenerateContent?alt=sse`:`/${this.endpointId}:generateContent`}:d={name:i?`/models/${o}:streamGenerateContent?alt=sse`:`/models/${o}:generateContent`},!this.isVertex){let x=i?"&":"?",f=typeof this.apiKey=="function"?await this.apiKey():this.apiKey;f&&(d.name+=`${x}key=${f}`)}let p=nC(o),m={maxOutputTokens:e.modelConfig?.maxTokens??this.config.maxTokens,...p?{}:{temperature:e.modelConfig?.temperature??this.config.temperature},...!p&&e.modelConfig?.topP!==void 0?{topP:e.modelConfig.topP}:{},...p?{}:{topK:e.modelConfig?.topK??this.config.topK},frequencyPenalty:e.modelConfig?.frequencyPenalty??this.config.frequencyPenalty,candidateCount:e.modelConfig?.n??this.config.n??1,stopSequences:e.modelConfig?.stopSequences??this.config.stopSequences,responseMimeType:"text/plain"};!p&&Nr(o)&&(m.temperature===void 0||m.temperature<1)&&(m.temperature=1);let g=this.config.safetySettings,h={contents:l,cachedContent:n,generationConfig:m,safetySettings:g};return c||(s&&s.length>0&&(h.tools=s),a&&(h.toolConfig=a)),u&&(h.systemInstruction=u),{apiConfig:d,request:h}};extractCacheableContent(e){let t,n=[],o=-1;for(let i=e.length-1;i>=0;i--){let s=e[i];if("cache"in s&&s.cache){o=i;break}}for(let i=0;i<e.length;i++){let s=e[i];if(s.role==="system"){t={role:"user",parts:[{text:s.content}]};continue}if(o>=0&&i<=o)if(s.role==="user"){let a=[];if(typeof s.content=="string")a.push({text:s.content});else if(Array.isArray(s.content))for(let c of s.content)switch(c.type){case"text":a.push({text:c.text});break;case"image":a.push({inlineData:{mimeType:c.mimeType,data:c.image}});break;case"audio":a.push({inlineData:{mimeType:c.mimeType??_t(c.format,c.sampleRate),data:c.data}});break;case"file":"fileUri"in c?a.push({fileData:{mimeType:c.mimeType,fileUri:c.fileUri}}):a.push({inlineData:{mimeType:c.mimeType,data:c.data}});break}a.length>0&&n.push({role:"user",parts:a})}else if(s.role==="assistant"){let a=[],c=s.thoughtBlocks,l=s.functionCalls&&s.functionCalls.length>0,u=c?.[0]?.signature,d=c?.map(p=>p.data).join("")??"";if(d&&a.push({...l?{}:{thought:!0},text:d,...u&&!l?{thought_signature:u}:{}}),s.functionCalls)for(let[p,m]of s.functionCalls.entries()){let g;if(typeof m.function.params=="string")try{g=JSON.parse(m.function.params)}catch{g={}}else g=m.function.params??{};let h={functionCall:{name:m.function.name,args:g}};u&&p===0&&(h.thought_signature=u),a.push(h)}s.content&&a.push({text:s.content}),a.length>0&&n.push({role:"model",parts:a})}else s.role==="function"&&n.push({role:"user",parts:im(e,i,s)})}return{systemInstruction:t,contents:n}}extractDynamicContent(e){let n=[],o=-1;for(let i=e.length-1;i>=0;i--){let s=e[i];if("cache"in s&&s.cache){o=i;break}}for(let i=0;i<e.length;i++){let s=e[i];if(s.role!=="system"&&!(o>=0&&i<=o))if(s.role==="user"){let a=[];if(typeof s.content=="string")a.push({text:s.content});else if(Array.isArray(s.content)){for(let c of s.content)if(!("cache"in c&&c.cache))switch(c.type){case"text":a.push({text:c.text});break;case"image":a.push({inlineData:{mimeType:c.mimeType,data:c.image}});break;case"audio":a.push({inlineData:{mimeType:c.mimeType??_t(c.format,c.sampleRate),data:c.data}});break;case"file":"fileUri"in c?a.push({fileData:{mimeType:c.mimeType,fileUri:c.fileUri}}):a.push({inlineData:{mimeType:c.mimeType,data:c.data}});break}}a.length>0&&n.push({role:"user",parts:a})}else if(s.role==="assistant"){let a=[],c=s.thoughtBlocks,l=s.functionCalls&&s.functionCalls.length>0,u=c?.[0]?.signature,d=c?.map(p=>p.data).join("")??"";if(d&&a.push({...l?{}:{thought:!0},text:d,...u&&!l?{thought_signature:u}:{}}),s.functionCalls)for(let[p,m]of s.functionCalls.entries()){let g;if(typeof m.function.params=="string")try{g=JSON.parse(m.function.params)}catch{g={}}else g=m.function.params??{};let h={functionCall:{name:m.function.name,args:g}};u&&p===0&&(h.thought_signature=u),a.push(h)}s.content&&a.push({text:s.content}),a.length>0&&n.push({role:"model",parts:a})}else s.role==="function"&&n.push({role:"user",parts:im(e,i,s)})}return{dynamicContents:n,dynamicSystemInstruction:void 0}}},Yo=class r extends vt{static create(e){return new r(e)}constructor({apiKey:e,credentialProvider:t,projectId:n,region:o,endpointId:i,config:s,options:a,models:c,modelInfo:l}){let u=n!==void 0&&o!==void 0?{projectId:n,region:o}:void 0,d={...am(),...s},p,m,g;if(u){let{projectId:y,region:b}=u;if(!e&&!t)throw new Error("GoogleGemini Vertex API key or credential provider not set");if(e&&typeof e!="function")throw new Error("GoogleGemini Vertex API key must be a function for token-based authentication");let A;i?A="endpoints":A="publishers/google";let R=ds(b);g=(w,N)=>`https://${R}/${JP(w,N)}/projects/${y}/locations/${b}/${A}`,p=g(d.model),m=async()=>({...e?{Authorization:`Bearer ${typeof e=="function"?await e():e}`}:{}})}else{if(!e&&!t)throw new Error("GoogleGemini AI API key or credential provider not set");p="https://generativelanguage.googleapis.com/v1beta",m=async()=>({})}let h=new sm(d,u,i,e,t,a,g);l=[...Do,...l??[]];let x=y=>{let b=Es(y,{output:{enabled:!0}}),A=Gt({model:y,modelInfo:l,models:c}),R=A?.supported?.structuredOutputs??!0,w=A?.supported?.structuredOutputModes??(R?["native","function"]:["function"]);return{functions:!0,streaming:!0,hasThinkingBudget:A?.supported?.thinkingBudget??!1,hasShowThoughts:A?.supported?.showThoughts??!1,structuredOutputs:w.includes("native"),structuredOutputModes:w,media:{images:{supported:!0,formats:["image/jpeg","image/png","image/gif","image/webp"],maxSize:20*1024*1024,detailLevels:["high","low","auto"]},audio:{supported:!0,formats:b?["pcm16","pcm"]:["wav","mp3","aac","ogg"],maxDuration:9.5*60,output:{supported:b,formats:["pcm16"],sampleRate:24e3,voices:["Kore"]}},files:{supported:!0,formats:["application/pdf","text/plain","text/csv","text/html","text/xml"],maxSize:2*1024*1024*1024,uploadMethod:"cloud"},urls:{supported:!0,webSearch:!0,contextFetching:!0}},caching:{supported:h.supportsContextCache(y),types:["persistent"]},thinking:A?.supported?.thinkingBudget??!1,multiTurn:!0}},f=c?.map(y=>{let b=y,A=b?.config;if(!A)return y;let R={};A.maxTokens!==void 0&&(R.maxTokens=A.maxTokens),A.temperature!==void 0&&(R.temperature=A.temperature),A.topP!==void 0&&(R.topP=A.topP),A.topK!==void 0&&(R.topK=A.topK),A.presencePenalty!==void 0&&(R.presencePenalty=A.presencePenalty),A.frequencyPenalty!==void 0&&(R.frequencyPenalty=A.frequencyPenalty),A.stopSequences!==void 0&&(R.stopSequences=A.stopSequences),A.endSequences!==void 0&&(R.endSequences=A.endSequences),A.stream!==void 0&&(R.stream=A.stream),A.n!==void 0&&(R.n=A.n);let w={...b};Object.keys(R).length>0&&(w.modelConfig={...b.modelConfig??{},...R});let N=A.thinking?.thinkingTokenBudget;if(typeof N=="number"){let k=d.thinkingTokenBudgetLevels,E=[["minimal",k?.minimal??200],["low",k?.low??800],["medium",k?.medium??5e3],["high",k?.high??1e4],["highest",k?.highest??24500]],F="minimal",L=Number.POSITIVE_INFINITY;for(let[D,P]of E){let $=Math.abs(N-P);$<L&&(L=$,F=D)}w.thinkingTokenBudget=F}return A.thinking?.includeThoughts!==void 0&&(w.showThoughts=!!A.thinking.includeThoughts),A.thinkingLevelMapping&&(w.thinkingLevelMapping=A.thinkingLevelMapping),A.thinkingTokenBudgetLevels&&(w.thinkingTokenBudgetLevels=A.thinkingTokenBudgetLevels),w});f?h.setModels(f):c&&h.setModels(c),super(h,{name:"GoogleGeminiAI",apiURL:p,headers:m,modelInfo:l,defaults:{model:d.model,embedModel:d.embedModel},options:a,credentialProvider:t,profile:"google-gemini",supportFor:x,models:f??c})}};var cl=class{constructor(e={}){this.config=e;this.config.id=this.config.id??ze()}metrics={latency:{chat:{mean:0,p95:0,p99:0,samples:[]},embed:{mean:0,p95:0,p99:0,samples:[]}},errors:{chat:{count:0,rate:0,total:0},embed:{count:0,rate:0,total:0}}};getLastUsedChatModel(){return this.config.modelInfo?.name??"mock-model"}getLastUsedEmbedModel(){return this.config.embedModelInfo?.name??"mock-embed-model"}getLastUsedModelConfig(){return this.config.modelInfo?{maxTokens:this.config.modelInfo.maxTokens,temperature:.7,stream:this.config.features?.streaming??!1}:void 0}getName(){return this.config.name??"mock-ai-service"}getId(){return this.config.id??"mock-ai-service-id"}getFeatures(e){let t=this.config.features?.media;return{functions:this.config.features?.functions??!1,streaming:this.config.features?.streaming??!1,structuredOutputs:this.config.features?.structuredOutputs,...this.config.features?.structuredOutputModes?{structuredOutputModes:this.config.features.structuredOutputModes}:{},media:{images:{supported:t?.images?.supported??!1,formats:t?.images?.formats??[]},audio:{supported:t?.audio?.supported??!1,formats:t?.audio?.formats??[]},files:{supported:t?.files?.supported??!1,formats:t?.files?.formats??[],uploadMethod:t?.files?.uploadMethod??"none"},urls:{supported:t?.urls?.supported??!1,webSearch:t?.urls?.webSearch??!1,contextFetching:t?.urls?.contextFetching??!1}},caching:{supported:!1,types:[]},thinking:!1,multiTurn:!0}}getModelList(){return this.config.models}getMetrics(){return this.metrics}getEstimatedCost(){return 0}async chat(e,t){if(this.config.latencyMs&&await new Promise(n=>setTimeout(n,this.config.latencyMs)),this.config.shouldError)throw new Error(this.config.errorMessage??"Mock chat error");return this.updateMetrics("chat"),typeof this.config.chatResponse=="function"?await this.config.chatResponse(e):this.config.chatResponse??{results:[{index:0,content:"Mock response",finishReason:"stop"}],modelUsage:{ai:this.getName(),model:"mock-model",tokens:{promptTokens:10,completionTokens:5,totalTokens:15}}}}async embed(e,t){if(this.config.latencyMs&&await new Promise(n=>setTimeout(n,this.config.latencyMs)),this.config.shouldError)throw new Error(this.config.errorMessage??"Mock embed error");return this.updateMetrics("embed"),typeof this.config.embedResponse=="function"?this.config.embedResponse(e):this.config.embedResponse??{embeddings:[[.1,.2,.3]],modelUsage:{ai:this.getName(),model:"mock-model",tokens:{promptTokens:5,completionTokens:0,totalTokens:5}}}}async transcribe(e,t){if(this.config.shouldError)throw new Error(this.config.errorMessage??"Mock transcribe error");return typeof this.config.transcribeResponse=="function"?this.config.transcribeResponse(e):this.config.transcribeResponse??{text:"Mock transcription"}}async speak(e,t){if(this.config.shouldError)throw new Error(this.config.errorMessage??"Mock speech error");return typeof this.config.speechResponse=="function"?this.config.speechResponse(e):this.config.speechResponse??{data:"bW9jay1hdWRpbw==",format:"mp3",mimeType:"audio/mpeg",transcript:e.text}}setOptions(e){this.config.options=e}getOptions(){return this.config.options??{}}getLogger(){return this.config.options?.logger??(e=>{console.log(e)})}updateMetrics(e){let t=this.config.latencyMs??0;this.metrics.latency[e].samples.push(t);let n=this.metrics.latency[e].samples;if(this.metrics.latency[e].mean=n.reduce((o,i)=>o+i,0)/n.length,n.length>0){let o=[...n].sort((a,c)=>a-c),i=Math.max(0,Math.floor(o.length*.95)-1);this.metrics.latency[e].p95=o[i]??t;let s=Math.max(0,Math.floor(o.length*.99)-1);this.metrics.latency[e].p99=o[s]??t}if(this.config.shouldError){this.metrics.errors[e].count++,this.metrics.errors[e].total++;let o=this.metrics.latency[e].samples.length;this.metrics.errors[e].rate=o>0?this.metrics.errors[e].count/o:0}}};var ll=class r{options;lastUsedService;services=new Map;constructor(e){if(e.length===0)throw new Error("No AI services provided.");for(let[t,n]of e.entries())if("key"in n){if(this.services.has(n.key))throw new Error(`Duplicate model key: ${n.key}`);let{service:i,description:s,isInternal:a}=n;this.services.set(n.key,{service:i,description:s,isInternal:a})}else{let i=n.getModelList();if(!i)throw new Error(`Service ${t} \`${n.getName()}\` has no model list.`);for(let s of i){if(this.services.has(s.key)){let a=this.services.get(s.key)?.service;throw new Error(`Service ${t} \`${n.getName()}\` has duplicate model key: ${s.key} as service ${a?.getName()}`)}if("model"in s&&typeof s.model)this.services.set(s.key,{description:s.description,service:n,model:s.model});else if("embedModel"in s&&s.embedModel)this.services.set(s.key,{description:s.description,service:n,embedModel:s.embedModel});else throw new Error(`Key ${s.key} in model list for service ${t} \`${n.getName()}\` is missing a model or embedModel property.`)}}}static create(e){return new r(e)}getLastUsedChatModel(){return this.lastUsedService?.getLastUsedChatModel()}getLastUsedEmbedModel(){return this.lastUsedService?.getLastUsedEmbedModel()}getLastUsedModelConfig(){return this.lastUsedService?.getLastUsedModelConfig()}async chat(e,t){let n=e.model;if(!n)throw new Error("Model key must be specified for multi-service");let o=this.services.get(n);if(!o)throw new Error(`No service found for model key: ${n}`);if(this.lastUsedService=o.service,!o.model){let{model:i,...s}=e;return await o.service.chat(s,t)}return await o.service.chat({model:n,...e},t)}async embed(e,t){let n=e.embedModel;if(!n)throw new Error("Embed model key must be specified for multi-service");let o=this.services.get(n);if(!o)throw new Error(`No service found for embed model key: ${n}`);if(this.lastUsedService=o.service,!o.model){let{embedModel:i,...s}=e;return await o.service.embed(s,t)}return await o.service.embed({embedModel:n,...e},t)}async transcribe(e,t){let n=e.model;if(!n){let i=Array.from(this.services.values())[0]?.service;if(!i)throw new Error("No AI services provided.");return this.lastUsedService=i,await i.transcribe(e,t)}let o=this.services.get(n);if(!o)throw new Error(`No service found for transcription model key: ${n}`);return this.lastUsedService=o.service,await o.service.transcribe(e,t)}async speak(e,t){let n=e.model;if(!n){let i=Array.from(this.services.values())[0]?.service;if(!i)throw new Error("No AI services provided.");return this.lastUsedService=i,await i.speak(e,t)}let o=this.services.get(n);if(!o)throw new Error(`No service found for speech model key: ${n}`);return this.lastUsedService=o.service,await o.service.speak(e,t)}getId(){return`MultiServiceRouter:${Array.from(this.services.values()).map(e=>e.service.getId()).join(",")}`}getName(){return"MultiServiceRouter"}getModelList(){return Array.from(this.services).filter(([,e])=>!e.isInternal).map(([e,t])=>{if(t.model)return{key:e,description:t.description,model:t.model};if(t.embedModel)return{key:e,description:t.description,embedModel:t.embedModel};throw new Error(`Service ${e} has no model or embedModel`)})}getFeatures(e){if(e){let t=this.services.get(e);if(t)return t.service.getFeatures(e)}return{functions:!1,streaming:!1,media:{images:{supported:!1,formats:[]},audio:{supported:!1,formats:[]},files:{supported:!1,formats:[],uploadMethod:"none"},urls:{supported:!1,webSearch:!1,contextFetching:!1}},caching:{supported:!1,types:[]},thinking:!1,multiTurn:!0}}getMetrics(){let e=this.lastUsedService;if(!e){let t=this.services.values().next().value;t&&(e="service"in t?t.service:t)}if(!e)throw new Error("No service available to get metrics.");return e.getMetrics()}getEstimatedCost(e){return this.lastUsedService?.getEstimatedCost(e)??0}setOptions(e){for(let t of this.services.values())t.service.setOptions(e);this.options=e}getOptions(){return this.options??{}}getLogger(){let e=this.lastUsedService;if(!e){let t=this.services.values().next().value;t&&(e=t.service)}if(!e)throw new Error("No service available to get logger.");return e.getLogger()}setServiceEntry(e,t){this.services.set(e,t)}};async function ul(r,e,t={}){if(typeof r=="string")return[{type:"text",text:r}];if(!Array.isArray(r))return[{type:"text",text:String(r)}];let n=e.getFeatures(),o=[];for(let i of r)try{switch(i.type){case"text":o.push({type:"text",text:i.text});break;case"image":if(n.media.images.supported)i.altText?o.push({type:"text",text:`[Image: ${i.altText}]`}):o.push({type:"text",text:"[Image content]"});else if(i.altText)o.push({type:"text",text:i.altText});else if(t.imageToText)try{let s=await t.imageToText(i.image);o.push({type:"text",text:s})}catch(s){throw new Kt(s,"image","vision analysis")}else switch(t.fallbackBehavior){case"error":throw new ft("Images",e.getName(),!1);case"skip":continue;default:o.push({type:"text",text:"[Image content not supported by this provider]"})}break;case"audio":if(n.media.audio.supported)i.transcription?o.push({type:"text",text:i.transcription}):o.push({type:"text",text:"[Audio content]"});else if(i.transcription)o.push({type:"text",text:i.transcription});else if(t.audioToText)try{let s=await t.audioToText(i.data,i.format);o.push({type:"text",text:s})}catch(s){throw new Kt(s,"audio","transcription")}else switch(t.fallbackBehavior){case"error":throw new ft("Audio",e.getName(),!1);case"skip":continue;case"degrade":o.push({type:"text",text:"[Audio content not supported by this provider]"})}break;case"file":if(n.media.files.supported)i.extractedText?o.push({type:"text",text:i.extractedText}):o.push({type:"text",text:`[File: ${i.filename}]`});else if(i.extractedText)o.push({type:"text",text:i.extractedText});else if(t.fileToText)try{let s=await t.fileToText(i.data,i.mimeType);o.push({type:"text",text:s})}catch(s){throw new Kt(s,"file","text extraction")}else switch(t.fallbackBehavior){case"error":throw new ft("Files",e.getName(),!1);case"skip":continue;default:o.push({type:"text",text:`[File: ${i.filename} - content not accessible by this provider]`})}break;case"url":if(n.media.urls.supported)i.cachedContent?o.push({type:"text",text:i.cachedContent}):o.push({type:"text",text:`[Link: ${i.url}${i.title?` - ${i.title}`:""}]`});else if(i.cachedContent)o.push({type:"text",text:i.cachedContent});else if(t.urlToText)try{let s=await t.urlToText(i.url);o.push({type:"text",text:s})}catch(s){throw new Kt(s,"url","content fetching")}else switch(t.fallbackBehavior){case"error":throw new ft("URLs",e.getName(),!1);case"skip":continue;case"degrade":o.push({type:"text",text:`[Link: ${i.url}${i.title?` - ${i.title}`:""}]`})}break;default:typeof i=="object"&&i.text?o.push({type:"text",text:i.text}):o.push({type:"text",text:String(i)})}}catch(s){throw s instanceof ft||s instanceof Kt?s:new Kt(s,i.type||"unknown","content processing")}return o}function iC(r){let e=!1,t=!1,n=!1,o=!1;for(let i of r)if(i.role==="user"&&Array.isArray(i.content))for(let s of i.content)switch(s.type){case"image":e=!0;break;case"audio":t=!0;break;case"file":n=!0;break;case"url":o=!0;break}return{hasImages:e,hasAudio:t,hasFiles:n,hasUrls:o}}var dl=class{providers;processingServices;config;constructor(e){this.providers=[e.providers.primary,...e.providers.alternatives],this.processingServices=e.processing,this.config=e.routing}async chat(e,t={}){let n=await this.selectProviderWithDegradation(e,t.routingOptions||{}),o=await this.preprocessRequest(e,n.provider,t.processingOptions);try{return{response:await n.provider.chat(o,t),routing:n}}catch(i){if(i instanceof ft&&t.fallbackProviders?.length)return await this.tryFallbackProviders(e,t.fallbackProviders,t);throw i}}async preprocessRequest(e,t,n){let o={...n,fallbackBehavior:n?.fallbackBehavior||"degrade",imageToText:n?.imageToText||this.processingServices.imageToText,audioToText:n?.audioToText||this.processingServices.audioToText,fileToText:n?.fileToText||this.processingServices.fileToText,urlToText:n?.urlToText||this.processingServices.urlToText},i=[];for(let s of e.chatPrompt)if(s.role==="user"&&Array.isArray(s.content)){let a=await ul(s.content,t,o);a.every(l=>l.type==="text")&&a.length===1?i.push({...s,content:a[0].text}):i.push({...s,content:a.map(l=>({type:"text",text:l.text}))})}else i.push(s);return{...e,chatPrompt:i}}async selectProviderWithDegradation(e,t){let n=Mr(e),o=[],i=[],s=[];try{let a=_c(e,this.providers,{requireExactMatch:t.requireExactMatch??this.config.capability.requireExactMatch,allowDegradation:t.allowDegradation??this.config.capability.allowDegradation}),c=a.getFeatures();return n.hasImages&&!c.media.images.supported&&(i.push("Images will be converted to text descriptions"),o.push("Image-to-text conversion")),n.hasAudio&&!c.media.audio.supported&&(i.push("Audio will be transcribed to text"),o.push("Audio-to-text transcription")),n.hasFiles&&!c.media.files.supported&&(i.push("File content will be extracted to text"),o.push("File-to-text extraction")),n.hasUrls&&!c.media.urls.supported&&(i.push("URL content will be pre-fetched"),o.push("URL content fetching")),n.requiresStreaming&&!c.streaming&&s.push("Streaming not supported - will use non-streaming mode"),n.requiresCaching&&!c.caching.supported&&s.push("Content caching not supported"),{provider:a,processingApplied:o,degradations:i,warnings:s}}catch(a){throw new Error(`Provider selection failed: ${a instanceof Error?a.message:"Unknown error"}`)}}async tryFallbackProviders(e,t,n){for(let o of t)try{let i={provider:o,processingApplied:["Fallback provider selection"],degradations:["Using fallback provider due to primary provider failure"],warnings:[]},s=await this.preprocessRequest(e,o,{fallbackBehavior:"degrade"});return{response:await o.chat(s,n),routing:i}}catch{}throw new Error("All fallback providers failed")}async getRoutingRecommendation(e){return await this.selectProviderWithDegradation(e,{})}async validateRequest(e){let t=Mr(e),n=[],o=[];try{let i=await this.selectProviderWithDegradation(e,{});return i.degradations.length>0&&(n.push(...i.degradations),o.push("Consider using a provider that natively supports all media types")),i.warnings.length>0&&n.push(...i.warnings),t.hasImages&&this.processingServices.imageToText===void 0&&(this.providers.some(a=>a.getFeatures().media.images.supported)||(n.push("No image processing service available and no providers support images"),o.push("Add imageToText processing service or use image-capable provider"))),t.hasAudio&&this.processingServices.audioToText===void 0&&(this.providers.some(a=>a.getFeatures().media.audio.supported)||(n.push("No audio processing service available and no providers support audio"),o.push("Add audioToText processing service or use audio-capable provider"))),{canHandle:n.length===0||i.degradations.length>0,issues:n,recommendations:o}}catch(i){return{canHandle:!1,issues:[`Cannot route request: ${i instanceof Error?i.message:"Unknown error"}`],recommendations:["Add more providers or processing services to handle this request"]}}}getRoutingStats(){let e={};for(let t of this.providers){let n=t.getFeatures(),o=t.getName();n.functions&&(e.Functions=e.Functions||[],e.Functions.push(o)),n.streaming&&(e.Streaming=e.Streaming||[],e.Streaming.push(o)),n.media.images.supported&&(e.Images=e.Images||[],e.Images.push(o)),n.media.audio.supported&&(e.Audio=e.Audio||[],e.Audio.push(o)),n.media.files.supported&&(e.Files=e.Files||[],e.Files.push(o)),n.media.urls.supported&&(e.URLs=e.URLs||[],e.URLs.push(o)),n.caching.supported&&(e.Caching=e.Caching||[],e.Caching.push(o))}return{totalProviders:this.providers.length,capabilityMatrix:e,recommendedProvider:this.providers[0]?.getName()||"None"}}};var lm=()=>structuredClone({model:"Llama-3.2-3B-Instruct-q4f32_1-MLC",...Qe()}),sC=()=>structuredClone({model:"Llama-3.2-3B-Instruct-q4f32_1-MLC",...Zn()}),cm=class{constructor(e,t){this.config=e;this.engine=t}tokensUsed;engine;getTokenUsage(){return this.tokensUsed}getModelConfig(){let{config:e}=this;return{maxTokens:e.maxTokens,temperature:e.temperature,topP:e.topP,topK:e.topK,presencePenalty:e.presencePenalty,frequencyPenalty:e.frequencyPenalty,stopSequences:e.stopSequences,endSequences:e.endSequences,stream:e.stream,n:e.n}}createChatReq(e){let t=e.model,n=this.config.supportsFunctions??!1,o=e.chatPrompt.map(u=>{if(u.role==="function")return{role:"tool",tool_call_id:u.functionId,content:typeof u.result=="string"?u.result:JSON.stringify(u.result)};let d="";typeof u.content=="string"?d=u.content:Array.isArray(u.content)&&(d=u.content.filter(m=>m.type==="text").map(m=>m.text).join(`
|
|
1267
1267
|
`));let p={role:u.role,content:d};return u.role==="assistant"&&u.functionCalls?.length?{...p,tool_calls:u.functionCalls.map(m=>({id:m.id,type:"function",function:{name:m.function.name,arguments:typeof m.function.params=="string"?m.function.params:JSON.stringify(m.function.params||{})}}))}:p}),i=n?e.functions?.map(u=>({type:"function",function:{name:u.name,description:u.description,parameters:u.parameters||{type:"object",properties:{}}}})):void 0,s=n&&i?.length?e.functionCall===void 0?"auto":e.functionCall:void 0,a=this.createResponseFormat(e.responseFormat),c={name:"/chat/completions",localCall:async(u,d)=>{try{let p=await this.engine.chat.completions.create({...u,stream:d??!1});return d?this.toReadableStream(p):p}catch(p){let m=p instanceof Error?p.message:String(p);throw new Error(`WebLLM API error: ${m}`,{cause:p})}}},l={model:t,messages:o,...i?.length?{tools:i}:{},...s?{tool_choice:s}:{},...a?{response_format:a}:{},max_tokens:e.modelConfig?.maxTokens??this.config.maxTokens,...e.modelConfig?.temperature!==void 0?{temperature:e.modelConfig.temperature}:{},...e.modelConfig?.topP!==void 0?{top_p:e.modelConfig.topP}:{},presence_penalty:e.modelConfig?.presencePenalty??this.config.presencePenalty,frequency_penalty:e.modelConfig?.frequencyPenalty??this.config.frequencyPenalty,stop:e.modelConfig?.stopSequences??this.config.stopSequences,stream:e.modelConfig?.stream??this.config.stream,...e.modelConfig?.stream??this.config.stream?{stream_options:{include_usage:!0}}:{},n:e.modelConfig?.n??this.config.n,...this.config.logitBias!==void 0?{logit_bias:this.config.logitBias}:{},...this.config.logProbs!==void 0?{logprobs:this.config.logProbs}:{},...this.config.topLogprobs!==void 0?{top_logprobs:this.config.topLogprobs}:{}};return[c,l]}createResponseFormat(e){if(e?.type==="json_object")return{type:"json_object"};if(e?.type==="json_schema")return{type:"json_schema",json_schema:e.schema??e.json_schema}}toReadableStream(e){if(this.isReadableStream(e))return e;if(e&&typeof e[Symbol.asyncIterator]=="function")return new ReadableStream({async start(t){try{for await(let n of e)t.enqueue(n);t.close()}catch(n){t.error(n)}}});throw new Error("WebLLM streaming response is not async iterable")}isReadableStream(e){return e!==null&&typeof e=="object"&&typeof e.getReader=="function"}createEmbedReq=e=>{throw new Error("WebLLM does not support embeddings")};createChatResp=e=>(this.tokensUsed={promptTokens:e.usage?.prompt_tokens??0,completionTokens:e.usage?.completion_tokens??0,totalTokens:e.usage?.total_tokens??0},{results:e.choices.map((n,o)=>{let i="stop";switch(n.finish_reason){case"stop":i="stop";break;case"length":i="length";break;case"tool_calls":i="function_call";break;case"content_filter":i="content_filter";break;default:i="stop";break}let s=n.message.tool_calls?.map(a=>({id:a.id,type:"function",function:{name:a.function.name,params:a.function.arguments}}));return{index:o,id:e.id,content:n.message.content||"",functionCalls:s,finishReason:i,logprobs:n.logprobs?this.createLogprobs(n.logprobs):void 0}}),remoteId:e.id});createChatStreamResp=(e,t)=>{let n=t,o=e.choices[0];if(!o)throw new Error("No choice in WebLLM stream response");if(o.delta.content&&(n.content=(n.content||"")+o.delta.content),o.delta.tool_calls){n.toolCalls||(n.toolCalls=[]);for(let c of o.delta.tool_calls){let l=n.toolCalls[c.index];l?(l.id=c.id??l.id,l.type=c.type??l.type,l.function??={},l.function.name=c.function?.name??l.function.name,c.function?.arguments&&(l.function.arguments=(l.function?.arguments||"")+c.function.arguments)):n.toolCalls[c.index]={id:c.id,type:c.type,function:{name:c.function?.name,arguments:c.function?.arguments||""}}}}if(o.logprobs){let c=this.createLogprobs(o.logprobs);n.logprobs={content:[...n.logprobs?.content??[],...c.content??[]]}}e.usage&&(this.tokensUsed={promptTokens:e.usage.prompt_tokens,completionTokens:e.usage.completion_tokens,totalTokens:e.usage.total_tokens});let i;if(o.finish_reason)switch(o.finish_reason){case"stop":i="stop";break;case"length":i="length";break;case"tool_calls":i="function_call";break;case"content_filter":i="content_filter";break;default:i="stop";break}let s=n.toolCalls?.map(c=>({id:c.id||"",type:"function",function:{name:c.function?.name||"",params:c.function?.arguments||""}}));return{results:[{index:0,id:e.id,content:n.content||"",functionCalls:s,finishReason:i,logprobs:n.logprobs}],remoteId:e.id}};createLogprobs(e){return{content:e.content.map(t=>({token:t.token,logprob:t.logprob,topLogprobs:t.top_logprobs?.map(n=>({token:n.token,logprob:n.logprob}))}))}}createEmbedResp(e){throw new Error("WebLLM does not support embeddings")}},Qo=class extends vt{constructor({engine:e,config:t,options:n,models:o}){if(!e)throw new Error("WebLLM engine instance is required");let i={...lm(),...t},s=new cm(i,e);super(s,{name:"WebLLM",apiURL:void 0,headers:async()=>({}),modelInfo:Jo,defaults:{model:i.model},supportFor:a=>({functions:i.supportsFunctions??!1,streaming:!0,media:{images:{supported:!1,formats:[]},audio:{supported:!1,formats:[]},files:{supported:!1,formats:[],uploadMethod:"none"},urls:{supported:!1,webSearch:!1,contextFetching:!1}},caching:{supported:!1,types:[]},thinking:!1,multiTurn:!0}),options:n,models:o})}};function aC(r){return Os.create(r)}var Os=class r{ai;static create(e){return new r(e)}constructor(e){let t=el(e.name);switch(t.transport){case"openai-chat":t.id==="openai"?this.ai=new qo(e):this.ai=new Ho(e);break;case"openai-responses":t.id==="openai-responses"?this.ai=new zo(e):this.ai=new Wo(e);break;case"anthropic-messages":this.ai=new No(e);break;case"gemini-generate-content":this.ai=new Yo(e);break;case"webllm":this.ai=new Qo(e);break;default:throw new Error(`Unsupported AI transport: ${t.transport}`)}}getName(){return this.ai.getName()}getId(){return this.ai.getId()}getFeatures(e){return this.ai.getFeatures(e)}getModelList(){return this.ai.getModelList()}getLastUsedChatModel(){return this.ai.getLastUsedChatModel()}getLastUsedEmbedModel(){return this.ai.getLastUsedEmbedModel()}getLastUsedModelConfig(){return this.ai.getLastUsedModelConfig()}getMetrics(){return this.ai.getMetrics()}getEstimatedCost(e){return this.ai.getEstimatedCost(e)}async chat(e,t){return await this.ai.chat(e,t)}async embed(e,t){return await this.ai.embed(e,t)}async transcribe(e,t){return await this.ai.transcribe(e,t)}async speak(e,t){return await this.ai.speak(e,t)}setOptions(e){this.ai.setOptions(e)}getOptions(){return this.ai.getOptions()}getLogger(){return this.ai.getLogger()}};function cC(r,e){return r.filter(t=>!e.has(t))}function lC(r){let e={};for(let t of r)e[t]=(e[t]||0)+1;return e}function $r(r){let e=r.normalize("NFD");return e=e.replace(/\b(a|an|the)\b/g," "),e=e.split(/\s+/).join(" "),e=e.replace(/[!"#$%&'()*+,-./:;<=>?@[\]^_`{|}~]/g,""),e.toLowerCase()}function QP(r,e){return $r(r)===$r(e)?1:0}function ZP(r,e){let t=$r(r).split(" "),n=$r(e).split(" "),o=lC(t),i=lC(n),s=0;for(let l in o){let u=o[l]??0,d=i[l]??0;s+=Math.min(u,d)}if(s===0)return 0;let a=s/t.length,c=s/n.length;return 2*a*c/(a+c)}function XP(r,e,t,n=!1){let o=$r(r).split(" "),i=$r(e).split(" "),s=$r(t).split(" "),a=new Set([...nc,...o]);i=cC(i,a),s=cC(s,a);let c=0,l=c/i.length,u=c/s.length,d=2*l*u/(l+u);return n?u:d}var uC={emScore:QP,f1Score:ZP,novelF1ScoreOptimized:XP};var pl=class{ai;program;examples;constructor({ai:e,program:t,examples:n=[]}){if(n.length===0)throw new Error("No examples found");this.ai=e,this.program=t,this.examples=n}async run(e){let t=Date.now(),n=this.examples.length,o=0;for(let s=0;s<n;s++){let a=this.examples[s];if(!a)throw new Error("Invalid example");try{let c=await this.program.forward(this.ai,a,{maxRetries:1}),l=await e({prediction:c,example:a});o+=l}catch(c){console.warn(`Program evaluation failed for example ${s}: ${c instanceof Error?c.message:"Unknown error"}`)}}let i=n>0?o/n:0;this.ai.getOptions().debug&&console.log(`
|