Skip to content

Commit 3fe602c

Browse files
smakoshclauderekram1-node
authored
feat: add LLM Gateway provider (#7847)
Co-authored-by: Claude Opus 4.5 <[email protected]> Co-authored-by: Aiden Cline <[email protected]> Co-authored-by: Aiden Cline <[email protected]>
1 parent 3a4b490 commit 3fe602c

5 files changed

Lines changed: 83 additions & 2 deletions

File tree

packages/opencode/src/provider/provider.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,17 @@ function custom(dep: CustomDep): Record<string, CustomLoader> {
390390
},
391391
}
392392
}),
393+
llmgateway: () =>
394+
Effect.succeed({
395+
autoload: false,
396+
options: {
397+
headers: {
398+
"HTTP-Referer": "https://opencode.ai/",
399+
"X-Title": "opencode",
400+
"X-Source": "opencode",
401+
},
402+
},
403+
}),
393404
openrouter: () =>
394405
Effect.succeed({
395406
autoload: false,

packages/opencode/src/provider/transform.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -807,7 +807,7 @@ export function options(input: {
807807
result["promptCacheKey"] = input.sessionID
808808
}
809809

810-
if (input.model.api.npm === "@openrouter/ai-sdk-provider") {
810+
if (input.model.api.npm === "@openrouter/ai-sdk-provider" || input.model.api.npm === "@llmgateway/ai-sdk-provider") {
811811
result["usage"] = {
812812
include: true,
813813
}
@@ -944,7 +944,7 @@ export function smallOptions(model: Provider.Model) {
944944
}
945945
return { thinkingConfig: { thinkingBudget: 0 } }
946946
}
947-
if (model.providerID === "openrouter") {
947+
if (model.providerID === "openrouter" || model.providerID === "llmgateway") {
948948
if (model.api.id.includes("google")) {
949949
return { reasoning: { enabled: false } }
950950
}

packages/opencode/test/preload.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ delete process.env["AWS_PROFILE"]
6262
delete process.env["AWS_REGION"]
6363
delete process.env["AWS_BEARER_TOKEN_BEDROCK"]
6464
delete process.env["OPENROUTER_API_KEY"]
65+
delete process.env["LLM_GATEWAY_API_KEY"]
6566
delete process.env["GROQ_API_KEY"]
6667
delete process.env["MISTRAL_API_KEY"]
6768
delete process.env["PERPLEXITY_API_KEY"]

packages/ui/src/components/provider-icons/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export const iconNames = [
3232
"perplexity",
3333
"ovhcloud",
3434
"openrouter",
35+
"llmgateway",
3536
"opencode",
3637
"opencode-go",
3738
"openai",

packages/web/src/content/docs/providers.mdx

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,74 @@ OpenCode Zen is a list of tested and verified models provided by the OpenCode te
15771577

15781578
---
15791579

1580+
### LLM Gateway
1581+
1582+
1. Head over to the [LLM Gateway dashboard](https://llmgateway.io/dashboard), click **Create API Key**, and copy the key.
1583+
1584+
2. Run the `/connect` command and search for LLM Gateway.
1585+
1586+
```txt
1587+
/connect
1588+
```
1589+
1590+
3. Enter the API key for the provider.
1591+
1592+
```txt
1593+
┌ API key
1594+
1595+
1596+
└ enter
1597+
```
1598+
1599+
4. Many LLM Gateway models are preloaded by default, run the `/models` command to select the one you want.
1600+
1601+
```txt
1602+
/models
1603+
```
1604+
1605+
You can also add additional models through your opencode config.
1606+
1607+
```json title="opencode.json" {6}
1608+
{
1609+
"$schema": "https://opencode.ai/config.json",
1610+
"provider": {
1611+
"llmgateway": {
1612+
"models": {
1613+
"somecoolnewmodel": {}
1614+
}
1615+
}
1616+
}
1617+
}
1618+
```
1619+
1620+
5. You can also customize them through your opencode config. Here's an example of specifying a provider
1621+
1622+
```json title="opencode.json"
1623+
{
1624+
"$schema": "https://opencode.ai/config.json",
1625+
"provider": {
1626+
"llmgateway": {
1627+
"models": {
1628+
"glm-4.7": {
1629+
"name": "GLM 4.7"
1630+
},
1631+
"gpt-5.2": {
1632+
"name": "GPT-5.2"
1633+
},
1634+
"gemini-2.5-pro": {
1635+
"name": "Gemini 2.5 Pro"
1636+
},
1637+
"claude-3-5-sonnet-20241022": {
1638+
"name": "Claude 3.5 Sonnet"
1639+
}
1640+
}
1641+
}
1642+
}
1643+
}
1644+
```
1645+
1646+
---
1647+
15801648
### SAP AI Core
15811649

15821650
SAP AI Core provides access to 40+ models from OpenAI, Anthropic, Google, Amazon, Meta, Mistral, and AI21 through a unified platform.

0 commit comments

Comments
 (0)