Skip to main content

Overview

PipeLLM WebSearch provides real-time web search capability through the Gateway, with per-request billing. Perfect for RAG (Retrieval-Augmented Generation) and building AI agents with web access.

Endpoint

MethodEndpoint
GEThttps://api.pipellm.com/v1/websearch/search

Authentication

Use your PipeLLM API key in the Authorization header:
Authorization: Bearer YOUR_PIPELLM_API_KEY

Request

ParameterTypeRequiredDescription
qstringYesSearch query

Example Request

curl -X GET "https://api.pipellm.com/v1/websearch/search?q=latest+AI+news" \
  -H "Authorization: Bearer $PIPELLM_API_KEY"

Response Format

{
  "code": 200,
  "message": "ok",
  "took_ms": 6050,
  "data": {
    "organic": [
      {
        "title": "AI News | Latest News | Insights Powering AI-Driven Business ...",
        "link": "https://www.artificialintelligence-news.com/",
        "snippet": "AI News delivers the latest updates in artificial intelligence, machine learning, deep learning, enterprise AI, and emerging tech worldwide."
      },
      {
        "title": "The Latest AI News and AI Breakthroughs that Matter Most",
        "link": "https://www.crescendo.ai/news/latest-ai-news-and-updates",
        "snippet": "Summary: Xiaomi has announced a next-gen AI voice model optimized for in-car and smart home experiences. The model features faster response times, offline ...",
        "contexts": [
          {
            "idx": 0,
            "text": "December 26, 2025\n\n# The Latest AI News and AI Breakthroughs that Matter Most: 2025..."
          }
        ]
      }
    ]
  }
}

Response Fields

FieldTypeDescription
codeinteger200 for success
messagestringStatus message
took_msintegerTime taken in milliseconds
data.organicarrayList of organic search results
data.organic[].titlestringPage title
data.organic[].linkstringPage URL
data.organic[].snippetstringPage description
data.organic[].contextsarrayFull content contexts extracted from the page (optional)
data.organic[].contexts[].idxintegerIndex of the context
data.organic[].contexts[].textstringThe content text

Error Response

{
  "code": 400,
  "message": "Bad Request, missing query parameter"
}

Pricing

ItemPrice
Per Request$0.05
Billing is per successful request. Failed requests are not charged.

Use Cases

RAG Context Enhancement

Use WebSearch to provide real-time context for your LLM:
import requests
import os
from openai import OpenAI

# Step 1: Search the web
search_response = requests.get(
    "https://api.pipellm.com/v1/websearch/search",
    params={"q": "OpenAI o3 model capabilities"},
    headers={"Authorization": f"Bearer {os.getenv('PIPELLM_API_KEY')}"}
)
search_data = search_response.json()

# Step 2: Extract context
context = "\n".join([
    f"[{r['title']}]({r['link']}): {r['snippet']}"
    for r in search_data.get("data", {}).get("organic", [])[:5]
])

# Step 3: Use with LLM
client = OpenAI(
    api_key=os.getenv("PIPELLM_API_KEY"),
    base_url="https://api.pipellm.com/v1"
)

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[
        {"role": "system", "content": f"Use this context:\n{context}"},
        {"role": "user", "content": "What are the key features of OpenAI o3?"}
    ]
)

print(response.choices[0].message.content)

Rate Limits

WebSearch requests share your account’s rate limit. If you receive a 503 Service Unavailable response with Retry-After header, please wait and retry.