Skip to main content

Overview

The Answer API combines live web search with LLM generation in one request. Use it when you need:
  • Current information from the web
  • Source-backed responses
  • Structured output (JSON) for downstream processing
  • Streaming UX for chat and copilots

Endpoints

provider_key is accepted for backward compatibility but currently ignored; provider usage is not billed to the user’s provider account.

Authentication

All requests require:
Keep API keys server-side. Do not expose them in browser code.

Model Selection

If unsure, start with llmlayer-web and max_queries=1.

Quickstart

Non-streaming (/answer)

Example response (simplified):

Streaming (/answer_stream)

Request Parameters

This is the canonical request-body table for both endpoints.
HTTP requests use snake_case field names. JavaScript SDK examples use camelCase.
For /answer JSON mode, raw REST requests should send json_schema as a string. The Python and TypeScript SDKs accept schema objects for convenience and serialize them before sending the request.

Parameter Rules

  1. max_queries must be between 1 and 4.
  2. answer_type="json" requires json_schema.
  3. /api/v2/answer_stream does not support structured JSON output.
  4. provider_key does not change routing or billing, and provider usage is not billed to the user’s provider account.
  5. Use -domain.com in domain_filter to exclude domains.

Non-streaming Response Contract (/answer)

Source objects typically include title, link, snippet (plus provider-specific extras). Image objects typically include title, imageUrl, thumbnailUrl, source, link.

Streaming Event Contract (/answer_stream)

The stream is Server-Sent Events (text/event-stream). Each frame contains JSON under data:. Example stream sequence:
On early setup failures, some clients may receive an immediate frame like { "error": "missing_query" }.

Practical Examples

1) News summary with citations

2) Structured JSON extraction (/answer only)

3) Domain-constrained answer

Error Handling

/answer error format

Common status codes

/answer_stream errors

  • Runtime failures are emitted as stream events (type: error).
  • Early validation failures can appear as an immediate single error frame.

Pricing

Standard token-priced models

LLMLayer fixed-price models

Use llmlayer_cost and model_cost from responses as the billing source of truth.

Implementation Checklist

  1. Start with /answer unless you need progressive rendering.
  2. Set max_queries=1 first; increase only for research-style queries.
  3. Enable return_sources=true for trust-sensitive use cases.
  4. Use answer_type="json" + json_schema for structured pipelines.
  5. Add retry/backoff logic for transient 429/500/502 paths.
  6. Keep keys server-side and log llmlayer_cost + token usage.

FAQ

Use /answer_stream for chat UIs and live typing effects. Use /answer for batch jobs, strict request/response flows, and JSON structured output.
No. Streaming returns incremental text chunks and does not support JSON schema-constrained output.
Use domain_filter, search_type, date_filter, and search_context_size together. For factual tasks, use lower temperature.
It is accepted for backward compatibility but currently ignored; provider usage is not billed to the user’s provider account.
The backend currently falls back to llmlayer-web instead of failing the request.
Start with llmlayer-web, keep max_queries=1, only request images/sources when needed, and tune max_tokens to expected output length.

Next Steps

Web Search API

Raw search results without LLM generation

Scraper API

Extract full page content from URLs

Answer Stream Endpoint

OpenAPI reference for SSE endpoint

Python SDK

Python package and usage examples

TypeScript SDK

JS/TS package and usage examples

Need Help?

Discord Community

Ask implementation questions

Email Support