answer.generate
Submits a query to a text namespace to get a conversational answer generated by an LLM.Parameters
The single text namespace to search for context, or empty string "" for Direct AI Mode.
The user’s question or prompt.
Number of top relevant chunks for your query across given namespace. Default is 10.
Minimum relevance score threshold (0-1) to filter out chunks below this relevance level. Required when kiosk_mode is true. Only used in Search Mode.
Enable kiosk mode to filter chunks below certain relevance. When kiosk mode is on, threshold is required. Only used in Search Mode.
The identifier for the LLM to use.
A list of previous conversation turns to maintain context.
The sampling temperature for the LLM (0-1). Defaults to 0.7.
Custom instruction for AI behavior.
Custom instruction to append.
Dict[str, Any] - A dictionary containing the answer, model, and other metadata.
Raises: NamespaceNotFound, InvalidInputError.
Search Mode Example (with namespace)
Generate Answer Example
Direct AI Mode Example (empty namespace)
Direct AI Mode Example
Conversational AI with History
Conversational AI with History
Complete Example
Complete Search and AI Workflow
AI Response Structure
AI generation responses contain:AI Response Format
API Modes
Search Mode (with namespace)
When you provide a namespace, the API searches your data for relevant context and uses it to generate contextual answers.Direct AI Mode (empty namespace)
When you pass an empty string"" as namespace, the API makes a direct call to the AI model without searching your data.
Available Models
| Model ID | Name | Provider | Description | Credits |
|---|---|---|---|---|
| anthropic.claude-sonnet-4-20250514-v1:0 | Claude Sonnet 4 | Anthropic | Hybrid reasoning, extended thinking, efficient code generation | 3 |
| anthropic.claude-sonnet-4-5-20250929-v1:0 | Claude Sonnet 4.5 | Anthropic | Latest Claude model with enhanced capabilities and agentic search | 3 |
| anthropic.claude-opus-4-5-20251101-v1:0 | Claude Opus 4.5 | Anthropic | Most advanced Claude model with superior reasoning and extended thinking capabilities | 3 |
| meta.llama4-maverick-17b-instruct-v1:0 | Llama 4 Maverick 17B | Meta | 1M token context, fine tuning, text summarization, function calling | 3 |
| meta.llama3-3-70b-instruct-v1:0 | Llama 3.3 70B | Meta | Advanced reasoning and decision making capabilities | 1 |
| amazon.nova-pro-v1:0 | Amazon Nova Pro | Amazon | 300K context, chat optimized, complex reasoning, math | 2 |
| deepseek.r1-v1:0 | DeepSeek R1 | DeepSeek | Advanced reasoning and code generation | 1 |
Temperature Guide
- 0.0-0.5: Conservative, factual responses - best for technical documentation
- 0.5-1.0: Balanced creativity - good for general Q&A
- 1.0-2.0: More creative and varied responses - use carefully for factual content
Relevance Score Threshold
Results are scored using Information Theoretic Similarity (ITS), providing nuanced relevance measurements:| Label | Score Range | Description |
|---|---|---|
| Close Match | score ≥ 0.894 | Near-perfect relevance to the query |
| Very High Relevance | 0.632 ≤ score < 0.894 | Strongly related content |
| High Relevance | 0.447 ≤ score < 0.632 | Significantly related content |
| Good Relevance | 0.316 ≤ score < 0.447 | Moderately related content |
| Low Relevance | 0.224 ≤ score < 0.316 | Minimally related content |
| Very Low Relevance | 0.1 ≤ score < 0.224 | Barely related content |
| Irrelevant | score < 0.1 | No meaningful relation to the query |
Best Practices
- Provide clear, specific questions
- Use chat history for conversational experiences
- Adjust temperature based on creativity needs
- Choose appropriate AI models for your use case
- For Search Mode: Higher top_k values provide more context but may increase response time
- For Search Mode: The threshold parameter can be used to filter low-relevance results
Use Cases
- Customer Support: Answer customer questions using your documentation
- Internal Q&A: Help employees find answers in company knowledge bases
- Educational Tools: Create AI tutors using educational content
- Research Assistance: Get insights from research papers and publications
- Technical Support: Provide technical answers based on documentation
- Content Creation: Generate content based on existing materials
Related Operations
- Search - Search for relevant context documents
- Upload Text Data - Add documents for AI context
- List Namespaces - View available namespaces for generation