Repository navigation
Description
Feature hasn't been suggested before.
- I searched existing issues for one-shot generation, hosted web search, and the generate endpoint. Related requests are linked below; I did not find this exact local HTTP API proposal.
Describe the enhancement you want to request
Add optional hosted web search to the one-shot inference API, so an external application can submit one inference request, let the model search when necessary, and receive the final answer with source citations.
For example, an application should be able to ask “What is the weather in Chicago today?” without implementing its own search → inject results → generate loop, or creating, polling, and deleting an OpenCode session.
Current behavior
Tested with OpenCode Desktop/CLI 2.1.3:
POST /api/experimental/generateworks for text inference using a connected OpenAI/ChatGPT account andopenai/gpt-6-luna.- Its request schema accepts only
promptandmodel, with no tool configuration. POST /api/websearchis a separate search operation. An explicitexasearch returned results in this setup.- OpenCode Console documents a hosted search provider, but connecting a search backend does not expose search in the current one-shot generation contract.
The gap is coordinating inference and search behind a single request, rather than adding another standalone search endpoint.
Proposed experience
Illustrative proposal, not currently supported syntax; extending the existing endpoint or adding a separate one-shot tool-enabled endpoint would both work:
{
"prompt": "What is the weather in Chicago today? Include sources and the observation time.",
"model": {
"providerID": "openai",
"id": "gpt-6-luna"
},
"tools": [{ "type": "web_search" }],
"toolChoice": "auto"
}The server would use the configured search provider, including OpenCode Console hosted search where enabled. It could execute the search loop itself or use an upstream model's hosted search capability. The caller would receive the completed answer and citations without managing intermediate tool calls.
Why this is useful
This would make OpenCode's existing provider connections useful to external apps, browser integrations such as Inference Bridge, and small utilities that need occasional current information without embedding a full coding-agent session.
Acceptance criteria
- Search is explicit and optional; existing text-only requests retain their behavior.
- The model can choose whether to search, with bounded search calls and existing provider permissions/budget enforcement.
- The caller receives the final answer plus structured source URLs/citations and an indication of searches performed.
- Search failures, missing authorization, unsupported models, and spending limits are surfaced clearly.
- Cancellation stops the associated generation/search work.
- No persistent user-facing session or access to coding tools is required.
Comparisons and references
- Ollama hosted search (requester’s working comparison): With an Ollama API key, including on the free tier, hosted search works without the application implementing a client-side search loop. The requested OpenCode experience is the same: enable search, submit an inference request, and receive the grounded answer. See also Ollama’s hosted-search documentation.
- OpenAI's single-request interface: Responses API web search lets a caller enable
tools: [{ "type": "web_search" }]and receive a searched answer when the model uses it. - OpenCode Console hosted web search
- Related: [FEATURE]: Ephemeral, tool-capable sessions for the V2 plugin API #58060 requests ephemeral tool-capable sessions and mentions a one-shot helper. This issue focuses on the external HTTP inference contract and optional web search.
- Related: Go
/v1/responses: theoa-compatpath turnstool_search/web_searchinto nameless function tools, so deferred MCP tools and web search are unreachable #57397 reports route-dependent handling ofweb_searchin the hosted Go Responses gateway; it is distinct from exposing search in the local one-shot generate API.
Activity
opencode-agent commentedon Oct 22, 2026
Thanks for the detailed proposal! In short, you're asking for
POST /api/experimental/generate(or a sibling one-shot endpoint) to optionally let the model use the configured web search provider, including OpenCode Console hosted search, and to return the final answer with structured citations. That way an external app wouldn't have to run its own search loop or manage a session.Right now the endpoint is a stateless, tool-less generation: it takes only
promptandmodeland returns{ text }, and/api/websearchis a separate route. So this would be a new capability. The maintainers will consider it.Related issues:
/v1/responses: theoa-compatpath turnstool_search/web_searchinto nameless function tools, so deferred MCP tools and web search are unreachable #57397: how the hosted Go Responses gateway handlesweb_searchdepending on the routescrossen commentedon Oct 24, 2026
An OpenCode-owned orchestration contract could give clients one interface across providers, with native hosted search behind the same response shape. Ollama’s linked docs show a search-results endpoint and a caller-side tool loop; I’d distinguish that interface from an integration that returns the grounded answer in one call.
Two acceptance tests I’d add: cancel after search finishes and assert that no subsequent model call starts; reject citations not traceable to recorded search results or fetched sources. The latter checks provenance, not factual support or URL safety.
Scott, Talavine Code maker.