@@ -17,6 +17,7 @@ import { processFilesToUserFiles } from '@/lib/uploads/utils/file'
1717import { downloadFileFromStorage } from '@/lib/uploads/utils/file.server'
1818import type { RawFileInput } from '@/lib/uploads/utils/file-schemas'
1919import { assertToolFileAccess } from '@/app/api/files/authorization'
20+ import { RETIRED_QUIVER_MODELS } from '@/tools/quiver/models'
2021import type { QuiverSvgResponse } from '@/tools/quiver/types'
2122
2223const logger = createLogger ( 'QuiverOperations' )
@@ -32,20 +33,19 @@ type ApiImage = { url: string } | { base64: string }
3233
3334export type QuiverSvgOutput = QuiverSvgResponse & { success : true }
3435
35- /**
36- * Arrow 1.x model IDs Quiver retired on 2026-10-16 (they now return 404 `model_not_found`).
37- * Saved blocks still carry them, so they are sent as `arrow-2`, the documented replacement.
38- */
39- const RETIRED_QUIVER_MODELS = new Set ( [
40- 'arrow-preview' ,
41- 'arrow-1' ,
42- 'arrow-1.0' ,
43- 'arrow-1.1' ,
44- 'arrow-1.1-max' ,
45- ] )
46-
4736function resolveModel ( model : string ) : string {
48- return RETIRED_QUIVER_MODELS . has ( model ) ? 'arrow-2' : model
37+ return ( RETIRED_QUIVER_MODELS as readonly string [ ] ) . includes ( model ) ? 'arrow-2' : model
38+ }
39+
40+ /** Arrow 2 Telos rejects these sampling fields with a 400 even when they hold the default. */
41+ function addSamplingParams (
42+ body : Record < string , unknown > ,
43+ input : Pick < QuiverTextToSvgInput , 'temperature' | 'top_p' | 'presence_penalty' >
44+ ) : void {
45+ if ( body . model === 'arrow-2-telos' ) return
46+ if ( input . temperature != null ) body . temperature = input . temperature
47+ if ( input . top_p != null ) body . top_p = input . top_p
48+ if ( input . presence_penalty != null ) body . presence_penalty = input . presence_penalty
4949}
5050
5151function fail ( message : string , status : number , body ?: Record < string , unknown > ) : never {
@@ -242,10 +242,8 @@ export async function executeQuiverTextToSvg(
242242 if ( input . instructions ) body . instructions = input . instructions
243243 if ( references . length > 0 ) body . references = references . slice ( 0 , 4 )
244244 if ( input . n != null ) body . n = input . n
245- if ( input . temperature != null ) body . temperature = input . temperature
246- if ( input . top_p != null ) body . top_p = input . top_p
245+ addSamplingParams ( body , input )
247246 if ( input . max_output_tokens != null ) body . max_output_tokens = input . max_output_tokens
248- if ( input . presence_penalty != null ) body . presence_penalty = input . presence_penalty
249247
250248 const result = await requestQuiverSvg ( 'generations' , input . apiKey , body , context . signal )
251249 context . signal ?. throwIfAborted ( )
@@ -274,10 +272,8 @@ export async function executeQuiverImageToSvg(
274272 validateProvenance ( input , context )
275273 const image = await resolveImage ( input . image , context )
276274 const body : Record < string , unknown > = { model : resolveModel ( input . model ) , image }
277- if ( input . temperature != null ) body . temperature = input . temperature
278- if ( input . top_p != null ) body . top_p = input . top_p
275+ addSamplingParams ( body , input )
279276 if ( input . max_output_tokens != null ) body . max_output_tokens = input . max_output_tokens
280- if ( input . presence_penalty != null ) body . presence_penalty = input . presence_penalty
281277 if ( input . auto_crop != null ) body . auto_crop = input . auto_crop
282278 if ( input . target_size != null ) body . target_size = input . target_size
283279
0 commit comments