AI Search Engine
Last updated
Last updated
AI Web Search Engine is designed to retrieve real-time information from the internet. This solution processes user queries and return relevant data from various online sources, making them useful for tasks that require up-to-date knowledge beyond static datasets. It supports two usage options:
Using six specialized API endpoints, each designed to search for only one specific type of information. These endpoints return structured responses, making them more suitable for integration into specialized services (e.g., a weather widget). Here are the types of information you can retrieve this way:
See API references and examples on the subpages.
As a general chat completion solution (but searching on the internet): enter a query in the prompt and receive an internet-sourced answer, similar to asking a question on a search engine through a browser. See the API Schema below or check how this call is made in the Python example on the bottom of this page.
Check how this call is made in the examples below.
Note that queries can include advanced search syntax:
Search for an exact match: Enter a word or phrase using \"
before and after it.
For example, \"tallest building\"
.
Search for a specific site: Enter site:
in front of a site or domain.
For example, site:youtube.com cat videos
.
Exclude words from your search: Enter -
in front of a word that you want to leave out.
For example, jaguar speed -car
.
You can also personalize the AI Search Engine output by passing the ip
parameter.
See Example #2 below.
import requests
from openai import OpenAI
# Insert your LAPLAS API Key instead of <YOUR_LAPLASAPI_KEY>:
API_KEY = '<YOUR_LAPLASAPI_KEY>'
API_URL = 'https://api.apilaplas.com'
def complete_chat():
client = OpenAI(
base_url=API_URL,
api_key=API_KEY,
)
response = client.chat.completions.create(
model="bagoodex/bagoodex-search-v1",
messages=[
{
"role": "user",
# Enter your query here
"content": 'how to make a slingshot',
},
],
)
print(response.choices[0].message.content)
# Run the function
complete_chat()
When using regular search engines in browsers, we can simply ask, 'Weather today' without specifying our location. In this case, the search engine automatically uses your IP address to determine your location and provide a more relevant response. The AI Search Engine also supports IP-based personalization.
In the example below, the query does not specify a city, but since the request includes an IP address registered in Stockholm, the system automatically adjusts, and the response will contain today's weather forecast for that city.
Note that when making a request via Python, the ip
parameter should be included inside the extra_body
parameter (see example below). When using other languages, this is not required, and the ip
parameter can be passed like any other parameter.
import requests
from openai import OpenAI
# Insert your LAPLAS API Key instead of <YOUR_LAPLASAPI_KEY>:
API_KEY = '<YOUR_LAPLASAPI_KEY>'
API_URL = 'https://api.apilaplas.com'
# Call the standart chat completion endpoint to get an ID
def complete_chat():
client = OpenAI(
base_url=API_URL,
api_key=API_KEY,
)
response = client.chat.completions.create(
model="bagoodex/bagoodex-search-v1",
messages=[
{
"role": "user",
"content": "Weather today",
},
],
# insert your IP into this section
extra_body={
'ip': '192.44.242.19' # we used a random IP address from Stockholm
}
)
print(response.choices[0].message.content)
return response
# Run the function
complete_chat()
Keep in mind that the system caches the IP address for a period of two weeks. This means that after specifying an IP address once, any queries without an explicit location will continue to return responses linked to Stockholm for the next two weeks, even if you don't include the IP address in subsequent requests. If you need to change the location, simply provide a new IP address in your next request.
If an IP address registered in one location is used while explicitly specifying a different location in the query, AI Search Engine will prioritize the location from the query: