SDKs & Libraries

Web Search

Enable AI models to search the web in real-time, providing up-to-date information with citations and source attribution.

Updated
Reading time
2 min

On this page

Prerequisites

pip install apertis

Get your API Key from Apertis

from apertis import Apertis

def main():
    client = Apertis()

    response = client.chat.completions.create(
        model="gpt-5.5:web",
        messages=[
            {"role": "user", "content": "What are the latest developments in AI?"}
        ]
    )

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

if __name__ == "__main__":
    main()

Web Search with Citations

from apertis import Apertis

def main():
    client = Apertis()

    response = client.chat.completions.create(
        model="gpt-5.5:web",
        messages=[
            {"role": "user", "content": "What is the current stock price of Apple?"}
        ]
    )

    message = response.choices[0].message

    print("Response:", message.content)

    # Sources found by web search
    if response.web_sources:
        print("\nSources:")
        for source in response.web_sources:
            print(f"  - {source.title}: {source.url}")

if __name__ == "__main__":
    main()

Factual Questions

from apertis import Apertis

def main():
    client = Apertis()

    questions = [
        "Who won the latest Super Bowl?",
        "What is the current population of Tokyo?",
        "When is the next solar eclipse?",
    ]

    for question in questions:
        response = client.chat.completions.create(
            model="gpt-5.5:web",
            messages=[
                {"role": "user", "content": question}
            ]
        )
        print(f"Q: {question}")
        print(f"A: {response.choices[0].message.content}\n")

if __name__ == "__main__":
    main()

Research Assistant

from apertis import Apertis

def main():
    client = Apertis()

    topic = "quantum computing applications in drug discovery"

    response = client.chat.completions.create(
        model="gpt-5.5:web",
        messages=[
            {
                "role": "system",
                "content": "You are a research assistant. Provide comprehensive, well-cited answers."
            },
            {
                "role": "user",
                "content": f"""Research the following topic and provide:
1. Current state of the field
2. Key players and organizations
3. Recent breakthroughs
4. Future outlook

Topic: {topic}"""
            }
        ]
    )

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

if __name__ == "__main__":
    main()

News Summary

from apertis import Apertis

def main():
    client = Apertis()

    response = client.chat.completions.create(
        model="gpt-5.5:web",
        messages=[
            {
                "role": "user",
                "content": """Summarize today's top technology news. Include:
- Company announcements
- Product launches
- Industry trends
Provide sources for each item."""
            }
        ]
    )

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

if __name__ == "__main__":
    main()
from apertis import Apertis

def main():
    client = Apertis()

    stream = client.chat.completions.create(
        model="gpt-5.5:web",
        messages=[
            {"role": "user", "content": "What are the current trends in renewable energy?"}
        ],
        stream=True
    )

    for chunk in stream:
        if chunk.choices and chunk.choices[0].delta.content:
            print(chunk.choices[0].delta.content, end="", flush=True)

    print()

if __name__ == "__main__":
    main()

Competitive Analysis

from apertis import Apertis

def main():
    client = Apertis()

    company = "OpenAI"

    response = client.chat.completions.create(
        model="gpt-5.5:web",
        messages=[
            {
                "role": "user",
                "content": f"""Provide a competitive analysis for {company}:
1. Recent product announcements
2. Market positioning
3. Key competitors
4. Strategic moves
5. Industry perception

Use only current, verifiable information."""
            }
        ]
    )

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

if __name__ == "__main__":
    main()
from apertis import Apertis

def main():
    client = Apertis()

    messages = [
        {"role": "user", "content": "What is the current status of the James Webb Space Telescope?"}
    ]

    # First query
    response = client.chat.completions.create(
        model="gpt-5.5:web",
        messages=messages
    )

    print("Assistant:", response.choices[0].message.content)

    # Follow-up
    messages.append({"role": "assistant", "content": response.choices[0].message.content})
    messages.append({"role": "user", "content": "What are its most recent discoveries?"})

    response = client.chat.completions.create(
        model="gpt-5.5:web",
        messages=messages
    )

    print("\nAssistant:", response.choices[0].message.content)

if __name__ == "__main__":
    main()

Supported Models

Append :web to any non-free model ID, for example:

Provider Models
OpenAI gpt-5.5, gpt-5.4-mini
Anthropic claude-sonnet-4-6, claude-opus-4-5-20251101
Google gemini-3.1-pro-preview, gemini-2.5-flash

View all models →

API Reference

Parameter Type Description
model str Model ID with the :web suffix, for example gpt-5.5:web
web_results_count int Number of search results to use (1-10)
web_content_length str How much page content to use: "short", "medium" or "full"

Web Source Object

Non-streaming responses list the pages used in response.web_sources:

Field Type Description
title str Source page title
url str Source URL
snippet str Relevant excerpt (if available)

Best Practices

  1. Be specific - More specific queries yield better search results
  2. Request citations - Ask the model to cite sources in its response
  3. Use for current events - Web search is ideal for recent/real-time information
  4. Verify important facts - Cross-reference critical information
  5. Consider rate limits - Web search may have additional rate limiting