From 622760822b67cef289882692aa9ac867d6deee46 Mon Sep 17 00:00:00 2001 From: "Keith R. Bennett" Date: Wed, 26 Mar 2025 00:35:20 +0800 Subject: [PATCH 01/14] Add model_list_as_markdown example script. --- examples/model_list_as_markdown | 112 ++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100755 examples/model_list_as_markdown diff --git a/examples/model_list_as_markdown b/examples/model_list_as_markdown new file mode 100755 index 000000000..32a1866a1 --- /dev/null +++ b/examples/model_list_as_markdown @@ -0,0 +1,112 @@ +#!/usr/bin/env ruby + +# model_list_as_markdown + +# This script generates a markdown table of all the models available in the RubyLLM library, +# with one table per model type. +# +# Its output can be seen in rendered markdown on the command line by using `glow` or `mdcat`: +# ./model_list_as_markdown | glow -w 150 - +# or +# ./model_list_as_markdown | mdcat - + +require 'awesome_print' +require 'ruby_llm' + +# Keys to extract from each model object for display +MODEL_KEYS_TO_DISPLAY = [ + :id, + :type, + :display_name, + :provider, + :context_window, + :max_tokens, + :family, + :input_price_per_million, + :output_price_per_million +] + +def to_display_hash(model) + model.to_h.slice(*MODEL_KEYS_TO_DISPLAY) +end + +# Converts model data into a markdown table with appropriate column alignments +def to_markdown_table(models) + model_hashes = Array(models).map { |model| to_display_hash(model) } + + # Shortened column headers for better table readability + headers = { + id: "ID", + type: "Type", + display_name: "Name", + provider: "Provider", + context_window: "Context", + max_tokens: "MaxTok", + family: "Family", + input_price_per_million: "In$/M", + output_price_per_million: "Out$/M" + } + + # Right-align numeric columns, left-align text + alignments = { + id: ":--", + type: ":--", + display_name: ":--", + provider: ":--", + context_window: "--:", + max_tokens: "--:", + family: ":--", + input_price_per_million: "--:", + output_price_per_million: "--:" + } + + # Build the table + lines = [] + + # Header rows + lines << "| #{MODEL_KEYS_TO_DISPLAY.map { |key| headers[key] }.join(' | ')} |" + lines << "| #{MODEL_KEYS_TO_DISPLAY.map { |key| alignments[key] }.join(' | ')} |" + + # Data rows + model_hashes.each do |model_hash| + values = MODEL_KEYS_TO_DISPLAY.map do |key| + if model_hash[key].is_a?(Float) + format('%.2f', model_hash[key]) + else + model_hash[key] + end + end + + lines << "| #{values.join(' | ')} |" + end + + lines.join("\n") +end + +# Generate markdown tables for each model type +puts <<~DOC + # Model List + + This is a list of all the models available in the RubyLLM library, by type: + + ### Chat Models + + #{to_markdown_table(RubyLLM.models.chat_models)} + + ### Image Models + + #{to_markdown_table(RubyLLM.models.image_models)} + + ### Audio Models + + #{to_markdown_table(RubyLLM.models.audio_models)} + + ### Embedding Models + + #{to_markdown_table(RubyLLM.models.embedding_models)} + + ### Moderation Models + + #{to_markdown_table(RubyLLM.models.select { |m| m.type == 'moderation'})} + DOC + \ No newline at end of file From d1fabcc9449a05866c69821c67ec264eb08cbc1e Mon Sep 17 00:00:00 2001 From: "Keith R. Bennett" Date: Wed, 26 Mar 2025 19:39:09 +0800 Subject: [PATCH 02/14] Add model_list_as_markdown script to /exe. --- {examples => exe}/model_list_as_markdown | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) rename {examples => exe}/model_list_as_markdown (93%) diff --git a/examples/model_list_as_markdown b/exe/model_list_as_markdown similarity index 93% rename from examples/model_list_as_markdown rename to exe/model_list_as_markdown index 32a1866a1..a6b3f8186 100755 --- a/examples/model_list_as_markdown +++ b/exe/model_list_as_markdown @@ -6,7 +6,7 @@ # with one table per model type. # # Its output can be seen in rendered markdown on the command line by using `glow` or `mdcat`: -# ./model_list_as_markdown | glow -w 150 - +# ./model_list_as_markdown | glow -w 160 - # or # ./model_list_as_markdown | mdcat - @@ -63,7 +63,7 @@ def to_markdown_table(models) # Build the table lines = [] - # Header rows + # Header rows=========------=++9 lines << "| #{MODEL_KEYS_TO_DISPLAY.map { |key| headers[key] }.join(' | ')} |" lines << "| #{MODEL_KEYS_TO_DISPLAY.map { |key| alignments[key] }.join(' | ')} |" @@ -109,4 +109,8 @@ puts <<~DOC #{to_markdown_table(RubyLLM.models.select { |m| m.type == 'moderation'})} DOC + +=begin +# TODO: Use JSON data from the model_info.json file to generate a table of model info +=end \ No newline at end of file From 708e6308a39207a86609d3a50112b5d530bdf842 Mon Sep 17 00:00:00 2001 From: "Keith R. Bennett" Date: Thu, 27 Mar 2025 23:13:34 +0800 Subject: [PATCH 03/14] Move exe/model_list_as_markdown to Rake task lib/tasks/models_docs.rake. Add "Models by Provider", before there was only "Models by Type". --- exe/model_list_as_markdown | 116 ------------------------------- lib/tasks/models_docs.rake | 138 +++++++++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+), 116 deletions(-) delete mode 100755 exe/model_list_as_markdown create mode 100644 lib/tasks/models_docs.rake diff --git a/exe/model_list_as_markdown b/exe/model_list_as_markdown deleted file mode 100755 index a6b3f8186..000000000 --- a/exe/model_list_as_markdown +++ /dev/null @@ -1,116 +0,0 @@ -#!/usr/bin/env ruby - -# model_list_as_markdown - -# This script generates a markdown table of all the models available in the RubyLLM library, -# with one table per model type. -# -# Its output can be seen in rendered markdown on the command line by using `glow` or `mdcat`: -# ./model_list_as_markdown | glow -w 160 - -# or -# ./model_list_as_markdown | mdcat - - -require 'awesome_print' -require 'ruby_llm' - -# Keys to extract from each model object for display -MODEL_KEYS_TO_DISPLAY = [ - :id, - :type, - :display_name, - :provider, - :context_window, - :max_tokens, - :family, - :input_price_per_million, - :output_price_per_million -] - -def to_display_hash(model) - model.to_h.slice(*MODEL_KEYS_TO_DISPLAY) -end - -# Converts model data into a markdown table with appropriate column alignments -def to_markdown_table(models) - model_hashes = Array(models).map { |model| to_display_hash(model) } - - # Shortened column headers for better table readability - headers = { - id: "ID", - type: "Type", - display_name: "Name", - provider: "Provider", - context_window: "Context", - max_tokens: "MaxTok", - family: "Family", - input_price_per_million: "In$/M", - output_price_per_million: "Out$/M" - } - - # Right-align numeric columns, left-align text - alignments = { - id: ":--", - type: ":--", - display_name: ":--", - provider: ":--", - context_window: "--:", - max_tokens: "--:", - family: ":--", - input_price_per_million: "--:", - output_price_per_million: "--:" - } - - # Build the table - lines = [] - - # Header rows=========------=++9 - lines << "| #{MODEL_KEYS_TO_DISPLAY.map { |key| headers[key] }.join(' | ')} |" - lines << "| #{MODEL_KEYS_TO_DISPLAY.map { |key| alignments[key] }.join(' | ')} |" - - # Data rows - model_hashes.each do |model_hash| - values = MODEL_KEYS_TO_DISPLAY.map do |key| - if model_hash[key].is_a?(Float) - format('%.2f', model_hash[key]) - else - model_hash[key] - end - end - - lines << "| #{values.join(' | ')} |" - end - - lines.join("\n") -end - -# Generate markdown tables for each model type -puts <<~DOC - # Model List - - This is a list of all the models available in the RubyLLM library, by type: - - ### Chat Models - - #{to_markdown_table(RubyLLM.models.chat_models)} - - ### Image Models - - #{to_markdown_table(RubyLLM.models.image_models)} - - ### Audio Models - - #{to_markdown_table(RubyLLM.models.audio_models)} - - ### Embedding Models - - #{to_markdown_table(RubyLLM.models.embedding_models)} - - ### Moderation Models - - #{to_markdown_table(RubyLLM.models.select { |m| m.type == 'moderation'})} - DOC - -=begin -# TODO: Use JSON data from the model_info.json file to generate a table of model info -=end - \ No newline at end of file diff --git a/lib/tasks/models_docs.rake b/lib/tasks/models_docs.rake new file mode 100644 index 000000000..9612f15c2 --- /dev/null +++ b/lib/tasks/models_docs.rake @@ -0,0 +1,138 @@ +# frozen_string_literal: true + +require 'ruby_llm' +require 'fileutils' + +namespace :models do + desc 'Generate available models documentation' + task :docs do + FileUtils.mkdir_p('docs/guides') # ensure output directory exists + + output = <<~MARKDOWN + --- + layout: default + title: Available Models + parent: Guides + nav_order: 10 + permalink: /guides/available-models + --- + + # Available Models + + This guide lists all models available in RubyLLM, automatically generated from the current model registry. + + _Last updated: #{Time.now.strftime('%Y-%m-%d')}_ + + ## Models by Type + + ### Chat Models + + #{to_markdown_table(RubyLLM.models.chat_models)} + + ### Image Models + + #{to_markdown_table(RubyLLM.models.image_models)} + + ### Audio Models + + #{to_markdown_table(RubyLLM.models.audio_models)} + + ### Embedding Models + + #{to_markdown_table(RubyLLM.models.embedding_models)} + + ### Moderation Models + + #{to_markdown_table(RubyLLM.models.select { |m| m.type == 'moderation'})} + + ## Models by Provider + + #{RubyLLM::Provider.providers.keys.map { |provider| + models = RubyLLM.models.by_provider(provider) + next if models.none? + + <<~PROVIDER + ### #{provider.to_s.capitalize} Models + + #{to_markdown_table(models)} + PROVIDER + }.compact.join("\n")} + MARKDOWN + + File.write('docs/guides/available-models.md', output) + puts "Generated docs/guides/available-models.md" + end + + private + + MODEL_KEYS_TO_DISPLAY = [ + :id, + :type, + :display_name, + :provider, + :context_window, + :max_tokens, + :family, + :input_price_per_million, + :output_price_per_million + ] + + def to_display_hash(model) + model.to_h.slice(*MODEL_KEYS_TO_DISPLAY) + end + + def to_markdown_table(models) + model_hashes = Array(models).map { |model| to_display_hash(model) } + + # Create abbreviated headers + headers = { + id: "ID", + type: "Type", + display_name: "Name", + provider: "Provider", + context_window: "Context", + max_tokens: "MaxTok", + family: "Family", + input_price_per_million: "In$/M", + output_price_per_million: "Out$/M" + } + + # Create header row with alignment markers + # Right-align numbers, left-align text + alignments = { + id: ":--", + type: ":--", + display_name: ":--", + provider: ":--", + context_window: "--:", + max_tokens: "--:", + family: ":--", + input_price_per_million: "--:", + output_price_per_million: "--:" + } + + # Build the table + lines = [] + + # Header row + lines << "| #{MODEL_KEYS_TO_DISPLAY.map { |key| headers[key] }.join(' | ')} |" + + # Alignment row + lines << "| #{MODEL_KEYS_TO_DISPLAY.map { |key| alignments[key] }.join(' | ')} |" + + # Data rows + model_hashes.each do |model_hash| + values = MODEL_KEYS_TO_DISPLAY.map do |key| + if model_hash[key].is_a?(Float) + format('%.2f', model_hash[key]) + else + model_hash[key] + end + end + + lines << "| #{values.join(' | ')} |" + end + + lines.join("\n") + end +end \ No newline at end of file From 3893f31d0c9653d4bf65ce272ce18f467384337b Mon Sep 17 00:00:00 2001 From: "Keith R. Bennett" Date: Thu, 27 Mar 2025 23:51:46 +0800 Subject: [PATCH 04/14] Add sections on Contributing and Model Capabilities. --- lib/tasks/models_docs.rake | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/lib/tasks/models_docs.rake b/lib/tasks/models_docs.rake index 9612f15c2..a8c067ce1 100644 --- a/lib/tasks/models_docs.rake +++ b/lib/tasks/models_docs.rake @@ -21,7 +21,17 @@ namespace :models do This guide lists all models available in RubyLLM, automatically generated from the current model registry. - _Last updated: #{Time.now.strftime('%Y-%m-%d')}_ + _Last updated: #{Time.now.utc.strftime('%Y-%m-%d %H:%M')} UTC_ + + ## Contributing + + The model list is automatically generated from the model registry. To add or update models: + + 1. Run `rake models:update` to refresh the model registry. + 2. Run `rake models:update_capabilities` to refresh the model capabilities. + 3. Submit a pull request with the updated `models.json` + + See [Contributing Guide](/CONTRIBUTING.md) for more details. ## Models by Type @@ -54,9 +64,22 @@ namespace :models do <<~PROVIDER ### #{provider.to_s.capitalize} Models - #{to_markdown_table(models)} + #{to_markdown_table(models)} PROVIDER }.compact.join("\n")} + + ## Model Capabilities + + Each model in the registry includes information about its capabilities: + + - **Context Window**: Maximum number of tokens the model can process in a single request + - **Max Tokens**: Maximum number of tokens the model can generate in a single response + - **Vision Support**: Whether the model can process images + - **Function Calling**: Whether the model supports function calling + - **JSON Mode**: Whether the model can be constrained to output valid JSON + - **Pricing**: Cost per million tokens for input and output + + For more information about working with models, see the [Working with Models](/guides/models) guide. MARKDOWN File.write('docs/guides/available-models.md', output) From 77d32d5bdde6296d9282eb8ee58bdbfd6a31732e Mon Sep 17 00:00:00 2001 From: "Keith R. Bennett" Date: Fri, 28 Mar 2025 01:48:33 +0800 Subject: [PATCH 05/14] Improve Contributing and Available Models sections. --- docs/guides/available-models.md | 317 ++++++++++++++++++++++++++++++++ lib/tasks/models_docs.rake | 9 +- 2 files changed, 322 insertions(+), 4 deletions(-) create mode 100644 docs/guides/available-models.md diff --git a/docs/guides/available-models.md b/docs/guides/available-models.md new file mode 100644 index 000000000..ceb999b26 --- /dev/null +++ b/docs/guides/available-models.md @@ -0,0 +1,317 @@ +--- +layout: default +title: Available Models +parent: Guides +nav_order: 10 +permalink: /guides/available-models +--- + +# Available Models + +This guide lists all models available in RubyLLM, automatically generated from the current model registry. + +This file was generated at 2025-03-27 17:45 UTC, +but the lib/ruby_llm/models.json file from which it was generated may or may not be up to date. + +## Contributing + +The model list is automatically generated from the model registry. To add or update models: + +1. Run `rake models:update` to refresh lib/ruby_llm/models.json. +2. Run `rake models:update_capabilities` to refresh lib/ruby_llm/providers/**/capabilities.rb. +3. Submit a pull request with the updated files. + +See [Contributing Guide](/CONTRIBUTING.md) for more details. + +## Models by Type + +### Chat Models + +| ID | Type | Name | Provider | Context | MaxTok | Family | In$/M | Out$/M | +| :-- | :-- | :-- | :-- | --: | --: | :-- | --: | --: | +| aqa | chat | Model that performs Attributed Question Answering. | gemini | 7168 | 1024 | aqa | 0.00 | 0.00 | +| babbage-002 | chat | Babbage 002 | openai | 16385 | 16384 | babbage | 0.50 | 1.50 | +| chat-bison-001 | chat | PaLM 2 Chat (Legacy) | gemini | 4096 | 1024 | other | 0.08 | 0.30 | +| chatgpt-4o-latest | chat | ChatGPT-4o Latest | openai | 128000 | 16384 | gpt4o | 0.50 | 1.50 | +| claude-2.0 | chat | Claude 2.0 | anthropic | 200000 | 4096 | claude2 | 3.00 | 15.00 | +| claude-2.1 | chat | Claude 2.1 | anthropic | 200000 | 4096 | claude2 | 3.00 | 15.00 | +| claude-3-5-haiku-20241022 | chat | Claude 3.5 Haiku | anthropic | 200000 | 8192 | claude35_haiku | 0.80 | 4.00 | +| claude-3-5-sonnet-20240620 | chat | Claude 3.5 Sonnet (Old) | anthropic | 200000 | 8192 | claude35_sonnet | 3.00 | 15.00 | +| claude-3-5-sonnet-20241022 | chat | Claude 3.5 Sonnet (New) | anthropic | 200000 | 8192 | claude35_sonnet | 3.00 | 15.00 | +| claude-3-7-sonnet-20250219 | chat | Claude 3.7 Sonnet | anthropic | 200000 | 8192 | claude37_sonnet | 3.00 | 15.00 | +| claude-3-haiku-20240307 | chat | Claude 3 Haiku | anthropic | 200000 | 4096 | claude3_haiku | 0.25 | 1.25 | +| claude-3-opus-20240229 | chat | Claude 3 Opus | anthropic | 200000 | 4096 | claude3_opus | 15.00 | 75.00 | +| claude-3-sonnet-20240229 | chat | Claude 3 Sonnet | anthropic | 200000 | 4096 | claude3_sonnet | 3.00 | 15.00 | +| davinci-002 | chat | Davinci 002 | openai | 16385 | 16384 | davinci | 0.50 | 1.50 | +| deepseek-chat | chat | DeepSeek V3 | deepseek | 64000 | 8192 | chat | 0.27 | 1.10 | +| deepseek-reasoner | chat | DeepSeek R1 | deepseek | 64000 | 8192 | reasoner | 0.55 | 2.19 | +| gemini-1.0-pro-vision-latest | chat | Gemini 1.0 Pro Vision | gemini | 12288 | 4096 | gemini10_pro | 0.50 | 1.50 | +| gemini-1.5-flash | chat | Gemini 1.5 Flash | gemini | 1000000 | 8192 | gemini15_flash | 0.15 | 0.60 | +| gemini-1.5-flash-001 | chat | Gemini 1.5 Flash 001 | gemini | 1000000 | 8192 | gemini15_flash | 0.15 | 0.60 | +| gemini-1.5-flash-001-tuning | chat | Gemini 1.5 Flash 001 Tuning | gemini | 16384 | 8192 | gemini15_flash | 0.15 | 0.60 | +| gemini-1.5-flash-002 | chat | Gemini 1.5 Flash 002 | gemini | 1000000 | 8192 | gemini15_flash | 0.15 | 0.60 | +| gemini-1.5-flash-8b | chat | Gemini 1.5 Flash-8B | gemini | 1000000 | 8192 | gemini15_flash_8b | 0.08 | 0.30 | +| gemini-1.5-flash-8b-001 | chat | Gemini 1.5 Flash-8B 001 | gemini | 1000000 | 8192 | gemini15_flash_8b | 0.08 | 0.30 | +| gemini-1.5-flash-8b-exp-0827 | chat | Gemini 1.5 Flash 8B Experimental 0827 | gemini | 1000000 | 8192 | gemini15_flash_8b | 0.08 | 0.30 | +| gemini-1.5-flash-8b-exp-0924 | chat | Gemini 1.5 Flash 8B Experimental 0924 | gemini | 1000000 | 8192 | gemini15_flash_8b | 0.08 | 0.30 | +| gemini-1.5-flash-8b-latest | chat | Gemini 1.5 Flash-8B Latest | gemini | 1000000 | 8192 | gemini15_flash_8b | 0.08 | 0.30 | +| gemini-1.5-flash-latest | chat | Gemini 1.5 Flash Latest | gemini | 1000000 | 8192 | gemini15_flash | 0.15 | 0.60 | +| gemini-1.5-pro | chat | Gemini 1.5 Pro | gemini | 2000000 | 8192 | gemini15_pro | 2.50 | 10.00 | +| gemini-1.5-pro-001 | chat | Gemini 1.5 Pro 001 | gemini | 2000000 | 8192 | gemini15_pro | 2.50 | 10.00 | +| gemini-1.5-pro-002 | chat | Gemini 1.5 Pro 002 | gemini | 2000000 | 8192 | gemini15_pro | 2.50 | 10.00 | +| gemini-1.5-pro-latest | chat | Gemini 1.5 Pro Latest | gemini | 2000000 | 8192 | gemini15_pro | 2.50 | 10.00 | +| gemini-2.0-flash | chat | Gemini 2.0 Flash | gemini | 1048576 | 8192 | gemini20_flash | 0.10 | 0.40 | +| gemini-2.0-flash-001 | chat | Gemini 2.0 Flash 001 | gemini | 1048576 | 8192 | gemini20_flash | 0.10 | 0.40 | +| gemini-2.0-flash-exp | chat | Gemini 2.0 Flash Experimental | gemini | 1048576 | 8192 | gemini20_flash | 0.10 | 0.40 | +| gemini-2.0-flash-exp-image-generation | chat | Gemini 2.0 Flash (Image Generation) Experimental | gemini | 1048576 | 8192 | gemini20_flash | 0.10 | 0.40 | +| gemini-2.0-flash-lite | chat | Gemini 2.0 Flash-Lite | gemini | 1048576 | 8192 | gemini20_flash_lite | 0.08 | 0.30 | +| gemini-2.0-flash-lite-001 | chat | Gemini 2.0 Flash-Lite 001 | gemini | 1048576 | 8192 | gemini20_flash_lite | 0.08 | 0.30 | +| gemini-2.0-flash-lite-preview | chat | Gemini 2.0 Flash-Lite Preview | gemini | 1048576 | 8192 | gemini20_flash_lite | 0.08 | 0.30 | +| gemini-2.0-flash-lite-preview-02-05 | chat | Gemini 2.0 Flash-Lite Preview 02-05 | gemini | 1048576 | 8192 | gemini20_flash_lite | 0.08 | 0.30 | +| gemini-2.0-flash-thinking-exp | chat | Gemini 2.0 Flash Thinking Experimental 01-21 | gemini | 1048576 | 65536 | gemini20_flash | 0.10 | 0.40 | +| gemini-2.0-flash-thinking-exp-01-21 | chat | Gemini 2.0 Flash Thinking Experimental 01-21 | gemini | 1048576 | 65536 | gemini20_flash | 0.10 | 0.40 | +| gemini-2.0-flash-thinking-exp-1219 | chat | Gemini 2.0 Flash Thinking Experimental | gemini | 1048576 | 65536 | gemini20_flash | 0.10 | 0.40 | +| gemini-2.0-pro-exp | chat | Gemini 2.0 Pro Experimental | gemini | 2097152 | 8192 | other | 0.08 | 0.30 | +| gemini-2.0-pro-exp-02-05 | chat | Gemini 2.0 Pro Experimental 02-05 | gemini | 2097152 | 8192 | other | 0.08 | 0.30 | +| gemini-exp-1206 | chat | Gemini Experimental 1206 | gemini | 2097152 | 8192 | other | 0.08 | 0.30 | +| gemini-pro-vision | chat | Gemini 1.0 Pro Vision | gemini | 12288 | 4096 | other | 0.08 | 0.30 | +| gemma-3-27b-it | chat | Gemma 3 27B | gemini | 131072 | 8192 | other | 0.08 | 0.30 | +| gpt-3.5-turbo | chat | GPT-3.5-Turbo | openai | 16385 | 4096 | gpt35 | 0.50 | 1.50 | +| gpt-3.5-turbo-0125 | chat | GPT-3.5-Turbo 0125 | openai | 4096 | 4096 | gpt35 | 0.50 | 1.50 | +| gpt-3.5-turbo-1106 | chat | GPT-3.5-Turbo 1106 | openai | 4096 | 4096 | gpt35 | 0.50 | 1.50 | +| gpt-3.5-turbo-16k | chat | GPT-3.5-Turbo 16k | openai | 16385 | 4096 | gpt35 | 0.50 | 1.50 | +| gpt-3.5-turbo-instruct | chat | GPT-3.5-Turbo Instruct | openai | 4096 | 4096 | gpt35_instruct | 0.50 | 1.50 | +| gpt-3.5-turbo-instruct-0914 | chat | GPT-3.5-Turbo Instruct 0914 | openai | 4096 | 4096 | gpt35_instruct | 0.50 | 1.50 | +| gpt-4 | chat | GPT-4 | openai | 4096 | 4096 | gpt4 | 0.50 | 1.50 | +| gpt-4-0125-preview | chat | GPT-4-0125 Preview | openai | 8192 | 8192 | gpt4 | 0.50 | 1.50 | +| gpt-4-0613 | chat | GPT-4-0613 | openai | 8192 | 8192 | gpt4 | 0.50 | 1.50 | +| gpt-4-1106-preview | chat | GPT-4-1106 Preview | openai | 4096 | 4096 | gpt4 | 0.50 | 1.50 | +| gpt-4-turbo | chat | GPT-4-Turbo | openai | 128000 | 4096 | gpt4_turbo | 0.50 | 1.50 | +| gpt-4-turbo-2024-04-09 | chat | GPT-4-Turbo 20240409 | openai | 128000 | 4096 | gpt4_turbo | 0.50 | 1.50 | +| gpt-4-turbo-preview | chat | GPT-4-Turbo Preview | openai | 128000 | 4096 | gpt4_turbo | 0.50 | 1.50 | +| gpt-4.5-preview | chat | GPT-4.5 Preview | openai | 4096 | 4096 | gpt4 | 0.50 | 1.50 | +| gpt-4.5-preview-2025-02-27 | chat | GPT-4.5 Preview 20250227 | openai | 4096 | 4096 | gpt4 | 0.50 | 1.50 | +| gpt-4o | chat | GPT-4o | openai | 128000 | 16384 | gpt4o | 0.50 | 1.50 | +| gpt-4o-2024-05-13 | chat | GPT-4o 20240513 | openai | 128000 | 16384 | gpt4o | 0.50 | 1.50 | +| gpt-4o-2024-08-06 | chat | GPT-4o 20240806 | openai | 128000 | 16384 | gpt4o | 0.50 | 1.50 | +| gpt-4o-2024-11-20 | chat | GPT-4o 20241120 | openai | 128000 | 16384 | gpt4o | 0.50 | 1.50 | +| gpt-4o-audio-preview | chat | GPT-4o-Audio Preview | openai | 128000 | 16384 | gpt4o_audio | 0.50 | 1.50 | +| gpt-4o-audio-preview-2024-10-01 | chat | GPT-4o-Audio Preview 20241001 | openai | 128000 | 16384 | gpt4o_audio | 0.50 | 1.50 | +| gpt-4o-audio-preview-2024-12-17 | chat | GPT-4o-Audio Preview 20241217 | openai | 128000 | 16384 | gpt4o_audio | 0.50 | 1.50 | +| gpt-4o-mini | chat | GPT-4o-Mini | openai | 128000 | 16384 | gpt4o_mini | 0.50 | 1.50 | +| gpt-4o-mini-2024-07-18 | chat | GPT-4o-Mini 20240718 | openai | 128000 | 16384 | gpt4o_mini | 0.50 | 1.50 | +| gpt-4o-mini-audio-preview | chat | GPT-4o-Mini Audio Preview | openai | 128000 | 16384 | gpt4o_mini_audio | 0.50 | 1.50 | +| gpt-4o-mini-audio-preview-2024-12-17 | chat | GPT-4o-Mini Audio Preview 20241217 | openai | 128000 | 16384 | gpt4o_mini_audio | 0.50 | 1.50 | +| gpt-4o-mini-realtime-preview | chat | GPT-4o-Mini Realtime Preview | openai | 128000 | 16384 | gpt4o_mini_realtime | 0.50 | 1.50 | +| gpt-4o-mini-realtime-preview-2024-12-17 | chat | GPT-4o-Mini Realtime Preview 20241217 | openai | 128000 | 16384 | gpt4o_mini_realtime | 0.50 | 1.50 | +| gpt-4o-mini-search-preview | chat | GPT-4o-Mini Search Preview | openai | 128000 | 16384 | gpt4o_mini | 0.50 | 1.50 | +| gpt-4o-mini-search-preview-2025-03-11 | chat | GPT-4o-Mini Search Preview 20250311 | openai | 128000 | 16384 | gpt4o_mini | 0.50 | 1.50 | +| gpt-4o-mini-transcribe | chat | GPT-4o-Mini Transcribe | openai | 128000 | 16384 | gpt4o_mini | 0.50 | 1.50 | +| gpt-4o-realtime-preview | chat | GPT-4o-Realtime Preview | openai | 128000 | 16384 | gpt4o_realtime | 0.50 | 1.50 | +| gpt-4o-realtime-preview-2024-10-01 | chat | GPT-4o-Realtime Preview 20241001 | openai | 128000 | 16384 | gpt4o_realtime | 0.50 | 1.50 | +| gpt-4o-realtime-preview-2024-12-17 | chat | GPT-4o-Realtime Preview 20241217 | openai | 128000 | 16384 | gpt4o_realtime | 0.50 | 1.50 | +| gpt-4o-search-preview | chat | GPT-4o Search Preview | openai | 128000 | 16384 | gpt4o | 0.50 | 1.50 | +| gpt-4o-search-preview-2025-03-11 | chat | GPT-4o Search Preview 20250311 | openai | 128000 | 16384 | gpt4o | 0.50 | 1.50 | +| gpt-4o-transcribe | chat | GPT-4o Transcribe | openai | 128000 | 16384 | gpt4o | 0.50 | 1.50 | +| learnlm-1.5-pro-experimental | chat | LearnLM 1.5 Pro Experimental | gemini | 32767 | 8192 | other | 0.08 | 0.30 | +| o1 | chat | O1 | openai | 4096 | 4096 | o1 | 0.50 | 1.50 | +| o1-2024-12-17 | chat | O1-20241217 | openai | 200000 | 100000 | o1 | 0.50 | 1.50 | +| o1-mini | chat | O1-Mini | openai | 128000 | 4096 | o1_mini | 0.50 | 1.50 | +| o1-mini-2024-09-12 | chat | O1-Mini 20240912 | openai | 128000 | 65536 | o1_mini | 0.50 | 1.50 | +| o1-preview | chat | O1-Preview | openai | 4096 | 4096 | o1 | 0.50 | 1.50 | +| o1-preview-2024-09-12 | chat | O1-Preview 20240912 | openai | 4096 | 4096 | o1 | 0.50 | 1.50 | +| o1-pro | chat | O1-Pro | openai | 4096 | 4096 | o1 | 0.50 | 1.50 | +| o1-pro-2025-03-19 | chat | O1-Pro 20250319 | openai | 4096 | 4096 | o1 | 0.50 | 1.50 | +| o3-mini | chat | O3-Mini | openai | 200000 | 100000 | o3_mini | 0.50 | 1.50 | +| o3-mini-2025-01-31 | chat | O3-Mini 20250131 | openai | 200000 | 100000 | o3_mini | 0.50 | 1.50 | +| text-bison-001 | chat | PaLM 2 (Legacy) | gemini | 8196 | 1024 | other | 0.08 | 0.30 | + +### Image Models + +| ID | Type | Name | Provider | Context | MaxTok | Family | In$/M | Out$/M | +| :-- | :-- | :-- | :-- | --: | --: | :-- | --: | --: | +| dall-e-2 | image | DALL-E-2 | openai | 4096 | 4096 | dalle2 | 0.50 | 1.50 | +| dall-e-3 | image | DALL-E-3 | openai | 4096 | 4096 | dalle3 | 0.50 | 1.50 | +| imagen-3.0-generate-002 | image | Imagen 3.0 002 model | gemini | 480 | 8192 | other | 0.08 | 0.30 | + +### Audio Models + +| ID | Type | Name | Provider | Context | MaxTok | Family | In$/M | Out$/M | +| :-- | :-- | :-- | :-- | --: | --: | :-- | --: | --: | +| gpt-4o-mini-tts | audio | GPT-4o-Mini Tts | openai | 128000 | 16384 | gpt4o_mini | 0.50 | 1.50 | +| tts-1 | audio | TTS-1 | openai | 4096 | 4096 | tts1 | 0.50 | 1.50 | +| tts-1-1106 | audio | TTS-1 1106 | openai | 4096 | 4096 | tts1 | 0.50 | 1.50 | +| tts-1-hd | audio | TTS-1 HD | openai | 4096 | 4096 | tts1_hd | 0.50 | 1.50 | +| tts-1-hd-1106 | audio | TTS-1 HD 1106 | openai | 4096 | 4096 | tts1_hd | 0.50 | 1.50 | +| whisper-1 | audio | Whisper 1 | openai | 4096 | 4096 | whisper1 | 0.50 | 1.50 | + +### Embedding Models + +| ID | Type | Name | Provider | Context | MaxTok | Family | In$/M | Out$/M | +| :-- | :-- | :-- | :-- | --: | --: | :-- | --: | --: | +| embedding-001 | embedding | Embedding 001 | gemini | 2048 | 1 | embedding1 | 0.00 | 0.00 | +| embedding-gecko-001 | embedding | Embedding Gecko | gemini | 1024 | 1 | other | 0.00 | 0.00 | +| gemini-embedding-exp | embedding | Gemini Embedding Experimental | gemini | 8192 | 1 | other | 0.00 | 0.00 | +| gemini-embedding-exp-03-07 | embedding | Gemini Embedding Experimental 03-07 | gemini | 8192 | 1 | other | 0.00 | 0.00 | +| text-embedding-004 | embedding | Text Embedding 004 | gemini | 2048 | 1 | embedding4 | 0.00 | 0.00 | +| text-embedding-3-large | embedding | Text Embedding 3 Large | openai | 4096 | 4096 | embedding3_large | 0.50 | 1.50 | +| text-embedding-3-small | embedding | Text Embedding 3 Small | openai | 4096 | 4096 | embedding3_small | 0.50 | 1.50 | +| text-embedding-ada-002 | embedding | Text Embedding Ada 002 | openai | 4096 | 4096 | embedding2 | 0.50 | 1.50 | + +### Moderation Models + +| ID | Type | Name | Provider | Context | MaxTok | Family | In$/M | Out$/M | +| :-- | :-- | :-- | :-- | --: | --: | :-- | --: | --: | +| omni-moderation-2024-09-26 | moderation | Omni-Moderation 20240926 | openai | 4096 | 4096 | moderation | 0.50 | 1.50 | +| omni-moderation-latest | moderation | Omni-Moderation Latest | openai | 4096 | 4096 | moderation | 0.50 | 1.50 | + +## Models by Provider + +### Openai Models + + | ID | Type | Name | Provider | Context | MaxTok | Family | In$/M | Out$/M | +| :-- | :-- | :-- | :-- | --: | --: | :-- | --: | --: | +| babbage-002 | chat | Babbage 002 | openai | 16385 | 16384 | babbage | 0.50 | 1.50 | +| chatgpt-4o-latest | chat | ChatGPT-4o Latest | openai | 128000 | 16384 | gpt4o | 0.50 | 1.50 | +| dall-e-2 | image | DALL-E-2 | openai | 4096 | 4096 | dalle2 | 0.50 | 1.50 | +| dall-e-3 | image | DALL-E-3 | openai | 4096 | 4096 | dalle3 | 0.50 | 1.50 | +| davinci-002 | chat | Davinci 002 | openai | 16385 | 16384 | davinci | 0.50 | 1.50 | +| gpt-3.5-turbo | chat | GPT-3.5-Turbo | openai | 16385 | 4096 | gpt35 | 0.50 | 1.50 | +| gpt-3.5-turbo-0125 | chat | GPT-3.5-Turbo 0125 | openai | 4096 | 4096 | gpt35 | 0.50 | 1.50 | +| gpt-3.5-turbo-1106 | chat | GPT-3.5-Turbo 1106 | openai | 4096 | 4096 | gpt35 | 0.50 | 1.50 | +| gpt-3.5-turbo-16k | chat | GPT-3.5-Turbo 16k | openai | 16385 | 4096 | gpt35 | 0.50 | 1.50 | +| gpt-3.5-turbo-instruct | chat | GPT-3.5-Turbo Instruct | openai | 4096 | 4096 | gpt35_instruct | 0.50 | 1.50 | +| gpt-3.5-turbo-instruct-0914 | chat | GPT-3.5-Turbo Instruct 0914 | openai | 4096 | 4096 | gpt35_instruct | 0.50 | 1.50 | +| gpt-4 | chat | GPT-4 | openai | 4096 | 4096 | gpt4 | 0.50 | 1.50 | +| gpt-4-0125-preview | chat | GPT-4-0125 Preview | openai | 8192 | 8192 | gpt4 | 0.50 | 1.50 | +| gpt-4-0613 | chat | GPT-4-0613 | openai | 8192 | 8192 | gpt4 | 0.50 | 1.50 | +| gpt-4-1106-preview | chat | GPT-4-1106 Preview | openai | 4096 | 4096 | gpt4 | 0.50 | 1.50 | +| gpt-4-turbo | chat | GPT-4-Turbo | openai | 128000 | 4096 | gpt4_turbo | 0.50 | 1.50 | +| gpt-4-turbo-2024-04-09 | chat | GPT-4-Turbo 20240409 | openai | 128000 | 4096 | gpt4_turbo | 0.50 | 1.50 | +| gpt-4-turbo-preview | chat | GPT-4-Turbo Preview | openai | 128000 | 4096 | gpt4_turbo | 0.50 | 1.50 | +| gpt-4.5-preview | chat | GPT-4.5 Preview | openai | 4096 | 4096 | gpt4 | 0.50 | 1.50 | +| gpt-4.5-preview-2025-02-27 | chat | GPT-4.5 Preview 20250227 | openai | 4096 | 4096 | gpt4 | 0.50 | 1.50 | +| gpt-4o | chat | GPT-4o | openai | 128000 | 16384 | gpt4o | 0.50 | 1.50 | +| gpt-4o-2024-05-13 | chat | GPT-4o 20240513 | openai | 128000 | 16384 | gpt4o | 0.50 | 1.50 | +| gpt-4o-2024-08-06 | chat | GPT-4o 20240806 | openai | 128000 | 16384 | gpt4o | 0.50 | 1.50 | +| gpt-4o-2024-11-20 | chat | GPT-4o 20241120 | openai | 128000 | 16384 | gpt4o | 0.50 | 1.50 | +| gpt-4o-audio-preview | chat | GPT-4o-Audio Preview | openai | 128000 | 16384 | gpt4o_audio | 0.50 | 1.50 | +| gpt-4o-audio-preview-2024-10-01 | chat | GPT-4o-Audio Preview 20241001 | openai | 128000 | 16384 | gpt4o_audio | 0.50 | 1.50 | +| gpt-4o-audio-preview-2024-12-17 | chat | GPT-4o-Audio Preview 20241217 | openai | 128000 | 16384 | gpt4o_audio | 0.50 | 1.50 | +| gpt-4o-mini | chat | GPT-4o-Mini | openai | 128000 | 16384 | gpt4o_mini | 0.50 | 1.50 | +| gpt-4o-mini-2024-07-18 | chat | GPT-4o-Mini 20240718 | openai | 128000 | 16384 | gpt4o_mini | 0.50 | 1.50 | +| gpt-4o-mini-audio-preview | chat | GPT-4o-Mini Audio Preview | openai | 128000 | 16384 | gpt4o_mini_audio | 0.50 | 1.50 | +| gpt-4o-mini-audio-preview-2024-12-17 | chat | GPT-4o-Mini Audio Preview 20241217 | openai | 128000 | 16384 | gpt4o_mini_audio | 0.50 | 1.50 | +| gpt-4o-mini-realtime-preview | chat | GPT-4o-Mini Realtime Preview | openai | 128000 | 16384 | gpt4o_mini_realtime | 0.50 | 1.50 | +| gpt-4o-mini-realtime-preview-2024-12-17 | chat | GPT-4o-Mini Realtime Preview 20241217 | openai | 128000 | 16384 | gpt4o_mini_realtime | 0.50 | 1.50 | +| gpt-4o-mini-search-preview | chat | GPT-4o-Mini Search Preview | openai | 128000 | 16384 | gpt4o_mini | 0.50 | 1.50 | +| gpt-4o-mini-search-preview-2025-03-11 | chat | GPT-4o-Mini Search Preview 20250311 | openai | 128000 | 16384 | gpt4o_mini | 0.50 | 1.50 | +| gpt-4o-mini-transcribe | chat | GPT-4o-Mini Transcribe | openai | 128000 | 16384 | gpt4o_mini | 0.50 | 1.50 | +| gpt-4o-mini-tts | audio | GPT-4o-Mini Tts | openai | 128000 | 16384 | gpt4o_mini | 0.50 | 1.50 | +| gpt-4o-realtime-preview | chat | GPT-4o-Realtime Preview | openai | 128000 | 16384 | gpt4o_realtime | 0.50 | 1.50 | +| gpt-4o-realtime-preview-2024-10-01 | chat | GPT-4o-Realtime Preview 20241001 | openai | 128000 | 16384 | gpt4o_realtime | 0.50 | 1.50 | +| gpt-4o-realtime-preview-2024-12-17 | chat | GPT-4o-Realtime Preview 20241217 | openai | 128000 | 16384 | gpt4o_realtime | 0.50 | 1.50 | +| gpt-4o-search-preview | chat | GPT-4o Search Preview | openai | 128000 | 16384 | gpt4o | 0.50 | 1.50 | +| gpt-4o-search-preview-2025-03-11 | chat | GPT-4o Search Preview 20250311 | openai | 128000 | 16384 | gpt4o | 0.50 | 1.50 | +| gpt-4o-transcribe | chat | GPT-4o Transcribe | openai | 128000 | 16384 | gpt4o | 0.50 | 1.50 | +| o1 | chat | O1 | openai | 4096 | 4096 | o1 | 0.50 | 1.50 | +| o1-2024-12-17 | chat | O1-20241217 | openai | 200000 | 100000 | o1 | 0.50 | 1.50 | +| o1-mini | chat | O1-Mini | openai | 128000 | 4096 | o1_mini | 0.50 | 1.50 | +| o1-mini-2024-09-12 | chat | O1-Mini 20240912 | openai | 128000 | 65536 | o1_mini | 0.50 | 1.50 | +| o1-preview | chat | O1-Preview | openai | 4096 | 4096 | o1 | 0.50 | 1.50 | +| o1-preview-2024-09-12 | chat | O1-Preview 20240912 | openai | 4096 | 4096 | o1 | 0.50 | 1.50 | +| o1-pro | chat | O1-Pro | openai | 4096 | 4096 | o1 | 0.50 | 1.50 | +| o1-pro-2025-03-19 | chat | O1-Pro 20250319 | openai | 4096 | 4096 | o1 | 0.50 | 1.50 | +| o3-mini | chat | O3-Mini | openai | 200000 | 100000 | o3_mini | 0.50 | 1.50 | +| o3-mini-2025-01-31 | chat | O3-Mini 20250131 | openai | 200000 | 100000 | o3_mini | 0.50 | 1.50 | +| omni-moderation-2024-09-26 | moderation | Omni-Moderation 20240926 | openai | 4096 | 4096 | moderation | 0.50 | 1.50 | +| omni-moderation-latest | moderation | Omni-Moderation Latest | openai | 4096 | 4096 | moderation | 0.50 | 1.50 | +| text-embedding-3-large | embedding | Text Embedding 3 Large | openai | 4096 | 4096 | embedding3_large | 0.50 | 1.50 | +| text-embedding-3-small | embedding | Text Embedding 3 Small | openai | 4096 | 4096 | embedding3_small | 0.50 | 1.50 | +| text-embedding-ada-002 | embedding | Text Embedding Ada 002 | openai | 4096 | 4096 | embedding2 | 0.50 | 1.50 | +| tts-1 | audio | TTS-1 | openai | 4096 | 4096 | tts1 | 0.50 | 1.50 | +| tts-1-1106 | audio | TTS-1 1106 | openai | 4096 | 4096 | tts1 | 0.50 | 1.50 | +| tts-1-hd | audio | TTS-1 HD | openai | 4096 | 4096 | tts1_hd | 0.50 | 1.50 | +| tts-1-hd-1106 | audio | TTS-1 HD 1106 | openai | 4096 | 4096 | tts1_hd | 0.50 | 1.50 | +| whisper-1 | audio | Whisper 1 | openai | 4096 | 4096 | whisper1 | 0.50 | 1.50 | + +### Anthropic Models + + | ID | Type | Name | Provider | Context | MaxTok | Family | In$/M | Out$/M | +| :-- | :-- | :-- | :-- | --: | --: | :-- | --: | --: | +| claude-2.0 | chat | Claude 2.0 | anthropic | 200000 | 4096 | claude2 | 3.00 | 15.00 | +| claude-2.1 | chat | Claude 2.1 | anthropic | 200000 | 4096 | claude2 | 3.00 | 15.00 | +| claude-3-5-haiku-20241022 | chat | Claude 3.5 Haiku | anthropic | 200000 | 8192 | claude35_haiku | 0.80 | 4.00 | +| claude-3-5-sonnet-20240620 | chat | Claude 3.5 Sonnet (Old) | anthropic | 200000 | 8192 | claude35_sonnet | 3.00 | 15.00 | +| claude-3-5-sonnet-20241022 | chat | Claude 3.5 Sonnet (New) | anthropic | 200000 | 8192 | claude35_sonnet | 3.00 | 15.00 | +| claude-3-7-sonnet-20250219 | chat | Claude 3.7 Sonnet | anthropic | 200000 | 8192 | claude37_sonnet | 3.00 | 15.00 | +| claude-3-haiku-20240307 | chat | Claude 3 Haiku | anthropic | 200000 | 4096 | claude3_haiku | 0.25 | 1.25 | +| claude-3-opus-20240229 | chat | Claude 3 Opus | anthropic | 200000 | 4096 | claude3_opus | 15.00 | 75.00 | +| claude-3-sonnet-20240229 | chat | Claude 3 Sonnet | anthropic | 200000 | 4096 | claude3_sonnet | 3.00 | 15.00 | + +### Gemini Models + + | ID | Type | Name | Provider | Context | MaxTok | Family | In$/M | Out$/M | +| :-- | :-- | :-- | :-- | --: | --: | :-- | --: | --: | +| aqa | chat | Model that performs Attributed Question Answering. | gemini | 7168 | 1024 | aqa | 0.00 | 0.00 | +| chat-bison-001 | chat | PaLM 2 Chat (Legacy) | gemini | 4096 | 1024 | other | 0.08 | 0.30 | +| embedding-001 | embedding | Embedding 001 | gemini | 2048 | 1 | embedding1 | 0.00 | 0.00 | +| embedding-gecko-001 | embedding | Embedding Gecko | gemini | 1024 | 1 | other | 0.00 | 0.00 | +| gemini-1.0-pro-vision-latest | chat | Gemini 1.0 Pro Vision | gemini | 12288 | 4096 | gemini10_pro | 0.50 | 1.50 | +| gemini-1.5-flash | chat | Gemini 1.5 Flash | gemini | 1000000 | 8192 | gemini15_flash | 0.15 | 0.60 | +| gemini-1.5-flash-001 | chat | Gemini 1.5 Flash 001 | gemini | 1000000 | 8192 | gemini15_flash | 0.15 | 0.60 | +| gemini-1.5-flash-001-tuning | chat | Gemini 1.5 Flash 001 Tuning | gemini | 16384 | 8192 | gemini15_flash | 0.15 | 0.60 | +| gemini-1.5-flash-002 | chat | Gemini 1.5 Flash 002 | gemini | 1000000 | 8192 | gemini15_flash | 0.15 | 0.60 | +| gemini-1.5-flash-8b | chat | Gemini 1.5 Flash-8B | gemini | 1000000 | 8192 | gemini15_flash_8b | 0.08 | 0.30 | +| gemini-1.5-flash-8b-001 | chat | Gemini 1.5 Flash-8B 001 | gemini | 1000000 | 8192 | gemini15_flash_8b | 0.08 | 0.30 | +| gemini-1.5-flash-8b-exp-0827 | chat | Gemini 1.5 Flash 8B Experimental 0827 | gemini | 1000000 | 8192 | gemini15_flash_8b | 0.08 | 0.30 | +| gemini-1.5-flash-8b-exp-0924 | chat | Gemini 1.5 Flash 8B Experimental 0924 | gemini | 1000000 | 8192 | gemini15_flash_8b | 0.08 | 0.30 | +| gemini-1.5-flash-8b-latest | chat | Gemini 1.5 Flash-8B Latest | gemini | 1000000 | 8192 | gemini15_flash_8b | 0.08 | 0.30 | +| gemini-1.5-flash-latest | chat | Gemini 1.5 Flash Latest | gemini | 1000000 | 8192 | gemini15_flash | 0.15 | 0.60 | +| gemini-1.5-pro | chat | Gemini 1.5 Pro | gemini | 2000000 | 8192 | gemini15_pro | 2.50 | 10.00 | +| gemini-1.5-pro-001 | chat | Gemini 1.5 Pro 001 | gemini | 2000000 | 8192 | gemini15_pro | 2.50 | 10.00 | +| gemini-1.5-pro-002 | chat | Gemini 1.5 Pro 002 | gemini | 2000000 | 8192 | gemini15_pro | 2.50 | 10.00 | +| gemini-1.5-pro-latest | chat | Gemini 1.5 Pro Latest | gemini | 2000000 | 8192 | gemini15_pro | 2.50 | 10.00 | +| gemini-2.0-flash | chat | Gemini 2.0 Flash | gemini | 1048576 | 8192 | gemini20_flash | 0.10 | 0.40 | +| gemini-2.0-flash-001 | chat | Gemini 2.0 Flash 001 | gemini | 1048576 | 8192 | gemini20_flash | 0.10 | 0.40 | +| gemini-2.0-flash-exp | chat | Gemini 2.0 Flash Experimental | gemini | 1048576 | 8192 | gemini20_flash | 0.10 | 0.40 | +| gemini-2.0-flash-exp-image-generation | chat | Gemini 2.0 Flash (Image Generation) Experimental | gemini | 1048576 | 8192 | gemini20_flash | 0.10 | 0.40 | +| gemini-2.0-flash-lite | chat | Gemini 2.0 Flash-Lite | gemini | 1048576 | 8192 | gemini20_flash_lite | 0.08 | 0.30 | +| gemini-2.0-flash-lite-001 | chat | Gemini 2.0 Flash-Lite 001 | gemini | 1048576 | 8192 | gemini20_flash_lite | 0.08 | 0.30 | +| gemini-2.0-flash-lite-preview | chat | Gemini 2.0 Flash-Lite Preview | gemini | 1048576 | 8192 | gemini20_flash_lite | 0.08 | 0.30 | +| gemini-2.0-flash-lite-preview-02-05 | chat | Gemini 2.0 Flash-Lite Preview 02-05 | gemini | 1048576 | 8192 | gemini20_flash_lite | 0.08 | 0.30 | +| gemini-2.0-flash-thinking-exp | chat | Gemini 2.0 Flash Thinking Experimental 01-21 | gemini | 1048576 | 65536 | gemini20_flash | 0.10 | 0.40 | +| gemini-2.0-flash-thinking-exp-01-21 | chat | Gemini 2.0 Flash Thinking Experimental 01-21 | gemini | 1048576 | 65536 | gemini20_flash | 0.10 | 0.40 | +| gemini-2.0-flash-thinking-exp-1219 | chat | Gemini 2.0 Flash Thinking Experimental | gemini | 1048576 | 65536 | gemini20_flash | 0.10 | 0.40 | +| gemini-2.0-pro-exp | chat | Gemini 2.0 Pro Experimental | gemini | 2097152 | 8192 | other | 0.08 | 0.30 | +| gemini-2.0-pro-exp-02-05 | chat | Gemini 2.0 Pro Experimental 02-05 | gemini | 2097152 | 8192 | other | 0.08 | 0.30 | +| gemini-embedding-exp | embedding | Gemini Embedding Experimental | gemini | 8192 | 1 | other | 0.00 | 0.00 | +| gemini-embedding-exp-03-07 | embedding | Gemini Embedding Experimental 03-07 | gemini | 8192 | 1 | other | 0.00 | 0.00 | +| gemini-exp-1206 | chat | Gemini Experimental 1206 | gemini | 2097152 | 8192 | other | 0.08 | 0.30 | +| gemini-pro-vision | chat | Gemini 1.0 Pro Vision | gemini | 12288 | 4096 | other | 0.08 | 0.30 | +| gemma-3-27b-it | chat | Gemma 3 27B | gemini | 131072 | 8192 | other | 0.08 | 0.30 | +| imagen-3.0-generate-002 | image | Imagen 3.0 002 model | gemini | 480 | 8192 | other | 0.08 | 0.30 | +| learnlm-1.5-pro-experimental | chat | LearnLM 1.5 Pro Experimental | gemini | 32767 | 8192 | other | 0.08 | 0.30 | +| text-bison-001 | chat | PaLM 2 (Legacy) | gemini | 8196 | 1024 | other | 0.08 | 0.30 | +| text-embedding-004 | embedding | Text Embedding 004 | gemini | 2048 | 1 | embedding4 | 0.00 | 0.00 | + +### Deepseek Models + + | ID | Type | Name | Provider | Context | MaxTok | Family | In$/M | Out$/M | +| :-- | :-- | :-- | :-- | --: | --: | :-- | --: | --: | +| deepseek-chat | chat | DeepSeek V3 | deepseek | 64000 | 8192 | chat | 0.27 | 1.10 | +| deepseek-reasoner | chat | DeepSeek R1 | deepseek | 64000 | 8192 | reasoner | 0.55 | 2.19 | + + +## Model Capabilities + +Each model in the registry includes information about its capabilities: + +- **Context Window**: Maximum number of tokens the model can process in a single request +- **Max Tokens**: Maximum number of tokens the model can generate in a single response +- **Vision Support**: Whether the model can process images +- **Function Calling**: Whether the model supports function calling +- **JSON Mode**: Whether the model can be constrained to output valid JSON +- **Pricing**: Cost per million tokens for input and output + +For more information about working with models, see the [Working with Models](/guides/models) guide. diff --git a/lib/tasks/models_docs.rake b/lib/tasks/models_docs.rake index a8c067ce1..e34ca9764 100644 --- a/lib/tasks/models_docs.rake +++ b/lib/tasks/models_docs.rake @@ -21,15 +21,16 @@ namespace :models do This guide lists all models available in RubyLLM, automatically generated from the current model registry. - _Last updated: #{Time.now.utc.strftime('%Y-%m-%d %H:%M')} UTC_ + This file was generated at #{Time.now.utc.strftime('%Y-%m-%d %H:%M')} UTC, + but the lib/ruby_llm/models.json file from which it was generated may or may not be up to date. ## Contributing The model list is automatically generated from the model registry. To add or update models: - 1. Run `rake models:update` to refresh the model registry. - 2. Run `rake models:update_capabilities` to refresh the model capabilities. - 3. Submit a pull request with the updated `models.json` + 1. Run `rake models:update` to refresh lib/ruby_llm/models.json. + 2. Run `rake models:update_capabilities` to refresh lib/ruby_llm/providers/**/capabilities.rb. + 3. Submit a pull request with the updated files. See [Contributing Guide](/CONTRIBUTING.md) for more details. From 692cf811123029c78e379eb4da33e936f0bb8680 Mon Sep 17 00:00:00 2001 From: "Keith R. Bennett" Date: Sat, 29 Mar 2025 14:56:08 +0800 Subject: [PATCH 06/14] Indicate that "registry" is models.json file. Mention models.json timestamp. Change "Model Capabilities" section to "Additional Model Information" and make the information there more helpful. --- docs/guides/available-models.md | 14 ++++++++------ lib/tasks/models_docs.rake | 14 ++++++++------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/docs/guides/available-models.md b/docs/guides/available-models.md index ceb999b26..0210d6598 100644 --- a/docs/guides/available-models.md +++ b/docs/guides/available-models.md @@ -8,10 +8,12 @@ permalink: /guides/available-models # Available Models -This guide lists all models available in RubyLLM, automatically generated from the current model registry. +This guide lists all models available in RubyLLM, automatically generated from the +current model registry (lib/ruby_llm/models.json). -This file was generated at 2025-03-27 17:45 UTC, +This file was generated at 2025-03-29 06:51 UTC, but the lib/ruby_llm/models.json file from which it was generated may or may not be up to date. +Its timestamp is 2025-03-28 01:45 UTC. ## Contributing @@ -305,13 +307,13 @@ See [Contributing Guide](/CONTRIBUTING.md) for more details. ## Model Capabilities -Each model in the registry includes information about its capabilities: +The tables above show basic model information including context windows, token limits, and pricing. Models also have additional capabilities not shown in the tables: -- **Context Window**: Maximum number of tokens the model can process in a single request -- **Max Tokens**: Maximum number of tokens the model can generate in a single response - **Vision Support**: Whether the model can process images - **Function Calling**: Whether the model supports function calling - **JSON Mode**: Whether the model can be constrained to output valid JSON -- **Pricing**: Cost per million tokens for input and output +- **Structured Output**: Whether the model supports structured output formats + +For complete model information, you can check the `models.json` file in the RubyLLM source code. For more information about working with models, see the [Working with Models](/guides/models) guide. diff --git a/lib/tasks/models_docs.rake b/lib/tasks/models_docs.rake index e34ca9764..3f000e1cc 100644 --- a/lib/tasks/models_docs.rake +++ b/lib/tasks/models_docs.rake @@ -19,10 +19,12 @@ namespace :models do # Available Models - This guide lists all models available in RubyLLM, automatically generated from the current model registry. + This guide lists all models available in RubyLLM, automatically generated from the + current model registry (lib/ruby_llm/models.json). This file was generated at #{Time.now.utc.strftime('%Y-%m-%d %H:%M')} UTC, but the lib/ruby_llm/models.json file from which it was generated may or may not be up to date. + Its timestamp is #{File.mtime('lib/ruby_llm/models.json').strftime('%Y-%m-%d %H:%M')} UTC. ## Contributing @@ -69,16 +71,16 @@ namespace :models do PROVIDER }.compact.join("\n")} - ## Model Capabilities + ## Additional Model Information - Each model in the registry includes information about its capabilities: + The tables above show basic model information including context windows, token limits, and pricing. Models also have additional capabilities not shown in the tables: - - **Context Window**: Maximum number of tokens the model can process in a single request - - **Max Tokens**: Maximum number of tokens the model can generate in a single response - **Vision Support**: Whether the model can process images - **Function Calling**: Whether the model supports function calling - **JSON Mode**: Whether the model can be constrained to output valid JSON - - **Pricing**: Cost per million tokens for input and output + - **Structured Output**: Whether the model supports structured output formats + + For complete model information, you can check the `models.json` file in the RubyLLM source code. For more information about working with models, see the [Working with Models](/guides/models) guide. MARKDOWN From 28040806fc271c404c59bbacafd0c279b00312ac Mon Sep 17 00:00:00 2001 From: "Keith R. Bennett" Date: Sat, 29 Mar 2025 15:13:13 +0800 Subject: [PATCH 07/14] Add "Family" to list of unlisted model attributes. --- lib/tasks/models_docs.rake | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tasks/models_docs.rake b/lib/tasks/models_docs.rake index 3f000e1cc..5838a0920 100644 --- a/lib/tasks/models_docs.rake +++ b/lib/tasks/models_docs.rake @@ -75,6 +75,7 @@ namespace :models do The tables above show basic model information including context windows, token limits, and pricing. Models also have additional capabilities not shown in the tables: + - **Family**: The family of models to which the model belongs. - **Vision Support**: Whether the model can process images - **Function Calling**: Whether the model supports function calling - **JSON Mode**: Whether the model can be constrained to output valid JSON From ae938096d99870be7ec4bd71fc18061c1ec47b96 Mon Sep 17 00:00:00 2001 From: "Keith R. Bennett" Date: Sat, 29 Mar 2025 15:24:02 +0800 Subject: [PATCH 08/14] Move "Additional Model Information" section to top of document. --- docs/guides/available-models.md | 39 +++++++++++++++----------------- lib/tasks/models_docs.rake | 40 +++++++++++++++------------------ 2 files changed, 36 insertions(+), 43 deletions(-) diff --git a/docs/guides/available-models.md b/docs/guides/available-models.md index 0210d6598..683901afe 100644 --- a/docs/guides/available-models.md +++ b/docs/guides/available-models.md @@ -8,23 +8,33 @@ permalink: /guides/available-models # Available Models -This guide lists all models available in RubyLLM, automatically generated from the -current model registry (lib/ruby_llm/models.json). +This guide lists all models available in RubyLLM, automatically generated from the current model registry. -This file was generated at 2025-03-29 06:51 UTC, -but the lib/ruby_llm/models.json file from which it was generated may or may not be up to date. -Its timestamp is 2025-03-28 01:45 UTC. +_Last updated: 2025-03-29_ ## Contributing The model list is automatically generated from the model registry. To add or update models: -1. Run `rake models:update` to refresh lib/ruby_llm/models.json. -2. Run `rake models:update_capabilities` to refresh lib/ruby_llm/providers/**/capabilities.rb. -3. Submit a pull request with the updated files. +1. Edit the appropriate `capabilities.rb` file in `lib/ruby_llm/providers//` +2. Run `rake models:update` to refresh the model registry +3. Submit a pull request with the updated `models.json` See [Contributing Guide](/CONTRIBUTING.md) for more details. +## Additional Model Information + +The tables below show basic model information including context windows, token limits, and pricing. Models also have additional capabilities not shown in the tables: + +- **Vision Support**: Whether the model can process images +- **Function Calling**: Whether the model supports function calling +- **JSON Mode**: Whether the model can be constrained to output valid JSON +- **Structured Output**: Whether the model supports structured output formats + +For complete model information, you can check the `models.json` file in the RubyLLM source code. + +For more information about working with models, see the [Working with Models](/guides/models) guide. + ## Models by Type ### Chat Models @@ -304,16 +314,3 @@ See [Contributing Guide](/CONTRIBUTING.md) for more details. | deepseek-chat | chat | DeepSeek V3 | deepseek | 64000 | 8192 | chat | 0.27 | 1.10 | | deepseek-reasoner | chat | DeepSeek R1 | deepseek | 64000 | 8192 | reasoner | 0.55 | 2.19 | - -## Model Capabilities - -The tables above show basic model information including context windows, token limits, and pricing. Models also have additional capabilities not shown in the tables: - -- **Vision Support**: Whether the model can process images -- **Function Calling**: Whether the model supports function calling -- **JSON Mode**: Whether the model can be constrained to output valid JSON -- **Structured Output**: Whether the model supports structured output formats - -For complete model information, you can check the `models.json` file in the RubyLLM source code. - -For more information about working with models, see the [Working with Models](/guides/models) guide. diff --git a/lib/tasks/models_docs.rake b/lib/tasks/models_docs.rake index 5838a0920..aa0b9e69a 100644 --- a/lib/tasks/models_docs.rake +++ b/lib/tasks/models_docs.rake @@ -19,23 +19,33 @@ namespace :models do # Available Models - This guide lists all models available in RubyLLM, automatically generated from the - current model registry (lib/ruby_llm/models.json). + This guide lists all models available in RubyLLM, automatically generated from the current model registry. - This file was generated at #{Time.now.utc.strftime('%Y-%m-%d %H:%M')} UTC, - but the lib/ruby_llm/models.json file from which it was generated may or may not be up to date. - Its timestamp is #{File.mtime('lib/ruby_llm/models.json').strftime('%Y-%m-%d %H:%M')} UTC. + _Last updated: #{Time.now.utc.strftime('%Y-%m-%d')}_ ## Contributing The model list is automatically generated from the model registry. To add or update models: - 1. Run `rake models:update` to refresh lib/ruby_llm/models.json. - 2. Run `rake models:update_capabilities` to refresh lib/ruby_llm/providers/**/capabilities.rb. - 3. Submit a pull request with the updated files. + 1. Edit the appropriate `capabilities.rb` file in `lib/ruby_llm/providers//` + 2. Run `rake models:update` to refresh the model registry + 3. Submit a pull request with the updated `models.json` See [Contributing Guide](/CONTRIBUTING.md) for more details. + ## Additional Model Information + + The tables below show basic model information including context windows, token limits, and pricing. Models also have additional capabilities not shown in the tables: + + - **Vision Support**: Whether the model can process images + - **Function Calling**: Whether the model supports function calling + - **JSON Mode**: Whether the model can be constrained to output valid JSON + - **Structured Output**: Whether the model supports structured output formats + + For complete model information, you can check the `models.json` file in the RubyLLM source code. + + For more information about working with models, see the [Working with Models](/guides/models) guide. + ## Models by Type ### Chat Models @@ -70,20 +80,6 @@ namespace :models do #{to_markdown_table(models)} PROVIDER }.compact.join("\n")} - - ## Additional Model Information - - The tables above show basic model information including context windows, token limits, and pricing. Models also have additional capabilities not shown in the tables: - - - **Family**: The family of models to which the model belongs. - - **Vision Support**: Whether the model can process images - - **Function Calling**: Whether the model supports function calling - - **JSON Mode**: Whether the model can be constrained to output valid JSON - - **Structured Output**: Whether the model supports structured output formats - - For complete model information, you can check the `models.json` file in the RubyLLM source code. - - For more information about working with models, see the [Working with Models](/guides/models) guide. MARKDOWN File.write('docs/guides/available-models.md', output) From 4d94df33489e8571c2e3f74446662ff2bd669fc6 Mon Sep 17 00:00:00 2001 From: "Keith R. Bennett" Date: Mon, 31 Mar 2025 00:55:32 +0800 Subject: [PATCH 09/14] Add model counts to sections. --- docs/guides/available-models.md | 20 ++++---- lib/tasks/models_docs.rake | 86 ++++++++++++++++----------------- 2 files changed, 53 insertions(+), 53 deletions(-) diff --git a/docs/guides/available-models.md b/docs/guides/available-models.md index 683901afe..ba76d0263 100644 --- a/docs/guides/available-models.md +++ b/docs/guides/available-models.md @@ -10,7 +10,7 @@ permalink: /guides/available-models This guide lists all models available in RubyLLM, automatically generated from the current model registry. -_Last updated: 2025-03-29_ +_Last updated: 2025-03-30_ ## Contributing @@ -37,7 +37,7 @@ For more information about working with models, see the [Working with Models](/g ## Models by Type -### Chat Models +### Chat Models (96) | ID | Type | Name | Provider | Context | MaxTok | Family | In$/M | Out$/M | | :-- | :-- | :-- | :-- | --: | --: | :-- | --: | --: | @@ -138,7 +138,7 @@ For more information about working with models, see the [Working with Models](/g | o3-mini-2025-01-31 | chat | O3-Mini 20250131 | openai | 200000 | 100000 | o3_mini | 0.50 | 1.50 | | text-bison-001 | chat | PaLM 2 (Legacy) | gemini | 8196 | 1024 | other | 0.08 | 0.30 | -### Image Models +### Image Models (3) | ID | Type | Name | Provider | Context | MaxTok | Family | In$/M | Out$/M | | :-- | :-- | :-- | :-- | --: | --: | :-- | --: | --: | @@ -146,7 +146,7 @@ For more information about working with models, see the [Working with Models](/g | dall-e-3 | image | DALL-E-3 | openai | 4096 | 4096 | dalle3 | 0.50 | 1.50 | | imagen-3.0-generate-002 | image | Imagen 3.0 002 model | gemini | 480 | 8192 | other | 0.08 | 0.30 | -### Audio Models +### Audio Models (6) | ID | Type | Name | Provider | Context | MaxTok | Family | In$/M | Out$/M | | :-- | :-- | :-- | :-- | --: | --: | :-- | --: | --: | @@ -157,7 +157,7 @@ For more information about working with models, see the [Working with Models](/g | tts-1-hd-1106 | audio | TTS-1 HD 1106 | openai | 4096 | 4096 | tts1_hd | 0.50 | 1.50 | | whisper-1 | audio | Whisper 1 | openai | 4096 | 4096 | whisper1 | 0.50 | 1.50 | -### Embedding Models +### Embedding Models (8) | ID | Type | Name | Provider | Context | MaxTok | Family | In$/M | Out$/M | | :-- | :-- | :-- | :-- | --: | --: | :-- | --: | --: | @@ -170,7 +170,7 @@ For more information about working with models, see the [Working with Models](/g | text-embedding-3-small | embedding | Text Embedding 3 Small | openai | 4096 | 4096 | embedding3_small | 0.50 | 1.50 | | text-embedding-ada-002 | embedding | Text Embedding Ada 002 | openai | 4096 | 4096 | embedding2 | 0.50 | 1.50 | -### Moderation Models +### Moderation Models (2) | ID | Type | Name | Provider | Context | MaxTok | Family | In$/M | Out$/M | | :-- | :-- | :-- | :-- | --: | --: | :-- | --: | --: | @@ -179,7 +179,7 @@ For more information about working with models, see the [Working with Models](/g ## Models by Provider -### Openai Models +### Openai Models (63) | ID | Type | Name | Provider | Context | MaxTok | Family | In$/M | Out$/M | | :-- | :-- | :-- | :-- | --: | --: | :-- | --: | --: | @@ -247,7 +247,7 @@ For more information about working with models, see the [Working with Models](/g | tts-1-hd-1106 | audio | TTS-1 HD 1106 | openai | 4096 | 4096 | tts1_hd | 0.50 | 1.50 | | whisper-1 | audio | Whisper 1 | openai | 4096 | 4096 | whisper1 | 0.50 | 1.50 | -### Anthropic Models +### Anthropic Models (9) | ID | Type | Name | Provider | Context | MaxTok | Family | In$/M | Out$/M | | :-- | :-- | :-- | :-- | --: | --: | :-- | --: | --: | @@ -261,7 +261,7 @@ For more information about working with models, see the [Working with Models](/g | claude-3-opus-20240229 | chat | Claude 3 Opus | anthropic | 200000 | 4096 | claude3_opus | 15.00 | 75.00 | | claude-3-sonnet-20240229 | chat | Claude 3 Sonnet | anthropic | 200000 | 4096 | claude3_sonnet | 3.00 | 15.00 | -### Gemini Models +### Gemini Models (41) | ID | Type | Name | Provider | Context | MaxTok | Family | In$/M | Out$/M | | :-- | :-- | :-- | :-- | --: | --: | :-- | --: | --: | @@ -307,7 +307,7 @@ For more information about working with models, see the [Working with Models](/g | text-bison-001 | chat | PaLM 2 (Legacy) | gemini | 8196 | 1024 | other | 0.08 | 0.30 | | text-embedding-004 | embedding | Text Embedding 004 | gemini | 2048 | 1 | embedding4 | 0.00 | 0.00 | -### Deepseek Models +### Deepseek Models (2) | ID | Type | Name | Provider | Context | MaxTok | Family | In$/M | Out$/M | | :-- | :-- | :-- | :-- | --: | --: | :-- | --: | --: | diff --git a/lib/tasks/models_docs.rake b/lib/tasks/models_docs.rake index aa0b9e69a..44eb17fed 100644 --- a/lib/tasks/models_docs.rake +++ b/lib/tasks/models_docs.rake @@ -48,56 +48,56 @@ namespace :models do ## Models by Type - ### Chat Models + ### Chat Models (#{RubyLLM.models.chat_models.count}) #{to_markdown_table(RubyLLM.models.chat_models)} - ### Image Models + ### Image Models (#{RubyLLM.models.image_models.count}) #{to_markdown_table(RubyLLM.models.image_models)} - ### Audio Models + ### Audio Models (#{RubyLLM.models.audio_models.count}) #{to_markdown_table(RubyLLM.models.audio_models)} - ### Embedding Models + ### Embedding Models (#{RubyLLM.models.embedding_models.count}) #{to_markdown_table(RubyLLM.models.embedding_models)} - ### Moderation Models + ### Moderation Models (#{RubyLLM.models.select { |m| m.type == 'moderation' }.count}) - #{to_markdown_table(RubyLLM.models.select { |m| m.type == 'moderation'})} + #{to_markdown_table(RubyLLM.models.select { |m| m.type == 'moderation' })} ## Models by Provider - #{RubyLLM::Provider.providers.keys.map { |provider| + #{RubyLLM::Provider.providers.keys.map do |provider| models = RubyLLM.models.by_provider(provider) next if models.none? <<~PROVIDER - ### #{provider.to_s.capitalize} Models + ### #{provider.to_s.capitalize} Models (#{models.count}) #{to_markdown_table(models)} PROVIDER - }.compact.join("\n")} + end.compact.join("\n")} MARKDOWN File.write('docs/guides/available-models.md', output) - puts "Generated docs/guides/available-models.md" + puts 'Generated docs/guides/available-models.md' end private - MODEL_KEYS_TO_DISPLAY = [ - :id, - :type, - :display_name, - :provider, - :context_window, - :max_tokens, - :family, - :input_price_per_million, - :output_price_per_million + MODEL_KEYS_TO_DISPLAY = %i[ + id + type + display_name + provider + context_window + max_tokens + family + input_price_per_million + output_price_per_million ] def to_display_hash(model) @@ -109,43 +109,43 @@ namespace :models do # Create abbreviated headers headers = { - id: "ID", - type: "Type", - display_name: "Name", - provider: "Provider", - context_window: "Context", - max_tokens: "MaxTok", - family: "Family", - input_price_per_million: "In$/M", - output_price_per_million: "Out$/M" + id: 'ID', + type: 'Type', + display_name: 'Name', + provider: 'Provider', + context_window: 'Context', + max_tokens: 'MaxTok', + family: 'Family', + input_price_per_million: 'In$/M', + output_price_per_million: 'Out$/M' } # Create header row with alignment markers # Right-align numbers, left-align text alignments = { - id: ":--", - type: ":--", - display_name: ":--", - provider: ":--", - context_window: "--:", - max_tokens: "--:", - family: ":--", - input_price_per_million: "--:", - output_price_per_million: "--:" + id: ':--', + type: ':--', + display_name: ':--', + provider: ':--', + context_window: '--:', + max_tokens: '--:', + family: ':--', + input_price_per_million: '--:', + output_price_per_million: '--:' } # Build the table lines = [] - + # Header row lines << "| #{MODEL_KEYS_TO_DISPLAY.map { |key| headers[key] }.join(' | ')} |" - + # Alignment row lines << "| #{MODEL_KEYS_TO_DISPLAY.map { |key| alignments[key] }.join(' | ')} |" - + # Data rows model_hashes.each do |model_hash| - values = MODEL_KEYS_TO_DISPLAY.map do |key| + values = MODEL_KEYS_TO_DISPLAY.map do |key| if model_hash[key].is_a?(Float) format('%.2f', model_hash[key]) else @@ -158,4 +158,4 @@ namespace :models do lines.join("\n") end -end \ No newline at end of file +end From 8a2863703d6de1c95749ef090140c45b454f7cf3 Mon Sep 17 00:00:00 2001 From: "Keith R. Bennett" Date: Tue, 1 Apr 2025 10:54:42 +0800 Subject: [PATCH 10/14] Address Rubocop complaints. --- lib/tasks/models_docs.rake | 147 ++++++++++++++++++------------------- 1 file changed, 71 insertions(+), 76 deletions(-) diff --git a/lib/tasks/models_docs.rake b/lib/tasks/models_docs.rake index 44eb17fed..419cd9f5a 100644 --- a/lib/tasks/models_docs.rake +++ b/lib/tasks/models_docs.rake @@ -3,9 +3,77 @@ require 'ruby_llm' require 'fileutils' -namespace :models do +MODEL_KEYS_TO_DISPLAY = %i[ + id + type + display_name + provider + context_window + max_tokens + family + input_price_per_million + output_price_per_million +].freeze + +def to_markdown_table(models) # rubocop:disable Metrics/AbcSize,Metrics/MethodLength + to_display_hash = ->(model) { model.to_h.slice(*MODEL_KEYS_TO_DISPLAY) } + model_hashes = Array(models).map { |model| to_display_hash.call(model) } + + # Create abbreviated headers + headers = { + id: 'ID', + type: 'Type', + display_name: 'Name', + provider: 'Provider', + context_window: 'Context', + max_tokens: 'MaxTok', + family: 'Family', + input_price_per_million: 'In$/M', + output_price_per_million: 'Out$/M' + } + + # Create header row with alignment markers + # Right-align numbers, left-align text + alignments = { + id: ':--', + type: ':--', + display_name: ':--', + provider: ':--', + context_window: '--:', + max_tokens: '--:', + family: ':--', + input_price_per_million: '--:', + output_price_per_million: '--:' + } + + # Build the table + lines = [] + + # Header row + lines << "| #{MODEL_KEYS_TO_DISPLAY.map { |key| headers[key] }.join(' | ')} |" + + # Alignment row + lines << "| #{MODEL_KEYS_TO_DISPLAY.map { |key| alignments[key] }.join(' | ')} |" + + # Data rows + model_hashes.each do |model_hash| + values = MODEL_KEYS_TO_DISPLAY.map do |key| + if model_hash[key].is_a?(Float) + format('%.2f', model_hash[key]) + else + model_hash[key] + end + end + + lines << "| #{values.join(' | ')} |" + end + + lines.join("\n") +end + +namespace :models do # rubocop:disable Metrics/BlockLength desc 'Generate available models documentation' - task :docs do + task :docs do # rubocop:disable Metrics/BlockLength FileUtils.mkdir_p('docs/guides') # ensure output directory exists output = <<~MARKDOWN @@ -73,7 +141,7 @@ namespace :models do #{RubyLLM::Provider.providers.keys.map do |provider| models = RubyLLM.models.by_provider(provider) next if models.none? - + <<~PROVIDER ### #{provider.to_s.capitalize} Models (#{models.count}) @@ -85,77 +153,4 @@ namespace :models do File.write('docs/guides/available-models.md', output) puts 'Generated docs/guides/available-models.md' end - - private - - MODEL_KEYS_TO_DISPLAY = %i[ - id - type - display_name - provider - context_window - max_tokens - family - input_price_per_million - output_price_per_million - ] - - def to_display_hash(model) - model.to_h.slice(*MODEL_KEYS_TO_DISPLAY) - end - - def to_markdown_table(models) - model_hashes = Array(models).map { |model| to_display_hash(model) } - - # Create abbreviated headers - headers = { - id: 'ID', - type: 'Type', - display_name: 'Name', - provider: 'Provider', - context_window: 'Context', - max_tokens: 'MaxTok', - family: 'Family', - input_price_per_million: 'In$/M', - output_price_per_million: 'Out$/M' - } - - # Create header row with alignment markers - # Right-align numbers, left-align text - alignments = { - id: ':--', - type: ':--', - display_name: ':--', - provider: ':--', - context_window: '--:', - max_tokens: '--:', - family: ':--', - input_price_per_million: '--:', - output_price_per_million: '--:' - } - - # Build the table - lines = [] - - # Header row - lines << "| #{MODEL_KEYS_TO_DISPLAY.map { |key| headers[key] }.join(' | ')} |" - - # Alignment row - lines << "| #{MODEL_KEYS_TO_DISPLAY.map { |key| alignments[key] }.join(' | ')} |" - - # Data rows - model_hashes.each do |model_hash| - values = MODEL_KEYS_TO_DISPLAY.map do |key| - if model_hash[key].is_a?(Float) - format('%.2f', model_hash[key]) - else - model_hash[key] - end - end - - lines << "| #{values.join(' | ')} |" - end - - lines.join("\n") - end end From 24e9ffc9bc3fb482892fcbc2f7366ef158b68129 Mon Sep 17 00:00:00 2001 From: "Keith R. Bennett" Date: Wed, 2 Apr 2025 22:29:19 +0800 Subject: [PATCH 11/14] Modify docs.yml to call `rake models:docs`. --- .github/workflows/docs.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index c78163120..2776e99bb 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -5,6 +5,7 @@ on: branches: [main] paths: - 'docs/**' + - 'lib/**' - '.github/workflows/docs.yml' workflow_dispatch: @@ -23,19 +24,32 @@ jobs: steps: - name: Checkout uses: actions/checkout@v4 + - name: Setup Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: '3.3' + bundler-cache: true + + - name: Run models:docs rake task + run: bundle exec rake models:docs + + - name: Setup Ruby for docs uses: ruby/setup-ruby@v1 with: ruby-version: '3.3' bundler-cache: true working-directory: docs + - name: Setup Pages uses: actions/configure-pages@v4 + - name: Build with Jekyll working-directory: docs run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}" env: JEKYLL_ENV: production + - name: Upload artifact uses: actions/upload-pages-artifact@v3 with: @@ -50,4 +64,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v4 + uses: actions/deploy-pages@v4 \ No newline at end of file From 3e7d3cac7712886855db3a6680bca446ce8db5a4 Mon Sep 17 00:00:00 2001 From: "Keith R. Bennett" Date: Wed, 2 Apr 2025 23:00:17 +0800 Subject: [PATCH 12/14] Improve names. --- .github/workflows/docs.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 2776e99bb..ad0f22f6e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -25,7 +25,7 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Setup Ruby + - name: Setup Ruby for models guide generation (ruby_llm environment) uses: ruby/setup-ruby@v1 with: ruby-version: '3.3' @@ -34,7 +34,7 @@ jobs: - name: Run models:docs rake task run: bundle exec rake models:docs - - name: Setup Ruby for docs + - name: Setup Ruby for Jekyll build (ruby_llm environment) uses: ruby/setup-ruby@v1 with: ruby-version: '3.3' From b8384c653613a12b8e2a6ff05a42fb4790f7b0f8 Mon Sep 17 00:00:00 2001 From: "Keith R. Bennett" Date: Wed, 2 Apr 2025 23:01:13 +0800 Subject: [PATCH 13/14] Add 'examples' branch for testing. --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index ad0f22f6e..29dac3fe1 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -2,7 +2,7 @@ name: Deploy docs on: push: - branches: [main] + branches: [main, examples] # Adding `examples` only for testing. Remove later! paths: - 'docs/**' - 'lib/**' From 6dcc2bc4dd9fa29d3c023c20b3167d02b2260241 Mon Sep 17 00:00:00 2001 From: "Keith R. Bennett" Date: Wed, 2 Apr 2025 23:06:49 +0800 Subject: [PATCH 14/14] Remove 'examples' branch, previously added only for testing. --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 29dac3fe1..ad0f22f6e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -2,7 +2,7 @@ name: Deploy docs on: push: - branches: [main, examples] # Adding `examples` only for testing. Remove later! + branches: [main] paths: - 'docs/**' - 'lib/**'