The "Task" API

Ask deep questions about your website content

All ChatBar AI Search clients also get optional access to the AI Search Task API. This API allows clients to send wide ranging and detailed questions about their website that cannot easily be answered by a standard chat interface. For example an AI Search Task could ask:

Find all pages on the website that have complex grammar or grammatical errors. For each page provide:

  • The URL of the page
  • The original grammar
  • A suggested grammar improvement

To run a Task you will need:

  • The domain of your website
  • The URL for your ChatBar AI Search server
  • The API key for your website

Contact Business Landing or TWOMC if you don't have any of this information.

Task API call format

The body of your API POST must be in JSON format, like the example below. The task_id should be a unique id for your own tracking purposes, but may be nil if tracking is not required.

{
  "callback_url": "https://my-callback-address.com",
  "api_key": "uGTyrM/XARKJ0Xb68EisfRH7q15GHUx",
  "cmd": "execute_task",
  "domain": "<YOUR DOMAIN>",
  "task_id": "<YOUR TASK TRACKING ID>",
  "description": "List the URL of any page containing typos.\nOutput in human readable format.",
  "task_model": "gemini-2.0-flash",
  "context_window_size": 1000000
}

Currently the following there is support for the follow task_model and maximum context window sizes:

Model Name Max Context Window Size
gpt-4o-mini 128000
gpt-4o 128000
o1-mini 128000
o1 200000
o3-mini 200000
gemini-2.0-flash 1000000
gemini-2.0-pro-exp-02-05 2000000

Task API example with CURL

To call the Task API you will need the URL for your AI Search server. Assuming my AI Server URL is https://business-landing.com/aicb I could use the following CURL command to send start a task:

curl -X POST https://business-landing.com/aicb \
  -H "Content-Type: application/json" \
  -d '{
    "callback_url": "https://whacf70462b53ded132f.free.beeceptor.com",
    "api_key": "uGTyrM/XARKJ0Xb68EisfRH7q15GHUx",
    "cmd": "execute_task",
    "domain": "business-landing.com",
    "task_id": 17,
    "description": "List the URL of any page that contains javascript.",
    "task_model": "gemini-2.0-flash",
    "context_window_size": 1000000
  }'

Task Callback URLs

If you do not have the ability to respond to callbacks, then you may use a online service. In the above example we use the free service from Beeceptor. You will need to replace the callback URL with your own Beeceptor callback URL.

Interesting task ideas

Task can take many forms. For example you could check your website SEO with this task:

The Task is to identify any webpage header TITLE that needs improvement.

Analyze the webpage TITLE and check if it is a good match to the webpage content. If it is NOT a good match, then list the URL and explain why it is not a good match. Be aware that the page content may be split over several chunks of page content data, such that the URL is the unique page identifier. Do not report URLs where the title is a good match; simply ignore them.

Consider that when the title is given in the webpage text, it refers to the webpage header TITLE.

In addition, provide the URL to any webpage TITLE that does not follow the guidelines below. Explain why it does not follow the guidelines:

  • Sequences of keywords: This is seen by Google as Keyword Stuffing and therefore as spam, which can lead to a manual penalty and loss of rankings.
  • Irrelevant keywords: For example, spelling terms differently or using keywords that are very general and don't describe the content.
  • Keywords and descriptions that don't differentiate between other pages.
  • Questions in the TITLE are ok as long as they are clear and relevant.
  • The optimum TITLE is typically between 50 and 65 characters long.

For any TITLE that is reported in the output, suggest an alternative.

You could also, for example, ask the task to generate a Instagram script based on a certain subject within you website.

Task Strategies

The default Task strategy is Maximum Accuracy. For many tasks, like SEO analysis or spell-checking, this is the best strategy. However, for some Tasks, it may be sufficient to simply quickly try match a limited amount of content for the Task, in which case the Vector Similarity strategy is cheaper and faster. An example of this might be where the task was:

"Generate a email about <SUBJECT> with links to the page URLs"

You can set the strategy in the API call by setting the stragegy parameter an integer indicating:

  • 0: Maximum Accuracy
  • 1: Vector Similarity

Here is an example with the strategy set to Vector Similarity:  

curl -X POST https://aicb.business-landing.com \
  -H "Content-Type: application/json" \
  -d '{
  "callback_url": "https://my-callback-address.com",
  "api_key": "uGTyrM/XARKJ0Xb68EisfRH7q15GHUx",
  "cmd": "execute_task",
  "domain": "<YOUR DOMAIN>",
  "task_id": "<YOUR TASK TRACKING ID>",
  "description": "Generate an email on the subject of bananas with URLs to the pages.",
  "task_model": "gpt-4o-mini",
  "context_window_size": 128000,
  "strategy": 1,
}'