Class: LlmGateway::Clients::Groq

Inherits:
BaseClient show all
Defined in:
lib/llm_gateway/clients/groq.rb

Instance Attribute Summary

Attributes inherited from BaseClient

#api_key, #base_endpoint, #model_key

Instance Method Summary collapse

Methods inherited from BaseClient

#get, #post, #post_file, #post_stream

Constructor Details

#initialize(model_key: "openai/gpt-oss-20b", api_key: ENV["GROQ_API_KEY"]) ⇒ Groq

Returns a new instance of Groq.



8
9
10
11
# File 'lib/llm_gateway/clients/groq.rb', line 8

def initialize(model_key: "openai/gpt-oss-20b", api_key: ENV["GROQ_API_KEY"])
  @base_endpoint = "https://api.groq.com/openai/v1"
  super(model_key: model_key, api_key: api_key)
end

Instance Method Details

#chat(messages, tools: nil, system: [], **options) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/llm_gateway/clients/groq.rb', line 13

def chat(messages, tools: nil, system: [], **options)
  body = {
    model: model_key,
    messages: system + messages,
    tools: tools
  }
  body.merge!(options)

  post("chat/completions", body)
end