GeezerVison is showing github.com — pass through model.options properly without having to nest it under p… · mmacia/opencode@86d5b25
File treeExpand file treeCollapse file tree Open diff view settings web/src/content/docs/docs
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: opencode.json +14Lines changed: 14 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 1 | 1 | { | 2 | 2 | "$schema": "https://opencode.ai/config.json", | | 3 | + "provider": { | | 4 | + "openrouter": { | | 5 | + "models": { | | 6 | + "moonshotai/kimi-k2": { | | 7 | + "options": { | | 8 | + "provider": { | | 9 | + "order": ["baseten"], | | 10 | + "allow_fallbacks": false | | 11 | + } | | 12 | + } | | 13 | + } | | 14 | + } | | 15 | + } | | 16 | + }, | 3 | 17 | "mcp": { | 4 | 18 | "weather": { | 5 | 19 | "type": "local", | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/provider/provider.ts +4-1Lines changed: 4 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -367,7 +367,10 @@ export namespace Provider { | 367 | 367 | const pkg = provider.npm ?? provider.id | 368 | 368 | const mod = await import(await BunProc.install(pkg, "beta")) | 369 | 369 | const fn = mod[Object.keys(mod).find((key) => key.startsWith("create"))!] | 370 | | - const loaded = fn(s.providers[provider.id]?.options) | | 370 | + const loaded = fn({ | | 371 | + name: provider.id, | | 372 | + ...s.providers[provider.id]?.options, | | 373 | + }) | 371 | 374 | s.sdk.set(provider.id, loaded) | 372 | 375 | return loaded as SDK | 373 | 376 | })().catch((e) => { | |
Collapse file Copy file name to clipboardExpand all lines: packages/opencode/src/session/index.ts +6-2Lines changed: 6 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -540,7 +540,9 @@ export namespace Session { | 540 | 540 | const small = (await Provider.getSmallModel(input.providerID)) ?? model | 541 | 541 | generateText({ | 542 | 542 | maxOutputTokens: input.providerID === "google" ? 1024 : 20, | 543 | | - providerOptions: small.info.options, | | 543 | + providerOptions: { | | 544 | + [input.providerID]: small.info.options, | | 545 | + }, | 544 | 546 | messages: [ | 545 | 547 | ...SystemPrompt.title(input.providerID).map( | 546 | 548 | (x): ModelMessage => ({ | @@ -685,7 +687,9 @@ export namespace Session { | 685 | 687 | maxOutputTokens: outputLimit, | 686 | 688 | abortSignal: abort.signal, | 687 | 689 | stopWhen: stepCountIs(1000), | 688 | | - providerOptions: model.info.options, | | 690 | + providerOptions: { | | 691 | + [input.providerID]: model.info.options, | | 692 | + }, | 689 | 693 | messages: [ | 690 | 694 | ...system.map( | 691 | 695 | (x): ModelMessage => ({ | |
Collapse file Copy file name to clipboardExpand all lines: packages/web/src/content/docs/docs/models.mdx +42Lines changed: 42 additions & 0 deletions - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -61,6 +61,48 @@ You can customize the base URL for any provider by setting the `baseURL` option. | 61 | 61 |
| 62 | 62 | --- | 63 | 63 |
| | 64 | +### OpenRouter | | 65 | + | | 66 | +Many OpenRouter models are preloaded by default - you can customize these or add your own. | | 67 | + | | 68 | +Here's an example of specifying a provider | | 69 | + | | 70 | +```json title="opencode.json" | | 71 | +{ | | 72 | + "$schema": "https://opencode.ai/config.json", | | 73 | + "provider": { | | 74 | + "openrouter": { | | 75 | + "models": { | | 76 | + "moonshotai/kimi-k2": { | | 77 | + "options": { | | 78 | + "provider": { | | 79 | + "order": ["baseten"], | | 80 | + "allow_fallbacks": false | | 81 | + } | | 82 | + } | | 83 | + } | | 84 | + } | | 85 | + } | | 86 | + } | | 87 | +} | | 88 | +``` | | 89 | + | | 90 | +You can also add additional models | | 91 | + | | 92 | +```json title="opencode.json" | | 93 | +{ | | 94 | + "$schema": "https://opencode.ai/config.json", | | 95 | + "provider": { | | 96 | + "openrouter": { | | 97 | + "models": { | | 98 | + "somecoolnewmodel": {}, | | 99 | + } | | 100 | + } | | 101 | + } | | 102 | +} | | 103 | + | | 104 | +--- | | 105 | + | 64 | 106 | ### Local | 65 | 107 |
| 66 | 108 | You can configure local model like ones served through LM Studio or Ollama. To | |
|