Skip to content

[FEATURE]: Optional hosted web search in the one-shot inference API #58174

Open

Description

@SamSamskies

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/generate works for text inference using a connected OpenAI/ChatGPT account and openai/gpt-6-luna.
  • Its request schema accepts only prompt and model, with no tool configuration.
  • POST /api/websearch is a separate search operation. An explicit exa search 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

Activity

  1. opencode-agent commented on Oct 22, 2026

    @opencode-agent
    Contributor

    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 prompt and model and returns { text }, and /api/websearch is a separate route. So this would be a new capability. The maintainers will consider it.

    Related issues:

  2. scrossen commented on Oct 24, 2026

    @scrossen

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions