[FEATURE] config.price cannot set image prices

Aperta Adatta ai principianti
#1,713 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@alfredszhao-art ci sta già lavorando.

Dal 26/11/2026.

  • #1858 di @alfredszhao-art — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
69/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
ruby

Direzione di ricerca

Leggi Model::Pricing::OVERRIDES e la gestione esistente di config.price, poi verifica come Cost legge i prezzi delle immagini, come descritto nell’issue. Aggiungi il supporto per gli override image_input e image_output, associati alla categoria images, ed esegui i test di pricing pertinenti. Il lavoro è completato quando entrambe le opzioni vengono accettate e i costi delle immagini usano le tariffe configurate.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

enhancement
Scope check
  • This is core LLM communication (not application logic)
  • This benefits most users (not just my use case)
  • This can't be solved in application code with current RubyLLM
  • I read the Contributing Guide
Due diligence
  • I searched existing issues
  • I checked the documentation
What problem does this solve?

Cost prices an image from model.pricing.images and falls back to the text prices when that category is empty (Cost#output_price, #image_input_parts). config.price can write every other category, but not that one:

RubyLLM.configure { |c| c.price "gpt-image-2", provider: :openai, images: 40 }
# ArgumentError: Unknown price: images. Valid prices: input, output, cache_read,
# cache_write, characters, audio_seconds, search_units

It matters for models that bill image tokens at another rate than text. In 2.2.3's registry:

RubyLLM.models.find("gemini-3-pro-image", provider: :gemini).pricing.to_h
# => {text_tokens: {standard: {input_per_million: 2, output_per_million: 12}}}
RubyLLM.models.find("gpt-image-2", provider: :openai).pricing.to_h
# => {}

The registry at an earlier 2.2 commit priced gemini-3-pro-image output at 120. models.dev now lists the text rate there, so RubyLLM.paint(...).cost.total comes out at a tenth of the image rate. The only way to correct it today is config.price "gemini-3-pro-image", provider: :gemini, output: 120, which also reprices the same model's text and thinking output in chats.

Proposed solution

Two more keys on config.price, mapped into the images category the way characters maps into its own:

config.price "gemini-3-pro-image", provider: :gemini, image_output: 120
config.price "gpt-image-2", provider: :openai, input: 5, image_input: 8, image_output: 30

In Model::Pricing::OVERRIDES that is image_input: %i[images input_per_million] and image_output: %i[images output_per_million]. Cost already reads both.

Why this belongs in RubyLLM

config.price is the public door for "the registry has no price, or not mine", and Model::Pricing.override rejects any key it does not list. The one category it cannot reach is the one where registry data is thinnest, so an app is left to prepend Models.load_models and rewrite pricing hashes, which is private API.

Lingua principale
Ruby
Stelle
4.5k
Fork
543
Merge medio
11h 38m
PR unite (30g)
410

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di crmne/ruby_llm

Tutte le issue di crmne/ruby_llm

Issue simili

Altre issue su Ruby

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.