Class: LlmGateway::Clients::Groq
- Inherits:
-
BaseClient
- Object
- BaseClient
- LlmGateway::Clients::Groq
- Defined in:
- lib/llm_gateway/clients/groq.rb
Constant Summary collapse
- DEFAULT_MODEL =
"openai/gpt-oss-120b"
Instance Attribute Summary
Attributes inherited from BaseClient
Instance Method Summary collapse
- #chat(messages, tools: nil, system: [], model: DEFAULT_MODEL, **options) ⇒ Object
-
#initialize(api_key: ENV["GROQ_API_KEY"]) ⇒ Groq
constructor
A new instance of Groq.
- #stream(messages, tools: nil, system: [], model: DEFAULT_MODEL, **options, &block) ⇒ Object
Methods inherited from BaseClient
#get, #post, #post_file, #post_stream
Constructor Details
#initialize(api_key: ENV["GROQ_API_KEY"]) ⇒ Groq
Returns a new instance of Groq.
10 11 12 13 |
# File 'lib/llm_gateway/clients/groq.rb', line 10 def initialize(api_key: ENV["GROQ_API_KEY"]) @base_endpoint = "https://api.groq.com/openai/v1" super(api_key: api_key) end |
Instance Method Details
#chat(messages, tools: nil, system: [], model: DEFAULT_MODEL, **options) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/llm_gateway/clients/groq.rb', line 15 def chat(, tools: nil, system: [], model: DEFAULT_MODEL, **) body = { model: model, messages: system + , tools: tools } body.merge!() post("chat/completions", body) end |
#stream(messages, tools: nil, system: [], model: DEFAULT_MODEL, **options, &block) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/llm_gateway/clients/groq.rb', line 26 def stream(, tools: nil, system: [], model: DEFAULT_MODEL, **, &block) body = { model: model, messages: system + , tools: tools, stream_options: { include_usage: true } } body.merge!() post_stream("chat/completions", body, &block) end |