transform.test.ts 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410
  1. import { describe, expect, test } from "bun:test"
  2. import { ProviderTransform } from "../../src/provider/transform"
  3. const OUTPUT_TOKEN_MAX = 32000
  4. describe("ProviderTransform.options - setCacheKey", () => {
  5. const sessionID = "test-session-123"
  6. const mockModel = {
  7. id: "anthropic/claude-3-5-sonnet",
  8. providerID: "anthropic",
  9. api: {
  10. id: "claude-3-5-sonnet-20241022",
  11. url: "https://api.anthropic.com",
  12. npm: "@ai-sdk/anthropic",
  13. },
  14. name: "Claude 3.5 Sonnet",
  15. capabilities: {
  16. temperature: true,
  17. reasoning: false,
  18. attachment: true,
  19. toolcall: true,
  20. input: { text: true, audio: false, image: true, video: false, pdf: true },
  21. output: { text: true, audio: false, image: false, video: false, pdf: false },
  22. interleaved: false,
  23. },
  24. cost: {
  25. input: 0.003,
  26. output: 0.015,
  27. cache: { read: 0.0003, write: 0.00375 },
  28. },
  29. limit: {
  30. context: 200000,
  31. output: 8192,
  32. },
  33. status: "active",
  34. options: {},
  35. headers: {},
  36. } as any
  37. test("should set promptCacheKey when providerOptions.setCacheKey is true", () => {
  38. const result = ProviderTransform.options({
  39. model: mockModel,
  40. sessionID,
  41. providerOptions: { setCacheKey: true },
  42. })
  43. expect(result.promptCacheKey).toBe(sessionID)
  44. })
  45. test("should not set promptCacheKey when providerOptions.setCacheKey is false", () => {
  46. const result = ProviderTransform.options({
  47. model: mockModel,
  48. sessionID,
  49. providerOptions: { setCacheKey: false },
  50. })
  51. expect(result.promptCacheKey).toBeUndefined()
  52. })
  53. test("should not set promptCacheKey when providerOptions is undefined", () => {
  54. const result = ProviderTransform.options({
  55. model: mockModel,
  56. sessionID,
  57. providerOptions: undefined,
  58. })
  59. expect(result.promptCacheKey).toBeUndefined()
  60. })
  61. test("should not set promptCacheKey when providerOptions does not have setCacheKey", () => {
  62. const result = ProviderTransform.options({ model: mockModel, sessionID, providerOptions: {} })
  63. expect(result.promptCacheKey).toBeUndefined()
  64. })
  65. test("should set promptCacheKey for openai provider regardless of setCacheKey", () => {
  66. const openaiModel = {
  67. ...mockModel,
  68. providerID: "openai",
  69. api: {
  70. id: "gpt-4",
  71. url: "https://api.openai.com",
  72. npm: "@ai-sdk/openai",
  73. },
  74. }
  75. const result = ProviderTransform.options({ model: openaiModel, sessionID, providerOptions: {} })
  76. expect(result.promptCacheKey).toBe(sessionID)
  77. })
  78. test("should set store=false for openai provider", () => {
  79. const openaiModel = {
  80. ...mockModel,
  81. providerID: "openai",
  82. api: {
  83. id: "gpt-4",
  84. url: "https://api.openai.com",
  85. npm: "@ai-sdk/openai",
  86. },
  87. }
  88. const result = ProviderTransform.options({
  89. model: openaiModel,
  90. sessionID,
  91. providerOptions: {},
  92. })
  93. expect(result.store).toBe(false)
  94. })
  95. })
  96. describe("ProviderTransform.maxOutputTokens", () => {
  97. test("returns 32k when modelLimit > 32k", () => {
  98. const modelLimit = 100000
  99. const result = ProviderTransform.maxOutputTokens("@ai-sdk/openai", {}, modelLimit, OUTPUT_TOKEN_MAX)
  100. expect(result).toBe(OUTPUT_TOKEN_MAX)
  101. })
  102. test("returns modelLimit when modelLimit < 32k", () => {
  103. const modelLimit = 16000
  104. const result = ProviderTransform.maxOutputTokens("@ai-sdk/openai", {}, modelLimit, OUTPUT_TOKEN_MAX)
  105. expect(result).toBe(16000)
  106. })
  107. describe("azure", () => {
  108. test("returns 32k when modelLimit > 32k", () => {
  109. const modelLimit = 100000
  110. const result = ProviderTransform.maxOutputTokens("@ai-sdk/azure", {}, modelLimit, OUTPUT_TOKEN_MAX)
  111. expect(result).toBe(OUTPUT_TOKEN_MAX)
  112. })
  113. test("returns modelLimit when modelLimit < 32k", () => {
  114. const modelLimit = 16000
  115. const result = ProviderTransform.maxOutputTokens("@ai-sdk/azure", {}, modelLimit, OUTPUT_TOKEN_MAX)
  116. expect(result).toBe(16000)
  117. })
  118. })
  119. describe("bedrock", () => {
  120. test("returns 32k when modelLimit > 32k", () => {
  121. const modelLimit = 100000
  122. const result = ProviderTransform.maxOutputTokens("@ai-sdk/amazon-bedrock", {}, modelLimit, OUTPUT_TOKEN_MAX)
  123. expect(result).toBe(OUTPUT_TOKEN_MAX)
  124. })
  125. test("returns modelLimit when modelLimit < 32k", () => {
  126. const modelLimit = 16000
  127. const result = ProviderTransform.maxOutputTokens("@ai-sdk/amazon-bedrock", {}, modelLimit, OUTPUT_TOKEN_MAX)
  128. expect(result).toBe(16000)
  129. })
  130. })
  131. describe("anthropic without thinking options", () => {
  132. test("returns 32k when modelLimit > 32k", () => {
  133. const modelLimit = 100000
  134. const result = ProviderTransform.maxOutputTokens("@ai-sdk/anthropic", {}, modelLimit, OUTPUT_TOKEN_MAX)
  135. expect(result).toBe(OUTPUT_TOKEN_MAX)
  136. })
  137. test("returns modelLimit when modelLimit < 32k", () => {
  138. const modelLimit = 16000
  139. const result = ProviderTransform.maxOutputTokens("@ai-sdk/anthropic", {}, modelLimit, OUTPUT_TOKEN_MAX)
  140. expect(result).toBe(16000)
  141. })
  142. })
  143. describe("anthropic with thinking options", () => {
  144. test("returns 32k when budgetTokens + 32k <= modelLimit", () => {
  145. const modelLimit = 100000
  146. const options = {
  147. thinking: {
  148. type: "enabled",
  149. budgetTokens: 10000,
  150. },
  151. }
  152. const result = ProviderTransform.maxOutputTokens("@ai-sdk/anthropic", options, modelLimit, OUTPUT_TOKEN_MAX)
  153. expect(result).toBe(OUTPUT_TOKEN_MAX)
  154. })
  155. test("returns modelLimit - budgetTokens when budgetTokens + 32k > modelLimit", () => {
  156. const modelLimit = 50000
  157. const options = {
  158. thinking: {
  159. type: "enabled",
  160. budgetTokens: 30000,
  161. },
  162. }
  163. const result = ProviderTransform.maxOutputTokens("@ai-sdk/anthropic", options, modelLimit, OUTPUT_TOKEN_MAX)
  164. expect(result).toBe(20000)
  165. })
  166. test("returns 32k when thinking type is not enabled", () => {
  167. const modelLimit = 100000
  168. const options = {
  169. thinking: {
  170. type: "disabled",
  171. budgetTokens: 10000,
  172. },
  173. }
  174. const result = ProviderTransform.maxOutputTokens("@ai-sdk/anthropic", options, modelLimit, OUTPUT_TOKEN_MAX)
  175. expect(result).toBe(OUTPUT_TOKEN_MAX)
  176. })
  177. })
  178. })
  179. describe("ProviderTransform.schema - gemini array items", () => {
  180. test("adds missing items for array properties", () => {
  181. const geminiModel = {
  182. providerID: "google",
  183. api: {
  184. id: "gemini-3-pro",
  185. },
  186. } as any
  187. const schema = {
  188. type: "object",
  189. properties: {
  190. nodes: { type: "array" },
  191. edges: { type: "array", items: { type: "string" } },
  192. },
  193. } as any
  194. const result = ProviderTransform.schema(geminiModel, schema) as any
  195. expect(result.properties.nodes.items).toBeDefined()
  196. expect(result.properties.edges.items.type).toBe("string")
  197. })
  198. })
  199. describe("ProviderTransform.message - DeepSeek reasoning content", () => {
  200. test("DeepSeek with tool calls includes reasoning_content in providerOptions", () => {
  201. const msgs = [
  202. {
  203. role: "assistant",
  204. content: [
  205. { type: "reasoning", text: "Let me think about this..." },
  206. {
  207. type: "tool-call",
  208. toolCallId: "test",
  209. toolName: "bash",
  210. input: { command: "echo hello" },
  211. },
  212. ],
  213. },
  214. ] as any[]
  215. const result = ProviderTransform.message(
  216. msgs,
  217. {
  218. id: "deepseek/deepseek-chat",
  219. providerID: "deepseek",
  220. api: {
  221. id: "deepseek-chat",
  222. url: "https://api.deepseek.com",
  223. npm: "@ai-sdk/openai-compatible",
  224. },
  225. name: "DeepSeek Chat",
  226. capabilities: {
  227. temperature: true,
  228. reasoning: true,
  229. attachment: false,
  230. toolcall: true,
  231. input: { text: true, audio: false, image: false, video: false, pdf: false },
  232. output: { text: true, audio: false, image: false, video: false, pdf: false },
  233. interleaved: {
  234. field: "reasoning_content",
  235. },
  236. },
  237. cost: {
  238. input: 0.001,
  239. output: 0.002,
  240. cache: { read: 0.0001, write: 0.0002 },
  241. },
  242. limit: {
  243. context: 128000,
  244. output: 8192,
  245. },
  246. status: "active",
  247. options: {},
  248. headers: {},
  249. release_date: "2023-04-01",
  250. },
  251. {},
  252. )
  253. expect(result).toHaveLength(1)
  254. expect(result[0].content).toEqual([
  255. {
  256. type: "tool-call",
  257. toolCallId: "test",
  258. toolName: "bash",
  259. input: { command: "echo hello" },
  260. },
  261. ])
  262. expect(result[0].providerOptions?.openaiCompatible?.reasoning_content).toBe("Let me think about this...")
  263. })
  264. test("Non-DeepSeek providers leave reasoning content unchanged", () => {
  265. const msgs = [
  266. {
  267. role: "assistant",
  268. content: [
  269. { type: "reasoning", text: "Should not be processed" },
  270. { type: "text", text: "Answer" },
  271. ],
  272. },
  273. ] as any[]
  274. const result = ProviderTransform.message(
  275. msgs,
  276. {
  277. id: "openai/gpt-4",
  278. providerID: "openai",
  279. api: {
  280. id: "gpt-4",
  281. url: "https://api.openai.com",
  282. npm: "@ai-sdk/openai",
  283. },
  284. name: "GPT-4",
  285. capabilities: {
  286. temperature: true,
  287. reasoning: false,
  288. attachment: true,
  289. toolcall: true,
  290. input: { text: true, audio: false, image: true, video: false, pdf: false },
  291. output: { text: true, audio: false, image: false, video: false, pdf: false },
  292. interleaved: false,
  293. },
  294. cost: {
  295. input: 0.03,
  296. output: 0.06,
  297. cache: { read: 0.001, write: 0.002 },
  298. },
  299. limit: {
  300. context: 128000,
  301. output: 4096,
  302. },
  303. status: "active",
  304. options: {},
  305. headers: {},
  306. release_date: "2023-04-01",
  307. },
  308. {},
  309. )
  310. expect(result[0].content).toEqual([
  311. { type: "reasoning", text: "Should not be processed" },
  312. { type: "text", text: "Answer" },
  313. ])
  314. expect(result[0].providerOptions?.openaiCompatible?.reasoning_content).toBeUndefined()
  315. })
  316. })
  317. describe("ProviderTransform.message - empty image handling", () => {
  318. const mockModel = {
  319. id: "anthropic/claude-3-5-sonnet",
  320. providerID: "anthropic",
  321. api: {
  322. id: "claude-3-5-sonnet-20241022",
  323. url: "https://api.anthropic.com",
  324. npm: "@ai-sdk/anthropic",
  325. },
  326. name: "Claude 3.5 Sonnet",
  327. capabilities: {
  328. temperature: true,
  329. reasoning: false,
  330. attachment: true,
  331. toolcall: true,
  332. input: { text: true, audio: false, image: true, video: false, pdf: true },
  333. output: { text: true, audio: false, image: false, video: false, pdf: false },
  334. interleaved: false,
  335. },
  336. cost: {
  337. input: 0.003,
  338. output: 0.015,
  339. cache: { read: 0.0003, write: 0.00375 },
  340. },
  341. limit: {
  342. context: 200000,
  343. output: 8192,
  344. },
  345. status: "active",
  346. options: {},
  347. headers: {},
  348. } as any
  349. test("should replace empty base64 image with error text", () => {
  350. const msgs = [
  351. {
  352. role: "user",
  353. content: [
  354. { type: "text", text: "What is in this image?" },
  355. { type: "image", image: "data:image/png;base64," },
  356. ],
  357. },
  358. ] as any[]
  359. const result = ProviderTransform.message(msgs, mockModel, {})
  360. expect(result).toHaveLength(1)
  361. expect(result[0].content).toHaveLength(2)
  362. expect(result[0].content[0]).toEqual({ type: "text", text: "What is in this image?" })
  363. expect(result[0].content[1]).toEqual({
  364. type: "text",
  365. text: "ERROR: Image file is empty or corrupted. Please provide a valid image.",
  366. })
  367. })
  368. test("should keep valid base64 images unchanged", () => {
  369. const validBase64 =
  370. "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
  371. const msgs = [
  372. {
  373. role: "user",
  374. content: [
  375. { type: "text", text: "What is in this image?" },
  376. { type: "image", image: `data:image/png;base64,${validBase64}` },
  377. ],
  378. },
  379. ] as any[]
  380. const result = ProviderTransform.message(msgs, mockModel, {})
  381. expect(result).toHaveLength(1)
  382. expect(result[0].content).toHaveLength(2)
  383. expect(result[0].content[0]).toEqual({ type: "text", text: "What is in this image?" })
  384. expect(result[0].content[1]).toEqual({ type: "image", image: `data:image/png;base64,${validBase64}` })
  385. })
  386. test("should handle mixed valid and empty images", () => {
  387. const validBase64 =
  388. "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
  389. const msgs = [
  390. {
  391. role: "user",
  392. content: [
  393. { type: "text", text: "Compare these images" },
  394. { type: "image", image: `data:image/png;base64,${validBase64}` },
  395. { type: "image", image: "data:image/jpeg;base64," },
  396. ],
  397. },
  398. ] as any[]
  399. const result = ProviderTransform.message(msgs, mockModel, {})
  400. expect(result).toHaveLength(1)
  401. expect(result[0].content).toHaveLength(3)
  402. expect(result[0].content[0]).toEqual({ type: "text", text: "Compare these images" })
  403. expect(result[0].content[1]).toEqual({ type: "image", image: `data:image/png;base64,${validBase64}` })
  404. expect(result[0].content[2]).toEqual({
  405. type: "text",
  406. text: "ERROR: Image file is empty or corrupted. Please provide a valid image.",
  407. })
  408. })
  409. })
  410. describe("ProviderTransform.message - anthropic empty content filtering", () => {
  411. const anthropicModel = {
  412. id: "anthropic/claude-3-5-sonnet",
  413. providerID: "anthropic",
  414. api: {
  415. id: "claude-3-5-sonnet-20241022",
  416. url: "https://api.anthropic.com",
  417. npm: "@ai-sdk/anthropic",
  418. },
  419. name: "Claude 3.5 Sonnet",
  420. capabilities: {
  421. temperature: true,
  422. reasoning: false,
  423. attachment: true,
  424. toolcall: true,
  425. input: { text: true, audio: false, image: true, video: false, pdf: true },
  426. output: { text: true, audio: false, image: false, video: false, pdf: false },
  427. interleaved: false,
  428. },
  429. cost: {
  430. input: 0.003,
  431. output: 0.015,
  432. cache: { read: 0.0003, write: 0.00375 },
  433. },
  434. limit: {
  435. context: 200000,
  436. output: 8192,
  437. },
  438. status: "active",
  439. options: {},
  440. headers: {},
  441. } as any
  442. test("filters out messages with empty string content", () => {
  443. const msgs = [
  444. { role: "user", content: "Hello" },
  445. { role: "assistant", content: "" },
  446. { role: "user", content: "World" },
  447. ] as any[]
  448. const result = ProviderTransform.message(msgs, anthropicModel, {})
  449. expect(result).toHaveLength(2)
  450. expect(result[0].content).toBe("Hello")
  451. expect(result[1].content).toBe("World")
  452. })
  453. test("filters out empty text parts from array content", () => {
  454. const msgs = [
  455. {
  456. role: "assistant",
  457. content: [
  458. { type: "text", text: "" },
  459. { type: "text", text: "Hello" },
  460. { type: "text", text: "" },
  461. ],
  462. },
  463. ] as any[]
  464. const result = ProviderTransform.message(msgs, anthropicModel, {})
  465. expect(result).toHaveLength(1)
  466. expect(result[0].content).toHaveLength(1)
  467. expect(result[0].content[0]).toEqual({ type: "text", text: "Hello" })
  468. })
  469. test("filters out empty reasoning parts from array content", () => {
  470. const msgs = [
  471. {
  472. role: "assistant",
  473. content: [
  474. { type: "reasoning", text: "" },
  475. { type: "text", text: "Answer" },
  476. { type: "reasoning", text: "" },
  477. ],
  478. },
  479. ] as any[]
  480. const result = ProviderTransform.message(msgs, anthropicModel, {})
  481. expect(result).toHaveLength(1)
  482. expect(result[0].content).toHaveLength(1)
  483. expect(result[0].content[0]).toEqual({ type: "text", text: "Answer" })
  484. })
  485. test("removes entire message when all parts are empty", () => {
  486. const msgs = [
  487. { role: "user", content: "Hello" },
  488. {
  489. role: "assistant",
  490. content: [
  491. { type: "text", text: "" },
  492. { type: "reasoning", text: "" },
  493. ],
  494. },
  495. { role: "user", content: "World" },
  496. ] as any[]
  497. const result = ProviderTransform.message(msgs, anthropicModel, {})
  498. expect(result).toHaveLength(2)
  499. expect(result[0].content).toBe("Hello")
  500. expect(result[1].content).toBe("World")
  501. })
  502. test("keeps non-text/reasoning parts even if text parts are empty", () => {
  503. const msgs = [
  504. {
  505. role: "assistant",
  506. content: [
  507. { type: "text", text: "" },
  508. { type: "tool-call", toolCallId: "123", toolName: "bash", input: { command: "ls" } },
  509. ],
  510. },
  511. ] as any[]
  512. const result = ProviderTransform.message(msgs, anthropicModel, {})
  513. expect(result).toHaveLength(1)
  514. expect(result[0].content).toHaveLength(1)
  515. expect(result[0].content[0]).toEqual({
  516. type: "tool-call",
  517. toolCallId: "123",
  518. toolName: "bash",
  519. input: { command: "ls" },
  520. })
  521. })
  522. test("keeps messages with valid text alongside empty parts", () => {
  523. const msgs = [
  524. {
  525. role: "assistant",
  526. content: [
  527. { type: "reasoning", text: "Thinking..." },
  528. { type: "text", text: "" },
  529. { type: "text", text: "Result" },
  530. ],
  531. },
  532. ] as any[]
  533. const result = ProviderTransform.message(msgs, anthropicModel, {})
  534. expect(result).toHaveLength(1)
  535. expect(result[0].content).toHaveLength(2)
  536. expect(result[0].content[0]).toEqual({ type: "reasoning", text: "Thinking..." })
  537. expect(result[0].content[1]).toEqual({ type: "text", text: "Result" })
  538. })
  539. test("does not filter for non-anthropic providers", () => {
  540. const openaiModel = {
  541. ...anthropicModel,
  542. providerID: "openai",
  543. api: {
  544. id: "gpt-4",
  545. url: "https://api.openai.com",
  546. npm: "@ai-sdk/openai",
  547. },
  548. }
  549. const msgs = [
  550. { role: "assistant", content: "" },
  551. {
  552. role: "assistant",
  553. content: [{ type: "text", text: "" }],
  554. },
  555. ] as any[]
  556. const result = ProviderTransform.message(msgs, openaiModel, {})
  557. expect(result).toHaveLength(2)
  558. expect(result[0].content).toBe("")
  559. expect(result[1].content).toHaveLength(1)
  560. })
  561. })
  562. describe("ProviderTransform.message - strip openai metadata when store=false", () => {
  563. const openaiModel = {
  564. id: "openai/gpt-5",
  565. providerID: "openai",
  566. api: {
  567. id: "gpt-5",
  568. url: "https://api.openai.com",
  569. npm: "@ai-sdk/openai",
  570. },
  571. name: "GPT-5",
  572. capabilities: {
  573. temperature: true,
  574. reasoning: true,
  575. attachment: true,
  576. toolcall: true,
  577. input: { text: true, audio: false, image: true, video: false, pdf: false },
  578. output: { text: true, audio: false, image: false, video: false, pdf: false },
  579. interleaved: false,
  580. },
  581. cost: { input: 0.03, output: 0.06, cache: { read: 0.001, write: 0.002 } },
  582. limit: { context: 128000, output: 4096 },
  583. status: "active",
  584. options: {},
  585. headers: {},
  586. } as any
  587. test("strips itemId and reasoningEncryptedContent when store=false", () => {
  588. const msgs = [
  589. {
  590. role: "assistant",
  591. content: [
  592. {
  593. type: "reasoning",
  594. text: "thinking...",
  595. providerOptions: {
  596. openai: {
  597. itemId: "rs_123",
  598. reasoningEncryptedContent: "encrypted",
  599. },
  600. },
  601. },
  602. {
  603. type: "text",
  604. text: "Hello",
  605. providerOptions: {
  606. openai: {
  607. itemId: "msg_456",
  608. },
  609. },
  610. },
  611. ],
  612. },
  613. ] as any[]
  614. const result = ProviderTransform.message(msgs, openaiModel, { store: false }) as any[]
  615. expect(result).toHaveLength(1)
  616. expect(result[0].content[0].providerOptions?.openai?.itemId).toBeUndefined()
  617. expect(result[0].content[0].providerOptions?.openai?.reasoningEncryptedContent).toBeUndefined()
  618. expect(result[0].content[1].providerOptions?.openai?.itemId).toBeUndefined()
  619. })
  620. test("strips itemId and reasoningEncryptedContent when store=false even when not openai", () => {
  621. const zenModel = {
  622. ...openaiModel,
  623. providerID: "zen",
  624. }
  625. const msgs = [
  626. {
  627. role: "assistant",
  628. content: [
  629. {
  630. type: "reasoning",
  631. text: "thinking...",
  632. providerOptions: {
  633. openai: {
  634. itemId: "rs_123",
  635. reasoningEncryptedContent: "encrypted",
  636. },
  637. },
  638. },
  639. {
  640. type: "text",
  641. text: "Hello",
  642. providerOptions: {
  643. openai: {
  644. itemId: "msg_456",
  645. },
  646. },
  647. },
  648. ],
  649. },
  650. ] as any[]
  651. const result = ProviderTransform.message(msgs, zenModel, { store: false }) as any[]
  652. expect(result).toHaveLength(1)
  653. expect(result[0].content[0].providerOptions?.openai?.itemId).toBeUndefined()
  654. expect(result[0].content[0].providerOptions?.openai?.reasoningEncryptedContent).toBeUndefined()
  655. expect(result[0].content[1].providerOptions?.openai?.itemId).toBeUndefined()
  656. })
  657. test("preserves other openai options when stripping itemId", () => {
  658. const msgs = [
  659. {
  660. role: "assistant",
  661. content: [
  662. {
  663. type: "text",
  664. text: "Hello",
  665. providerOptions: {
  666. openai: {
  667. itemId: "msg_123",
  668. otherOption: "value",
  669. },
  670. },
  671. },
  672. ],
  673. },
  674. ] as any[]
  675. const result = ProviderTransform.message(msgs, openaiModel, { store: false }) as any[]
  676. expect(result[0].content[0].providerOptions?.openai?.itemId).toBeUndefined()
  677. expect(result[0].content[0].providerOptions?.openai?.otherOption).toBe("value")
  678. })
  679. test("strips metadata for openai package even when store is true", () => {
  680. const msgs = [
  681. {
  682. role: "assistant",
  683. content: [
  684. {
  685. type: "text",
  686. text: "Hello",
  687. providerOptions: {
  688. openai: {
  689. itemId: "msg_123",
  690. },
  691. },
  692. },
  693. ],
  694. },
  695. ] as any[]
  696. // openai package always strips itemId regardless of store value
  697. const result = ProviderTransform.message(msgs, openaiModel, { store: true }) as any[]
  698. expect(result[0].content[0].providerOptions?.openai?.itemId).toBeUndefined()
  699. })
  700. test("strips metadata for non-openai packages when store is false", () => {
  701. const anthropicModel = {
  702. ...openaiModel,
  703. providerID: "anthropic",
  704. api: {
  705. id: "claude-3",
  706. url: "https://api.anthropic.com",
  707. npm: "@ai-sdk/anthropic",
  708. },
  709. }
  710. const msgs = [
  711. {
  712. role: "assistant",
  713. content: [
  714. {
  715. type: "text",
  716. text: "Hello",
  717. providerOptions: {
  718. openai: {
  719. itemId: "msg_123",
  720. },
  721. },
  722. },
  723. ],
  724. },
  725. ] as any[]
  726. // store=false triggers stripping even for non-openai packages
  727. const result = ProviderTransform.message(msgs, anthropicModel, { store: false }) as any[]
  728. expect(result[0].content[0].providerOptions?.openai?.itemId).toBeUndefined()
  729. })
  730. test("does not strip metadata for non-openai packages when store is not false", () => {
  731. const anthropicModel = {
  732. ...openaiModel,
  733. providerID: "anthropic",
  734. api: {
  735. id: "claude-3",
  736. url: "https://api.anthropic.com",
  737. npm: "@ai-sdk/anthropic",
  738. },
  739. }
  740. const msgs = [
  741. {
  742. role: "assistant",
  743. content: [
  744. {
  745. type: "text",
  746. text: "Hello",
  747. providerOptions: {
  748. openai: {
  749. itemId: "msg_123",
  750. },
  751. },
  752. },
  753. ],
  754. },
  755. ] as any[]
  756. const result = ProviderTransform.message(msgs, anthropicModel, {}) as any[]
  757. expect(result[0].content[0].providerOptions?.openai?.itemId).toBe("msg_123")
  758. })
  759. })
  760. describe("ProviderTransform.variants", () => {
  761. const createMockModel = (overrides: Partial<any> = {}): any => ({
  762. id: "test/test-model",
  763. providerID: "test",
  764. api: {
  765. id: "test-model",
  766. url: "https://api.test.com",
  767. npm: "@ai-sdk/openai",
  768. },
  769. name: "Test Model",
  770. capabilities: {
  771. temperature: true,
  772. reasoning: true,
  773. attachment: true,
  774. toolcall: true,
  775. input: { text: true, audio: false, image: true, video: false, pdf: false },
  776. output: { text: true, audio: false, image: false, video: false, pdf: false },
  777. interleaved: false,
  778. },
  779. cost: {
  780. input: 0.001,
  781. output: 0.002,
  782. cache: { read: 0.0001, write: 0.0002 },
  783. },
  784. limit: {
  785. context: 128000,
  786. output: 8192,
  787. },
  788. status: "active",
  789. options: {},
  790. headers: {},
  791. release_date: "2024-01-01",
  792. ...overrides,
  793. })
  794. test("returns empty object when model has no reasoning capabilities", () => {
  795. const model = createMockModel({
  796. capabilities: { reasoning: false },
  797. })
  798. const result = ProviderTransform.variants(model)
  799. expect(result).toEqual({})
  800. })
  801. test("deepseek returns empty object", () => {
  802. const model = createMockModel({
  803. id: "deepseek/deepseek-chat",
  804. providerID: "deepseek",
  805. api: {
  806. id: "deepseek-chat",
  807. url: "https://api.deepseek.com",
  808. npm: "@ai-sdk/openai-compatible",
  809. },
  810. })
  811. const result = ProviderTransform.variants(model)
  812. expect(result).toEqual({})
  813. })
  814. test("minimax returns empty object", () => {
  815. const model = createMockModel({
  816. id: "minimax/minimax-model",
  817. providerID: "minimax",
  818. api: {
  819. id: "minimax-model",
  820. url: "https://api.minimax.com",
  821. npm: "@ai-sdk/openai-compatible",
  822. },
  823. })
  824. const result = ProviderTransform.variants(model)
  825. expect(result).toEqual({})
  826. })
  827. test("glm returns empty object", () => {
  828. const model = createMockModel({
  829. id: "glm/glm-4",
  830. providerID: "glm",
  831. api: {
  832. id: "glm-4",
  833. url: "https://api.glm.com",
  834. npm: "@ai-sdk/openai-compatible",
  835. },
  836. })
  837. const result = ProviderTransform.variants(model)
  838. expect(result).toEqual({})
  839. })
  840. test("mistral returns empty object", () => {
  841. const model = createMockModel({
  842. id: "mistral/mistral-large",
  843. providerID: "mistral",
  844. api: {
  845. id: "mistral-large-latest",
  846. url: "https://api.mistral.com",
  847. npm: "@ai-sdk/mistral",
  848. },
  849. })
  850. const result = ProviderTransform.variants(model)
  851. expect(result).toEqual({})
  852. })
  853. describe("@openrouter/ai-sdk-provider", () => {
  854. test("returns empty object for non-qualifying models", () => {
  855. const model = createMockModel({
  856. id: "openrouter/test-model",
  857. providerID: "openrouter",
  858. api: {
  859. id: "test-model",
  860. url: "https://openrouter.ai",
  861. npm: "@openrouter/ai-sdk-provider",
  862. },
  863. })
  864. const result = ProviderTransform.variants(model)
  865. expect(result).toEqual({})
  866. })
  867. test("gpt models return OPENAI_EFFORTS with reasoning", () => {
  868. const model = createMockModel({
  869. id: "openrouter/gpt-4",
  870. providerID: "openrouter",
  871. api: {
  872. id: "gpt-4",
  873. url: "https://openrouter.ai",
  874. npm: "@openrouter/ai-sdk-provider",
  875. },
  876. })
  877. const result = ProviderTransform.variants(model)
  878. expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
  879. expect(result.low).toEqual({ reasoning: { effort: "low" } })
  880. expect(result.high).toEqual({ reasoning: { effort: "high" } })
  881. })
  882. test("gemini-3 returns OPENAI_EFFORTS with reasoning", () => {
  883. const model = createMockModel({
  884. id: "openrouter/gemini-3-5-pro",
  885. providerID: "openrouter",
  886. api: {
  887. id: "gemini-3-5-pro",
  888. url: "https://openrouter.ai",
  889. npm: "@openrouter/ai-sdk-provider",
  890. },
  891. })
  892. const result = ProviderTransform.variants(model)
  893. expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
  894. })
  895. test("grok-4 returns OPENAI_EFFORTS with reasoning", () => {
  896. const model = createMockModel({
  897. id: "openrouter/grok-4",
  898. providerID: "openrouter",
  899. api: {
  900. id: "grok-4",
  901. url: "https://openrouter.ai",
  902. npm: "@openrouter/ai-sdk-provider",
  903. },
  904. })
  905. const result = ProviderTransform.variants(model)
  906. expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
  907. })
  908. })
  909. describe("@ai-sdk/gateway", () => {
  910. test("returns OPENAI_EFFORTS with reasoningEffort", () => {
  911. const model = createMockModel({
  912. id: "gateway/gateway-model",
  913. providerID: "gateway",
  914. api: {
  915. id: "gateway-model",
  916. url: "https://gateway.ai",
  917. npm: "@ai-sdk/gateway",
  918. },
  919. })
  920. const result = ProviderTransform.variants(model)
  921. expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
  922. expect(result.low).toEqual({ reasoningEffort: "low" })
  923. expect(result.high).toEqual({ reasoningEffort: "high" })
  924. })
  925. })
  926. describe("@ai-sdk/cerebras", () => {
  927. test("returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
  928. const model = createMockModel({
  929. id: "cerebras/llama-4",
  930. providerID: "cerebras",
  931. api: {
  932. id: "llama-4-sc",
  933. url: "https://api.cerebras.ai",
  934. npm: "@ai-sdk/cerebras",
  935. },
  936. })
  937. const result = ProviderTransform.variants(model)
  938. expect(Object.keys(result)).toEqual(["low", "medium", "high"])
  939. expect(result.low).toEqual({ reasoningEffort: "low" })
  940. expect(result.high).toEqual({ reasoningEffort: "high" })
  941. })
  942. })
  943. describe("@ai-sdk/togetherai", () => {
  944. test("returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
  945. const model = createMockModel({
  946. id: "togetherai/llama-4",
  947. providerID: "togetherai",
  948. api: {
  949. id: "llama-4-sc",
  950. url: "https://api.togetherai.com",
  951. npm: "@ai-sdk/togetherai",
  952. },
  953. })
  954. const result = ProviderTransform.variants(model)
  955. expect(Object.keys(result)).toEqual(["low", "medium", "high"])
  956. expect(result.low).toEqual({ reasoningEffort: "low" })
  957. expect(result.high).toEqual({ reasoningEffort: "high" })
  958. })
  959. })
  960. describe("@ai-sdk/xai", () => {
  961. test("returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
  962. const model = createMockModel({
  963. id: "xai/grok-3",
  964. providerID: "xai",
  965. api: {
  966. id: "grok-3",
  967. url: "https://api.x.ai",
  968. npm: "@ai-sdk/xai",
  969. },
  970. })
  971. const result = ProviderTransform.variants(model)
  972. expect(Object.keys(result)).toEqual(["low", "medium", "high"])
  973. expect(result.low).toEqual({ reasoningEffort: "low" })
  974. expect(result.high).toEqual({ reasoningEffort: "high" })
  975. })
  976. })
  977. describe("@ai-sdk/deepinfra", () => {
  978. test("returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
  979. const model = createMockModel({
  980. id: "deepinfra/llama-4",
  981. providerID: "deepinfra",
  982. api: {
  983. id: "llama-4-sc",
  984. url: "https://api.deepinfra.com",
  985. npm: "@ai-sdk/deepinfra",
  986. },
  987. })
  988. const result = ProviderTransform.variants(model)
  989. expect(Object.keys(result)).toEqual(["low", "medium", "high"])
  990. expect(result.low).toEqual({ reasoningEffort: "low" })
  991. expect(result.high).toEqual({ reasoningEffort: "high" })
  992. })
  993. })
  994. describe("@ai-sdk/openai-compatible", () => {
  995. test("returns WIDELY_SUPPORTED_EFFORTS with reasoningEffort", () => {
  996. const model = createMockModel({
  997. id: "custom-provider/custom-model",
  998. providerID: "custom-provider",
  999. api: {
  1000. id: "custom-model",
  1001. url: "https://api.custom.com",
  1002. npm: "@ai-sdk/openai-compatible",
  1003. },
  1004. })
  1005. const result = ProviderTransform.variants(model)
  1006. expect(Object.keys(result)).toEqual(["low", "medium", "high"])
  1007. expect(result.low).toEqual({ reasoningEffort: "low" })
  1008. expect(result.high).toEqual({ reasoningEffort: "high" })
  1009. })
  1010. })
  1011. describe("@ai-sdk/azure", () => {
  1012. test("o1-mini returns empty object", () => {
  1013. const model = createMockModel({
  1014. id: "o1-mini",
  1015. providerID: "azure",
  1016. api: {
  1017. id: "o1-mini",
  1018. url: "https://azure.com",
  1019. npm: "@ai-sdk/azure",
  1020. },
  1021. })
  1022. const result = ProviderTransform.variants(model)
  1023. expect(result).toEqual({})
  1024. })
  1025. test("standard azure models return custom efforts with reasoningSummary", () => {
  1026. const model = createMockModel({
  1027. id: "o1",
  1028. providerID: "azure",
  1029. api: {
  1030. id: "o1",
  1031. url: "https://azure.com",
  1032. npm: "@ai-sdk/azure",
  1033. },
  1034. })
  1035. const result = ProviderTransform.variants(model)
  1036. expect(Object.keys(result)).toEqual(["low", "medium", "high"])
  1037. expect(result.low).toEqual({
  1038. reasoningEffort: "low",
  1039. reasoningSummary: "auto",
  1040. include: ["reasoning.encrypted_content"],
  1041. })
  1042. })
  1043. test("gpt-5 adds minimal effort", () => {
  1044. const model = createMockModel({
  1045. id: "gpt-5",
  1046. providerID: "azure",
  1047. api: {
  1048. id: "gpt-5",
  1049. url: "https://azure.com",
  1050. npm: "@ai-sdk/azure",
  1051. },
  1052. })
  1053. const result = ProviderTransform.variants(model)
  1054. expect(Object.keys(result)).toEqual(["minimal", "low", "medium", "high"])
  1055. })
  1056. })
  1057. describe("@ai-sdk/openai", () => {
  1058. test("gpt-5-pro returns empty object", () => {
  1059. const model = createMockModel({
  1060. id: "gpt-5-pro",
  1061. providerID: "openai",
  1062. api: {
  1063. id: "gpt-5-pro",
  1064. url: "https://api.openai.com",
  1065. npm: "@ai-sdk/openai",
  1066. },
  1067. })
  1068. const result = ProviderTransform.variants(model)
  1069. expect(result).toEqual({})
  1070. })
  1071. test("standard openai models return custom efforts with reasoningSummary", () => {
  1072. const model = createMockModel({
  1073. id: "gpt-5",
  1074. providerID: "openai",
  1075. api: {
  1076. id: "gpt-5",
  1077. url: "https://api.openai.com",
  1078. npm: "@ai-sdk/openai",
  1079. },
  1080. release_date: "2024-06-01",
  1081. })
  1082. const result = ProviderTransform.variants(model)
  1083. expect(Object.keys(result)).toEqual(["minimal", "low", "medium", "high"])
  1084. expect(result.low).toEqual({
  1085. reasoningEffort: "low",
  1086. reasoningSummary: "auto",
  1087. include: ["reasoning.encrypted_content"],
  1088. })
  1089. })
  1090. test("models after 2025-11-13 include 'none' effort", () => {
  1091. const model = createMockModel({
  1092. id: "gpt-5-nano",
  1093. providerID: "openai",
  1094. api: {
  1095. id: "gpt-5-nano",
  1096. url: "https://api.openai.com",
  1097. npm: "@ai-sdk/openai",
  1098. },
  1099. release_date: "2025-11-14",
  1100. })
  1101. const result = ProviderTransform.variants(model)
  1102. expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high"])
  1103. })
  1104. test("models after 2025-12-04 include 'xhigh' effort", () => {
  1105. const model = createMockModel({
  1106. id: "openai/gpt-5-chat",
  1107. providerID: "openai",
  1108. api: {
  1109. id: "gpt-5-chat",
  1110. url: "https://api.openai.com",
  1111. npm: "@ai-sdk/openai",
  1112. },
  1113. release_date: "2025-12-05",
  1114. })
  1115. const result = ProviderTransform.variants(model)
  1116. expect(Object.keys(result)).toEqual(["none", "minimal", "low", "medium", "high", "xhigh"])
  1117. })
  1118. })
  1119. describe("@ai-sdk/anthropic", () => {
  1120. test("returns high and max with thinking config", () => {
  1121. const model = createMockModel({
  1122. id: "anthropic/claude-4",
  1123. providerID: "anthropic",
  1124. api: {
  1125. id: "claude-4",
  1126. url: "https://api.anthropic.com",
  1127. npm: "@ai-sdk/anthropic",
  1128. },
  1129. })
  1130. const result = ProviderTransform.variants(model)
  1131. expect(Object.keys(result)).toEqual(["high", "max"])
  1132. expect(result.high).toEqual({
  1133. thinking: {
  1134. type: "enabled",
  1135. budgetTokens: 16000,
  1136. },
  1137. })
  1138. expect(result.max).toEqual({
  1139. thinking: {
  1140. type: "enabled",
  1141. budgetTokens: 31999,
  1142. },
  1143. })
  1144. })
  1145. })
  1146. describe("@ai-sdk/amazon-bedrock", () => {
  1147. test("returns WIDELY_SUPPORTED_EFFORTS with reasoningConfig", () => {
  1148. const model = createMockModel({
  1149. id: "bedrock/llama-4",
  1150. providerID: "bedrock",
  1151. api: {
  1152. id: "llama-4-sc",
  1153. url: "https://bedrock.amazonaws.com",
  1154. npm: "@ai-sdk/amazon-bedrock",
  1155. },
  1156. })
  1157. const result = ProviderTransform.variants(model)
  1158. expect(Object.keys(result)).toEqual(["low", "medium", "high"])
  1159. expect(result.low).toEqual({
  1160. reasoningConfig: {
  1161. type: "enabled",
  1162. maxReasoningEffort: "low",
  1163. },
  1164. })
  1165. })
  1166. })
  1167. describe("@ai-sdk/google", () => {
  1168. test("gemini-2.5 returns high and max with thinkingConfig and thinkingBudget", () => {
  1169. const model = createMockModel({
  1170. id: "google/gemini-2.5-pro",
  1171. providerID: "google",
  1172. api: {
  1173. id: "gemini-2.5-pro",
  1174. url: "https://generativelanguage.googleapis.com",
  1175. npm: "@ai-sdk/google",
  1176. },
  1177. })
  1178. const result = ProviderTransform.variants(model)
  1179. expect(Object.keys(result)).toEqual(["high", "max"])
  1180. expect(result.high).toEqual({
  1181. thinkingConfig: {
  1182. includeThoughts: true,
  1183. thinkingBudget: 16000,
  1184. },
  1185. })
  1186. expect(result.max).toEqual({
  1187. thinkingConfig: {
  1188. includeThoughts: true,
  1189. thinkingBudget: 24576,
  1190. },
  1191. })
  1192. })
  1193. test("other gemini models return low and high with thinkingLevel", () => {
  1194. const model = createMockModel({
  1195. id: "google/gemini-2.0-pro",
  1196. providerID: "google",
  1197. api: {
  1198. id: "gemini-2.0-pro",
  1199. url: "https://generativelanguage.googleapis.com",
  1200. npm: "@ai-sdk/google",
  1201. },
  1202. })
  1203. const result = ProviderTransform.variants(model)
  1204. expect(Object.keys(result)).toEqual(["low", "high"])
  1205. expect(result.low).toEqual({
  1206. includeThoughts: true,
  1207. thinkingLevel: "low",
  1208. })
  1209. expect(result.high).toEqual({
  1210. includeThoughts: true,
  1211. thinkingLevel: "high",
  1212. })
  1213. })
  1214. })
  1215. describe("@ai-sdk/google-vertex", () => {
  1216. test("gemini-2.5 returns high and max with thinkingConfig and thinkingBudget", () => {
  1217. const model = createMockModel({
  1218. id: "google-vertex/gemini-2.5-pro",
  1219. providerID: "google-vertex",
  1220. api: {
  1221. id: "gemini-2.5-pro",
  1222. url: "https://vertexai.googleapis.com",
  1223. npm: "@ai-sdk/google-vertex",
  1224. },
  1225. })
  1226. const result = ProviderTransform.variants(model)
  1227. expect(Object.keys(result)).toEqual(["high", "max"])
  1228. })
  1229. test("other vertex models return low and high with thinkingLevel", () => {
  1230. const model = createMockModel({
  1231. id: "google-vertex/gemini-2.0-pro",
  1232. providerID: "google-vertex",
  1233. api: {
  1234. id: "gemini-2.0-pro",
  1235. url: "https://vertexai.googleapis.com",
  1236. npm: "@ai-sdk/google-vertex",
  1237. },
  1238. })
  1239. const result = ProviderTransform.variants(model)
  1240. expect(Object.keys(result)).toEqual(["low", "high"])
  1241. })
  1242. })
  1243. describe("@ai-sdk/cohere", () => {
  1244. test("returns empty object", () => {
  1245. const model = createMockModel({
  1246. id: "cohere/command-r",
  1247. providerID: "cohere",
  1248. api: {
  1249. id: "command-r",
  1250. url: "https://api.cohere.com",
  1251. npm: "@ai-sdk/cohere",
  1252. },
  1253. })
  1254. const result = ProviderTransform.variants(model)
  1255. expect(result).toEqual({})
  1256. })
  1257. })
  1258. describe("@ai-sdk/groq", () => {
  1259. test("returns none and WIDELY_SUPPORTED_EFFORTS with thinkingLevel", () => {
  1260. const model = createMockModel({
  1261. id: "groq/llama-4",
  1262. providerID: "groq",
  1263. api: {
  1264. id: "llama-4-sc",
  1265. url: "https://api.groq.com",
  1266. npm: "@ai-sdk/groq",
  1267. },
  1268. })
  1269. const result = ProviderTransform.variants(model)
  1270. expect(Object.keys(result)).toEqual(["none", "low", "medium", "high"])
  1271. expect(result.none).toEqual({
  1272. includeThoughts: true,
  1273. thinkingLevel: "none",
  1274. })
  1275. expect(result.low).toEqual({
  1276. includeThoughts: true,
  1277. thinkingLevel: "low",
  1278. })
  1279. })
  1280. })
  1281. describe("@ai-sdk/perplexity", () => {
  1282. test("returns empty object", () => {
  1283. const model = createMockModel({
  1284. id: "perplexity/sonar-plus",
  1285. providerID: "perplexity",
  1286. api: {
  1287. id: "sonar-plus",
  1288. url: "https://api.perplexity.ai",
  1289. npm: "@ai-sdk/perplexity",
  1290. },
  1291. })
  1292. const result = ProviderTransform.variants(model)
  1293. expect(result).toEqual({})
  1294. })
  1295. })
  1296. })