Skip to main content
POST
Answer API - Web-enhanced AI responses

Authorizations

Authorization
string
header
required

Bearer token authentication using your LLMLayer API key. Include in Authorization header as: Bearer YOUR_LLMLAYER_API_KEY

Body

application/json
query
string
required

The search query or question to answer

Example:

"What are the latest developments in quantum computing?"

model
string
required

LLM model to use (e.g., llmlayer-web, llmlayer-fast, openai/gpt-4o-mini, openai/gpt-5.1)

Example:

"llmlayer-web"

location
string
default:us

Country code for localized search results (us, uk, ca, etc.)

Example:

"us"

provider_key
string | null

Deprecated. Accepted for backward compatibility but currently ignored by the API.

system_prompt
string | null

Custom system prompt to override default behavior. Use this to customize how the LLM processes the search results.

response_language
string
default:auto

Language for the response. 'auto' detects from query, or specify language code (en, es, fr, etc.)

Example:

"auto"

answer_type
enum<string>
default:markdown

Format of the response. Use 'json' with json_schema for structured output.

Available options:
markdown,
html,
json
search_type
enum<string>
default:general

Type of web search to perform. 'news' provides recent news articles.

Available options:
general,
news
json_schema
string | null

JSON schema as string for structured responses. Required when answer_type='json'. The LLM will format its response according to this schema.

Example:

"{\"type\":\"object\",\"properties\":{\"summary\":{\"type\":\"string\"},\"key_points\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}}}"

citations
boolean
default:false

Include inline citations [1], [2] in the response text

return_sources
boolean
default:false

Return the source documents used for answer generation

return_images
boolean
default:false

Return relevant images from image search. Adds $0.001 to cost.

date_filter
enum<string>
default:anytime

Filter search results by recency. Useful for time-sensitive queries.

Available options:
anytime,
hour,
day,
week,
month,
year
max_tokens
integer
default:1500

Maximum tokens in the LLM response. Affects cost.

Required range: x >= 1
temperature
number
default:0.7

Controls response randomness. 0=deterministic, 2=very creative. Not supported by all models.

Required range: 0 <= x <= 2
domain_filter
string[] | null

Include or exclude specific domains. Use '-' prefix to exclude (e.g., ['-reddit.com', 'wikipedia.org'])

Example:
max_queries
integer
default:1

Number of search queries to generate from the user query. More queries = broader search and higher LLMLayer fee. Token-priced models use $0.004 per query; fixed-price LLMLayer models use their model-specific per-query price.

Required range: 1 <= x <= 4
Example:

3

search_context_size
enum<string>
default:medium

Amount of search context to extract and pass to LLM. 'high' provides more context but uses more tokens.

Available options:
low,
medium,
high

Response

Successful response with AI-generated answer

answer
required

The AI-generated answer. String for markdown/html, object for JSON responses.

response_time
string
required

Total processing time in seconds

Example:

"2.34"

input_tokens
integer
required

Total input tokens processed (includes query generation + main LLM call + internal system prompts)

output_tokens
integer
required

Total output tokens generated (includes query generation + main LLM response)

llmlayer_cost
number
required

Cost in USD for LLMLayer search infrastructure. Base cost varies by max_queries and return_images.

sources
object[]

Source documents used (only when return_sources=true)

images
object[]

Relevant images (only when return_images=true)

model_cost
number | null

Cost in USD for LLM usage. Null for fixed-price LLMLayer models.