diff options
| author | Hunter Casten <[email protected]> | 2025-04-24 22:48:48 -0700 |
|---|---|---|
| committer | Kujtim Hoxha <[email protected]> | 2025-04-25 11:11:52 +0200 |
| commit | 7a62ab7675dd042266611205c43e9869a2da1664 (patch) | |
| tree | 80788c9016d3866ac5de3c5a3d3c7c7c2b474bd6 /internal | |
| parent | 1586d757dc64e1e8f65625c289a707a5e34a16b0 (diff) | |
| download | opencode-7a62ab7675dd042266611205c43e9869a2da1664.tar.gz opencode-7a62ab7675dd042266611205c43e9869a2da1664.zip | |
feat(groq): add support for Groq using the OpenAI provider
Diffstat (limited to 'internal')
| -rw-r--r-- | internal/llm/models/groq.go | 82 | ||||
| -rw-r--r-- | internal/llm/models/models.go | 18 | ||||
| -rw-r--r-- | internal/llm/provider/provider.go | 8 |
3 files changed, 91 insertions, 17 deletions
diff --git a/internal/llm/models/groq.go b/internal/llm/models/groq.go new file mode 100644 index 000000000..749895b40 --- /dev/null +++ b/internal/llm/models/groq.go @@ -0,0 +1,82 @@ +package models + +const ( + ProviderGROQ ModelProvider = "groq" + + // GROQ + QWENQwq ModelID = "qwen-qwq" + + // GROQ preview models + Llama4Scout ModelID = "meta-llama/llama-4-scout-17b-16e-instruct" + Llama4Maverick ModelID = "meta-llama/llama-4-maverick-17b-128e-instruct" + Llama3_3_70BVersatile ModelID = "llama-3.3-70b-versatile" + DeepseekR1DistillLlama70b ModelID = "deepseek-r1-distill-llama-70b" +) + +var GroqModels = map[ModelID]Model{ + // + // GROQ + QWENQwq: { + ID: QWENQwq, + Name: "Qwen Qwq", + Provider: ProviderGROQ, + APIModel: "qwen-qwq-32b", + CostPer1MIn: 0.29, + CostPer1MInCached: 0.275, + CostPer1MOutCached: 0.0, + CostPer1MOut: 0.39, + ContextWindow: 128_000, + DefaultMaxTokens: 50000, + // for some reason, the groq api doesn't like the reasoningEffort parameter + CanReason: false, + }, + + Llama4Scout: { + ID: Llama4Scout, + Name: "Llama4Scout", + Provider: ProviderGROQ, + APIModel: "meta-llama/llama-4-scout-17b-16e-instruct", + CostPer1MIn: 0.11, + CostPer1MInCached: 0, + CostPer1MOutCached: 0, + CostPer1MOut: 0.34, + ContextWindow: 128_000, // 10M when? + }, + + Llama4Maverick: { + ID: Llama4Maverick, + Name: "Llama4Maverick", + Provider: ProviderGROQ, + APIModel: "meta-llama/llama-4-maverick-17b-128e-instruct", + CostPer1MIn: 0.20, + CostPer1MInCached: 0, + CostPer1MOutCached: 0, + CostPer1MOut: 0.20, + ContextWindow: 128_000, + }, + + Llama3_3_70BVersatile: { + ID: Llama3_3_70BVersatile, + Name: "Llama3_3_70BVersatile", + Provider: ProviderGROQ, + APIModel: "llama-3.3-70b-versatile", + CostPer1MIn: 0.59, + CostPer1MInCached: 0, + CostPer1MOutCached: 0, + CostPer1MOut: 0.79, + ContextWindow: 128_000, + }, + + DeepseekR1DistillLlama70b: { + ID: DeepseekR1DistillLlama70b, + Name: "DeepseekR1DistillLlama70b", + Provider: ProviderGROQ, + APIModel: "deepseek-r1-distill-llama-70b", + CostPer1MIn: 0.75, + CostPer1MInCached: 0, + CostPer1MOutCached: 0, + CostPer1MOut: 0.99, + ContextWindow: 128_000, + CanReason: true, + }, +} diff --git a/internal/llm/models/models.go b/internal/llm/models/models.go index cccbd2765..1bc02c49d 100644 --- a/internal/llm/models/models.go +++ b/internal/llm/models/models.go @@ -23,17 +23,12 @@ type Model struct { // Model IDs const ( // GEMINI - // GROQ - QWENQwq ModelID = "qwen-qwq" - // Bedrock BedrockClaude37Sonnet ModelID = "bedrock.claude-3.7-sonnet" ) const ( ProviderBedrock ModelProvider = "bedrock" - ProviderGROQ ModelProvider = "groq" - // ForTests ProviderMock ModelProvider = "__mock" ) @@ -63,18 +58,6 @@ var SupportedModels = map[ModelID]Model{ // CostPer1MOut: 0.4, // }, // - // // GROQ - // QWENQwq: { - // ID: QWENQwq, - // Name: "Qwen Qwq", - // Provider: ProviderGROQ, - // APIModel: "qwen-qwq-32b", - // CostPer1MIn: 0, - // CostPer1MInCached: 0, - // CostPer1MOutCached: 0, - // CostPer1MOut: 0, - // }, - // // // Bedrock BedrockClaude37Sonnet: { ID: BedrockClaude37Sonnet, @@ -92,4 +75,5 @@ func init() { maps.Copy(SupportedModels, AnthropicModels) maps.Copy(SupportedModels, OpenAIModels) maps.Copy(SupportedModels, GeminiModels) + maps.Copy(SupportedModels, GroqModels) } diff --git a/internal/llm/provider/provider.go b/internal/llm/provider/provider.go index 4281d658e..00b7b2978 100644 --- a/internal/llm/provider/provider.go +++ b/internal/llm/provider/provider.go @@ -107,6 +107,14 @@ func NewProvider(providerName models.ModelProvider, opts ...ProviderClientOption options: clientOptions, client: newBedrockClient(clientOptions), }, nil + case models.ProviderGROQ: + clientOptions.openaiOptions = append(clientOptions.openaiOptions, + WithOpenAIBaseURL("https://api.groq.com/openai/v1"), + ) + return &baseProvider[OpenAIClient]{ + options: clientOptions, + client: newOpenAIClient(clientOptions), + }, nil case models.ProviderMock: // TODO: implement mock client for test panic("not implemented") |
