Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ GEM
async (>= 2.0)
base64 (0.3.0)
benchmark (0.5.0)
bigdecimal (4.0.1)
bigdecimal (4.1.1)
cgi (0.5.1)
concurrent-ruby (1.3.6)
connection_pool (3.0.2)
Expand Down Expand Up @@ -263,7 +263,7 @@ CHECKSUMS
async-pool (0.11.2) sha256=0a43a17b02b04d9c451b7d12fafa9a50e55dc6dd00d4369aca00433f16a7e3ed
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
benchmark (0.5.0) sha256=465df122341aedcb81a2a24b4d3bd19b6c67c1530713fd533f3ff034e419236c
bigdecimal (4.0.1) sha256=8b07d3d065a9f921c80ceaea7c9d4ae596697295b584c296fe599dd0ad01c4a7
bigdecimal (4.1.1) sha256=1c09efab961da45203c8316b0cdaec0ff391dfadb952dd459584b63ebf8054ca
cgi (0.5.1) sha256=e93fcafc69b8a934fe1e6146121fa35430efa8b4a4047c4893764067036f18e9
concurrent-ruby (1.3.6) sha256=6b56837e1e7e5292f9864f34b69c5a2cbc75c0cf5338f1ce9903d10fa762d5ab
connection_pool (3.0.2) sha256=33fff5ba71a12d2aa26cb72b1db8bba2a1a01823559fb01d29eb74c286e62e0a
Expand Down
23 changes: 22 additions & 1 deletion lib/llm_gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,28 @@ def self.reset_configuration!
@configured_clients = {}
end

# Register built-in providers
# Register built-in providers (canonical keys)
ProviderRegistry.register("anthropic_messages",
client: Clients::Anthropic,
adapter: Adapters::Anthropic::MessagesAdapter)

ProviderRegistry.register("openai_completions",
client: Clients::OpenAI,
adapter: Adapters::OpenAI::ChatCompletionsAdapter)

ProviderRegistry.register("openai_responses",
client: Clients::OpenAI,
adapter: Adapters::OpenAI::ResponsesAdapter)

ProviderRegistry.register("groq_completions",
client: Clients::Groq,
adapter: Adapters::Groq::ChatCompletionsAdapter)

ProviderRegistry.register("openai_codex",
client: Clients::OpenAI,
adapter: Adapters::OpenAICodex::ResponsesAdapter)

# Backward-compatible aliases (deprecated)
ProviderRegistry.register("anthropic_apikey_messages",
client: Clients::Anthropic,
adapter: Adapters::Anthropic::MessagesAdapter)
Expand Down
5 changes: 1 addition & 4 deletions lib/llm_gateway/adapters/structs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class BaseStruct < Dry::Struct
end

class AssistantStreamEvent < BaseStruct
EventType = Types::Coercible::Symbol.enum(:text_start, :text_delta, :text_end, :tool_start, :tool_delta, :tool_end, :reasoning_start, :reasoning_delta, :reasoning_end, :thinking_start, :thinking_delta, :thinking_end)
EventType = Types::Coercible::Symbol.enum(:text_start, :text_delta, :text_end, :tool_start, :tool_delta, :tool_end, :reasoning_start, :reasoning_delta, :reasoning_end)

attribute :type, EventType
attribute :delta, Types::Coercible::String.default { "" }
Expand All @@ -30,9 +30,6 @@ class AssistantStreamReasoningEvent < AssistantStreamEvent
attribute :content_index, Types::Integer
end

# Backward-compatible alias
AssistantStreamThinkingEvent = AssistantStreamReasoningEvent

class AssistantStreamMessageEvent < BaseStruct
EventType = Types::Coercible::Symbol.enum(:message_start, :message_delta, :message_end)

Expand Down
8 changes: 4 additions & 4 deletions lib/llm_gateway/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ def self.build_adapter_from_model(model, api_key: nil, refresh_token: nil, expir

if api == "responses"
config = {
provider: "#{provider}_apikey_responses",
provider: "#{provider}_responses",
model_key: model
}
config[:api_key] = api_key if api_key
LlmGateway.build_provider(config)
else
provider_key = case provider
when "anthropic" then "anthropic_apikey_messages"
when "openai" then "openai_apikey_completions"
when "groq" then "groq_apikey_completions"
when "anthropic" then "anthropic_messages"
when "openai" then "openai_completions"
when "groq" then "groq_completions"
end
config = { provider: provider_key, model_key: model }
config[:api_key] = api_key if api_key
Expand Down
Loading