Repository navigation
Idea: Automatic API awareness #3105
Copy link
Copy link
Closed
Description
My version: 0.14.7 on MacOS 26.0.1 (M2).
So I recently had a very simple use case:
The code opencode created initially included this:
export async function ai(prompt: string): Promise<string> {
const apiKey = (typeof process !== 'undefined' && (process as any).env?.OPENAI_API_KEY) ?? '';
if (!apiKey) {
throw new Error("OPENAI_API_KEY is not set");
}
const body = {
model: "gpt-5-nano",
messages: [{ role: "user", content: prompt }],
temperature: 0.7
};
const res = await fetch("https://api.openai.com/v1/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${apiKey}`
},
body: JSON.stringify(body)
});
if (!res.ok) {
const err = await res.text();
throw new Error(`OpenAI request failed: ${res.status} ${res.statusText} - ${err}`);
}
const data: any = await res.json();
const content = data?.choices?.[0]?.message?.content ?? '';
return content.trim();
}
Later, I wrote bun index.ts (not as an actual shell command, but as just another chat message in the opencode TUI) and after fixing another bug, it also included this:
Shell Run updated index.ts with Bun (CLI harness active)
$ bun index.ts
16 | },
17 | body: JSON.stringify(body)
18 | });
19 | if (!res.ok) {
20 | const err = await res.text();
21 | throw new Error(`OpenAI request failed: ${res.status} ${res.statusText} - ${err}`);
^
error: OpenAI request failed: 400 Bad Request - {
"error": {
"message": "Unsupported value: 'temperature' does not support 0.7 with this model. Only the default (1) value is supported.",
"type": "invalid_request_error",
"param": "temperature",
"code": "unsupported_value"
}
}
at <anonymous> (/Users/nalenz/Programmierung/functional-llm/index.ts:21:9)
Of course opencode did fix it, but I think to improve speed, mistakes like these should not happen in the first place. So I think "awareness of APIs" is very important to have.
For example, when a call to api.openai.com is detected, it could automatically inject the OpenAI API docs. Curious about opinions.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
github-actions commentedon Oct 11, 2025
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case of automatic API documentation injection.
rekram1-node commentedon Oct 11, 2025
So it worked for everything just didn't have most up to date docs for gpt-5 models and their limitations right?
Maybe doing this out of box may happen at some point, right now I think you should use some docs searching tooling, like context7 mcp and add instructions to your global AGENTS.md to tell llm to utilize that mcp when reading docs
taqtiqa-mark commentedon Oct 12, 2025
As @rekram1-node notes, indirectly, opencode did not create any of that code. It came from the AI (LLM) vendor you are using.
Where you do have a good point:
The default OC prompts probably should be well suited to developing OC, in which case that error should not have happened.
But this gets fraught because you end up either having to package some default MCP's with OC (as Goose does), and you have to craft default prompts specialized to OC development.
My 2c, is that this is the path OC should take: Default prompts (and their implicit workflows) are dedicated to developing OC and other prompts and workflows are out-of-scope.
The scope of OC being to provided the maximally performant and robust environment for the widest range of prompts and workflows. See #3112 and #3113.
thdxr commentedon Mar 25, 2026
To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.