LLM Endpoints
Unlock NLP Capabilities for Keyword Generation, Q&A, and Semantic Search.
This document provides comprehensive documentation for the WebAI LLM API, which offers natural language processing capabilities including keyword generation, question answering, and NLP-powered search functionality.
Table of Contents
API Endpoints
Authentication
Generate Keywords Endpoint
QnA Endpoint
NLP Search Endpoint
Data Models
Error Handling
API Endpoints
All endpoints are prefixed with /v1.
/generate-keywords
POST
Generate alternative keywords based on input keywords
/qna
POST
Answer questions based on content from a specified domain
/nlp_search
POST
Process natural language queries and convert them to structured search parameters
Authentication
The API uses AWS Cognito for authentication. All requests must include a valid JWT token in the Authorization header.
The token must contain valid claims including:
cognito:usernameorusername: The user's usernamesub: The user's unique identifiercognito:groups: The Cognito groups the user belongs to
Access to certain resources is restricted based on the user's identity and group membership.
Generate Keywords Endpoint
Endpoint
Description
This endpoint takes a list of keywords and generates semantically related alternative keywords. It uses Azure OpenAI's language models to analyze the input keywords and suggest alternatives that capture related themes and concepts.
Request Body
Parameters
keywords
array
Yes
List of input keywords for which related terms will be generated
Response
QnA Endpoint
Endpoint
Description
This endpoint answers questions based on content scraped from a specified domain. It uses web scraping to extract text from the provided URL and then uses a language model to generate an answer to the user's question based on that content.
Request Body
Parameters
question
string
Yes
The user's question
domain
string
Yes
The URL to fetch text from
max_pages
integer
No
Maximum number of pages to scrape (default: 1)
Response
If the question can be answered based on the content:
If the question cannot be answered based on the content:
NLP Search Endpoint
Endpoint
Description
This endpoint processes natural language queries and converts them into structured search parameters. It uses a workflow that analyzes the query to determine intent, extract locations, generate keywords, identify domains, and create semantic search inputs.
Request Body
Parameters
user_query
string
Yes
The natural language query provided by the user
search_id
string
Yes
A unique identifier for the search request
Response
Data Models
Keyword Generation
KeywordRequest
BatchKeyword
QnA
QAResponse
NLP Search
QueryRequest
QueryResponse
Error Handling
The API returns standard HTTP status codes to indicate success or failure:
200 OK: Request was successful400 Bad Request: Invalid request parameters401 Unauthorized: Missing or invalid authentication token403 Forbidden: Authentication successful but access denied500 Internal Server Error: Server-side error
Error responses include a detail message explaining the issue:
For the QnA and Generate Keywords endpoints, errors are also returned in a structured format:
Implementation Details
Language Models
The API uses the following language models:
Azure OpenAI: Used for keyword generation and QnA functionality
OpenAI GPT-4o: Used for NLP search processing
Web Scraping
The QnA endpoint uses web scraping to extract content from the specified domain. It can scrape multiple pages from the same website if the max_pages parameter is greater than 1.
Token Limits
The QnA endpoint limits the document context to a maximum of 40,000 tokens to ensure compatibility with the language model's context window.
Last updated