import { AISearchAPIClient } from 'aisearchapi-client';
const client = new AISearchAPIClient({
apiKey: 'YOUR_API_KEY'
});
const response = await client.search({
prompt: 'What are some security risks I should be aware of?',
context: [{
role: 'user',
content: 'I am developing a web app using Node.js and Express.'
}],
response_type: 'markdown'
});
console.log(response);from aisearchapi_client import AISearchAPIClient, ChatMessage
client = AISearchAPIClient(api_key="YOUR_API_KEY")
response = client.search(
prompt="What are some security risks I should be aware of?",
context=[
ChatMessage(role="user", content="user conversation context for the LLM")
],
response_type="markdown"
)
print(response)curl --request POST \
--url https://api.aisearchapi.io/v1/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "What are some security risks I should be aware of?",
"context": [
{
"role": "user",
"content": "I am developing a web app using Node.js and Express."
},
{
"role": "user",
"content": "The app stores personal data, including names and emails."
},
{
"role": "user",
"content": "We plan to deploy it on AWS."
}
],
"response_type": "markdown"
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aisearchapi.io/v1/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => 'What are some security risks I should be aware of?',
'context' => [
[
'role' => 'user',
'content' => 'I am developing a web app using Node.js and Express.'
],
[
'role' => 'user',
'content' => 'The app stores personal data, including names and emails.'
],
[
'role' => 'user',
'content' => 'We plan to deploy it on AWS.'
]
],
'response_type' => 'markdown'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aisearchapi.io/v1/search"
payload := strings.NewReader("{\n \"prompt\": \"What are some security risks I should be aware of?\",\n \"context\": [\n {\n \"role\": \"user\",\n \"content\": \"I am developing a web app using Node.js and Express.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"The app stores personal data, including names and emails.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"We plan to deploy it on AWS.\"\n }\n ],\n \"response_type\": \"markdown\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.aisearchapi.io/v1/search")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"What are some security risks I should be aware of?\",\n \"context\": [\n {\n \"role\": \"user\",\n \"content\": \"I am developing a web app using Node.js and Express.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"The app stores personal data, including names and emails.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"We plan to deploy it on AWS.\"\n }\n ],\n \"response_type\": \"markdown\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aisearchapi.io/v1/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"What are some security risks I should be aware of?\",\n \"context\": [\n {\n \"role\": \"user\",\n \"content\": \"I am developing a web app using Node.js and Express.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"The app stores personal data, including names and emails.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"We plan to deploy it on AWS.\"\n }\n ],\n \"response_type\": \"markdown\"\n}"
response = http.request(request)
puts response.read_body{
"answer": "### Node.js Security Risks and Mitigation Strategies\n\nWhen developing Node.js applications that handle personal data and deploy to AWS, you should be aware of several critical security risks:\n\n**Authentication and Authorization**\n- Implement secure session management\n- Use strong password policies and multi-factor authentication\n- Avoid hardcoded credentials in your code\n\n**Data Protection**\n- Encrypt sensitive data both in transit and at rest\n- Implement proper input validation and sanitization\n- Use HTTPS for all data transmission\n\n**Infrastructure Security**\n- Keep Node.js and dependencies up to date\n- Configure AWS security groups properly\n- Use AWS IAM roles with least privilege principle\n\n**Application Security**\n- Protect against common vulnerabilities like XSS, CSRF, and SQL injection\n- Implement rate limiting and request throttling\n- Use security headers like HSTS, CSP, and X-Frame-Options",
"response_type": "markdown",
"sources": [
"https://owasp.org/www-project-nodejs-goat/",
"https://nodejs.org/en/docs/guides/security/",
"https://aws.amazon.com/security/security-learning/"
],
"response_time": 2847
}{
"error": {
"description": "Invalid or expired API key"
}
}{
"error": {
"description": "Too Many Requests"
}
}{
"error": {
"description": "Account is at / over message quota"
}
}{
"error": {
"description": "Server Error"
}
}Search
Execute a search query.
import { AISearchAPIClient } from 'aisearchapi-client';
const client = new AISearchAPIClient({
apiKey: 'YOUR_API_KEY'
});
const response = await client.search({
prompt: 'What are some security risks I should be aware of?',
context: [{
role: 'user',
content: 'I am developing a web app using Node.js and Express.'
}],
response_type: 'markdown'
});
console.log(response);from aisearchapi_client import AISearchAPIClient, ChatMessage
client = AISearchAPIClient(api_key="YOUR_API_KEY")
response = client.search(
prompt="What are some security risks I should be aware of?",
context=[
ChatMessage(role="user", content="user conversation context for the LLM")
],
response_type="markdown"
)
print(response)curl --request POST \
--url https://api.aisearchapi.io/v1/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"prompt": "What are some security risks I should be aware of?",
"context": [
{
"role": "user",
"content": "I am developing a web app using Node.js and Express."
},
{
"role": "user",
"content": "The app stores personal data, including names and emails."
},
{
"role": "user",
"content": "We plan to deploy it on AWS."
}
],
"response_type": "markdown"
}
'<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.aisearchapi.io/v1/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => 'What are some security risks I should be aware of?',
'context' => [
[
'role' => 'user',
'content' => 'I am developing a web app using Node.js and Express.'
],
[
'role' => 'user',
'content' => 'The app stores personal data, including names and emails.'
],
[
'role' => 'user',
'content' => 'We plan to deploy it on AWS.'
]
],
'response_type' => 'markdown'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.aisearchapi.io/v1/search"
payload := strings.NewReader("{\n \"prompt\": \"What are some security risks I should be aware of?\",\n \"context\": [\n {\n \"role\": \"user\",\n \"content\": \"I am developing a web app using Node.js and Express.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"The app stores personal data, including names and emails.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"We plan to deploy it on AWS.\"\n }\n ],\n \"response_type\": \"markdown\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.aisearchapi.io/v1/search")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"What are some security risks I should be aware of?\",\n \"context\": [\n {\n \"role\": \"user\",\n \"content\": \"I am developing a web app using Node.js and Express.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"The app stores personal data, including names and emails.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"We plan to deploy it on AWS.\"\n }\n ],\n \"response_type\": \"markdown\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.aisearchapi.io/v1/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"What are some security risks I should be aware of?\",\n \"context\": [\n {\n \"role\": \"user\",\n \"content\": \"I am developing a web app using Node.js and Express.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"The app stores personal data, including names and emails.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"We plan to deploy it on AWS.\"\n }\n ],\n \"response_type\": \"markdown\"\n}"
response = http.request(request)
puts response.read_body{
"answer": "### Node.js Security Risks and Mitigation Strategies\n\nWhen developing Node.js applications that handle personal data and deploy to AWS, you should be aware of several critical security risks:\n\n**Authentication and Authorization**\n- Implement secure session management\n- Use strong password policies and multi-factor authentication\n- Avoid hardcoded credentials in your code\n\n**Data Protection**\n- Encrypt sensitive data both in transit and at rest\n- Implement proper input validation and sanitization\n- Use HTTPS for all data transmission\n\n**Infrastructure Security**\n- Keep Node.js and dependencies up to date\n- Configure AWS security groups properly\n- Use AWS IAM roles with least privilege principle\n\n**Application Security**\n- Protect against common vulnerabilities like XSS, CSRF, and SQL injection\n- Implement rate limiting and request throttling\n- Use security headers like HSTS, CSP, and X-Frame-Options",
"response_type": "markdown",
"sources": [
"https://owasp.org/www-project-nodejs-goat/",
"https://nodejs.org/en/docs/guides/security/",
"https://aws.amazon.com/security/security-learning/"
],
"response_time": 2847
}{
"error": {
"description": "Invalid or expired API key"
}
}{
"error": {
"description": "Too Many Requests"
}
}{
"error": {
"description": "Account is at / over message quota"
}
}{
"error": {
"description": "Server Error"
}
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
Search request
The search query.
An ordered list of message objects that define the conversation context for the LLM. Each message contains a role and content. Currently, only the "user" role is supported.
Show child attributes
Show child attributes
The optional format parameter can be "text" or "markdown" (default). "text" returns plain text without formatting, useful for logs or custom-styled outputs. "markdown" includes rich formatting (bold, italics, lists, code, links) for apps that can render Markdown. If omitted, the API defaults to "markdown".
text, markdown Response
Search response
The main response generated by the API based on the provided prompt and context.
The format of the response, as specified by the user.
The list of sources used to generate the response.
The total time taken to generate the response, in milliseconds.

