Skip to content

Commit c6854d8

Browse files
Fix OpenCode configuration format in code examples
Update all OpenCode configuration examples to use correct format with options wrapper: provider.anthropic.options.apiKey instead of provider.anthropic.apiKey. This matches the official Config type from @opencode-ai/sdk.
1 parent 9b9a4fa commit c6854d8

File tree

2 files changed

+46
-14
lines changed

2 files changed

+46
-14
lines changed

src/content/docs/sandbox/api/opencode.mdx

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ const { client, server } = await createOpencode<OpencodeClient>(sandbox, {
4848
config: {
4949
provider: {
5050
anthropic: {
51-
apiKey: env.ANTHROPIC_API_KEY
51+
options: {
52+
apiKey: env.ANTHROPIC_API_KEY
53+
}
5254
}
5355
}
5456
}
@@ -104,7 +106,9 @@ export default {
104106
config: {
105107
provider: {
106108
anthropic: {
107-
apiKey: env.ANTHROPIC_API_KEY
109+
options: {
110+
apiKey: env.ANTHROPIC_API_KEY
111+
}
108112
}
109113
}
110114
}
@@ -194,8 +198,12 @@ API keys from `config.provider.*` are automatically extracted and set as environ
194198
await createOpencode(sandbox, {
195199
config: {
196200
provider: {
197-
anthropic: { apiKey: env.ANTHROPIC_API_KEY },
198-
openai: { apiKey: env.OPENAI_API_KEY }
201+
anthropic: {
202+
options: { apiKey: env.ANTHROPIC_API_KEY }
203+
},
204+
openai: {
205+
options: { apiKey: env.OPENAI_API_KEY }
206+
}
199207
}
200208
}
201209
});
@@ -212,7 +220,13 @@ await createOpencode(sandbox, {
212220
```
213221
const { client } = await createOpencode(sandbox, {
214222
port: 8080,
215-
config: { provider: { anthropic: { apiKey: env.KEY } } }
223+
config: {
224+
provider: {
225+
anthropic: {
226+
options: { apiKey: env.KEY }
227+
}
228+
}
229+
}
216230
});
217231
```
218232
</TypeScriptExample>

src/content/docs/sandbox/guides/opencode-integration.mdx

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,9 @@ export default {
9595
config: {
9696
provider: {
9797
anthropic: {
98-
apiKey: env.ANTHROPIC_API_KEY
98+
options: {
99+
apiKey: env.ANTHROPIC_API_KEY
100+
}
99101
}
100102
}
101103
}
@@ -160,7 +162,9 @@ const { client, server } = await createOpencode<OpencodeClient>(sandbox, {
160162
config: {
161163
provider: {
162164
anthropic: {
163-
apiKey: env.ANTHROPIC_API_KEY
165+
options: {
166+
apiKey: env.ANTHROPIC_API_KEY
167+
}
164168
}
165169
}
166170
}
@@ -264,7 +268,9 @@ const { client, server } = await createOpencode(sandbox, {
264268
config: {
265269
provider: {
266270
anthropic: {
267-
apiKey: env.ANTHROPIC_API_KEY
271+
options: {
272+
apiKey: env.ANTHROPIC_API_KEY
273+
}
268274
}
269275
}
270276
}
@@ -282,10 +288,14 @@ const { client } = await createOpencode(sandbox, {
282288
config: {
283289
provider: {
284290
anthropic: {
285-
apiKey: env.ANTHROPIC_API_KEY
291+
options: {
292+
apiKey: env.ANTHROPIC_API_KEY
293+
}
286294
},
287295
openai: {
288-
apiKey: env.OPENAI_API_KEY
296+
options: {
297+
apiKey: env.OPENAI_API_KEY
298+
}
289299
}
290300
}
291301
}
@@ -307,7 +317,9 @@ const { client } = await createOpencode(sandbox, {
307317
config: {
308318
provider: {
309319
anthropic: {
310-
apiKey: env.ANTHROPIC_API_KEY
320+
options: {
321+
apiKey: env.ANTHROPIC_API_KEY
322+
}
311323
}
312324
}
313325
},
@@ -341,7 +353,9 @@ try {
341353
config: {
342354
provider: {
343355
anthropic: {
344-
apiKey: env.ANTHROPIC_API_KEY
356+
options: {
357+
apiKey: env.ANTHROPIC_API_KEY
358+
}
345359
}
346360
}
347361
}
@@ -379,7 +393,9 @@ export default {
379393
config: {
380394
provider: {
381395
anthropic: {
382-
apiKey: env.ANTHROPIC_API_KEY
396+
options: {
397+
apiKey: env.ANTHROPIC_API_KEY
398+
}
383399
}
384400
}
385401
}
@@ -413,7 +429,9 @@ export default {
413429
config: {
414430
provider: {
415431
anthropic: {
416-
apiKey: env.ANTHROPIC_API_KEY
432+
options: {
433+
apiKey: env.ANTHROPIC_API_KEY
434+
}
417435
}
418436
}
419437
}

0 commit comments

Comments
 (0)