跳到正文
原文
OpenRouter:Announcements(RSS)·· 2025-01-23精选AI 评分62

OpenRouter API 推出网页搜索功能,支持所有模型

Introducing Web Search via the API

AI 导读

OpenRouter API 上线网页搜索功能,适用于所有模型,开发者可通过在模型 slug 后加 :online 或启用 web 插件,将搜索结果直接整合进消息流。

推荐理由

原文给出了接入方式、默认结果数和定价等关键细节,开发者可直接评估是否将网页搜索接入现有 API 工作流。

正文 · 原文

The OpenRouter API now supports a web search feature, available for all models. This enables developers to fetch and integrate web search results directly into their message streams. By appending :online to the model slug or activating the web plugin, you can include relevant, up-to-date information in your workflows.

Key Details

  • Default Behavior: Fetches up to 5 web results per request.
  • Pricing: $4 per 1,000 web results.
  • Integration Options: Use the web plugin directly in your API requests, or the :online shortcut for easier setup.

How it works

The web search plugin uses Exa.ai to retrieve results. Your prompt is passed to Exa, which executes relevant searches and summarizes the results. The results are then merged into a prompt. This is customizable (see below) but by default is:

A web search was conducted on {todays_date}. Incorporate the following web search results into your response. IMPORTANT: Cite them using markdown links named using the domain of the source. Example: nytimes.com. [web search results are inserted here]

The plugin injects this as a system message before the user message in the request payload.

Example Usage

Append :online to any model slug to enable web search.

{
  "model": "openai/gpt-4o:online"
}

This :online tag is simply shorthand for specifying the web plugin, which also works:

{
  "model": "openai/gpt-4o",
  "plugins": [{ "id": "web" }]
}

Customization Options

The web plugin has two customization options:

  • Maximum Results: Control the number of results with max_results (default: 5).
  • Custom Search Prompts: Tailor the prompt used to integrate results into the conversation.

Example:

{
  "model": "openai/gpt-4o:online",
  "plugins": [
    {
      "id": "web",
      "max_results": 3,
      "search_prompt": "Consider these web results when forming your response:"
    }
  ]
}

For more information, check the documentation or try it directly with OpenRouter Chat by toggling the ‘web’ icon on the model selector.

来源:OpenRouter:Announcements(RSS) · openrouter.ai