AI Personal Learning
and practical guidance
TRAE

Bocha AI Open Platform: real-time search API for AI applications

General Introduction

Bocha AI Open Platform is a search engine service platform designed for AI applications. It helps developers make AI connect to real-time world knowledge by providing tools such as Web Search API and Semantic Reranker API. The platform extracts clean, accurate data from nearly 10 billion web pages and ecological content sources, and supports a wide range of content searches, including news, images, and videos. Bocha's goal is to make AI applications smarter and more practical, especially for scenarios that require real-time information or data initialization. It is easy to use, supports flexible invocation, and is suitable for a variety of AI development needs.

Bocha AI Open Platform: real-time search API for AI applications-1


 

Function List

  • Web Search API:: Provides real-time web search functionality, supporting a mix of keyword and semantic searches and returning structured results.
  • Semantic Reranker API:: Secondary sorting of search results to improve the relevance of content to questions.
  • multimodal search: Supports content retrieval in multiple formats such as text, images, videos, etc.
  • Data Filtering and Customization: Parameters such as time range, number of results, etc. can be set to obtain accurate data that meets your needs.
  • Large model optimization: The search result format is designed for large models to be easily processed and understood by AI.

 

Using Help

The use of the Boca AI Open Platform is very straightforward. Developers can integrate search functions through API calls. The following is a detailed description of how to start using it and the actual operation process of the main functions.

How to register and get an API key

  1. Click the "Login" button on the top right corner of the homepage, and use WeChat to scan the code to login (currently only WeChat login is supported).
  2. Once you have successfully logged in, click on "API KEY Management" in the upper right corner.
  3. Click "Create API KEY" on the administration page, and the system will generate a unique key.
  4. Copy this key and save it in a safe place, it will be used later when calling the API.

Calling the Web Search API

The Web Search API is a core feature of Bocha that allows your AI app to search web content in real time. Here are the steps to do so:

Called from the command line

You can usecurlcommand to quickly test the API. the following is an example:

curl --location 'https://api.bochaai.com/v1/web-search' \
--header 'Authorization: Bearer Your-API-KEY' \
--header 'Content-Type: application/json' \
--data '{
"query": "2024年最新科技新闻",
"freshness": "oneMonth",
"summary": true,
"count": 5
}'
  • parameter interpretation:
    • query:: What you want to search for, e.g. "latest tech news 2024".
    • freshness: The time range for the search, which can beoneDay(one day),oneWeek(one week),oneMonth(January),oneYear(one year) ornoLimit(Unlimited).
    • summary: Whether a summary of results is required, fill intrueA short summary will be returned.
    • count: The number of results to return, e.g. 5.
  • running result: After the command is executed, the terminal returns the search results in JSON format, including titles, links, and summaries.

Integration in code

If you develop in Python, you can call the API with the following code:

import requests
import json
url = "https://api.bochaai.com/v1/web-search"
payload = json.dumps({
"query": "2024年最新科技新闻",
"freshness": "oneMonth",
"summary": True,
"count": 5
})
headers = {
'Authorization': 'Bearer Your-API-KEY',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.json())
  • move:
    1. mountingrequestsLibrary (Run)pip install requests).
    2. commander-in-chief (military)Your-API-KEYReplace the key with your own.
    3. Run the code and the program will output the search results.

Using the Semantic Reranker API

This API reorders the search results so that the most relevant ones come first. It needs to be used in conjunction with the Web Search API. The calls are similar, but the official documentation does not provide separate examples. Developers can first use the Web Search API to get the results, and then optimize the sorting through the Reranker API. Specific parameters and usage is recommended to refer to the official documents.

Operational Features

  • multimodal search: InqueryWhen you enter a keyword into the search engine, the API will automatically return text, images or video content. For example, if you search for "cat pictures", there will be links to related images in the results.
  • Flexible filtering:: By adjustingfreshnesscap (a poem)count, you can control the freshness and number of results. For example, if you only want 5 news items from the past week, set thefreshness: oneWeekcap (a poem)count: 5The
  • Large model optimization: The JSON data returned is clearly structured and contains thetitle(Title),url(Link),summary(summary) and other fields that are directly suitable for AI processing.

caveat

  • Ensure that the network is stable and that the API calls require an internet connection.
  • The key should not be leaked and can be regenerated on the admin page after leakage.
  • If the results are unsatisfactory, adjustments can be madequerykeywords or optimized using the Reranker API.

With the above steps, you can quickly get started with the Bocha AI Open Platform and add real-time search functionality to your AI projects.

 

application scenario

  1. AI chatbot
    • Developers can add real-time knowledge to the chatbot using Buchanan's API. For example, if a user asks, "What's the latest tech news?", the bot will be able to return the latest information via the Web Search API.
  2. Academic research tools
    • Researchers can use it to search for academic papers or news, get quick access to background information, and support essay writing or research on a topic.
  3. Content creation support
    • Writers can use the multimodal search function to find inspiration, such as searching for images or video footage to enrich their articles.

 

QA

  1. Do I need to pay for the Boca AI Open Platform?
    • The official website does not specify the pricing, but you need to register and get an API key to use it. It is recommended to contact the official customer service to confirm the exact pricing.
  2. Can I use it to search for English content?
    • Can. Bocha supports multi-language search, and inputting English keywords can also return relevant results, but it is mainly optimized for Chinese Internet content.
  3. What if the API call fails?
    • Check if the network connection, key is correct, or adjust the parameters by referring to the returned error message. If that doesn't work, you can contact technical support.
May not be reproduced without permission:Chief AI Sharing Circle " Bocha AI Open Platform: real-time search API for AI applications
en_USEnglish