Queries & RAG

The query endpoint is the core of Egret. Send a natural-language compliance question, and Egret searches both the curated regulatory library and your organisation's private documents, then generates a cited answer grounded in real sources.

Make a query

POST https://api.getegret.com/v1/query/
Authorization: Bearer egret_...
Content-Type: application/json

{
  "query": "What is Business Continuity Management according to the FFIEC IT Examination Handbook?",
  "domain": "business-continuity",
  "category": "us",
  "mode": "compliance",
  "model": "us.anthropic.claude-3-5-haiku-20241022-v1:0",
  "knowledge_scope": "public",
  "stream": false
}

Request parameters

FieldTypeRequiredDescription
querystringYesYour compliance question in plain language
domainstringYesDomain slug (e.g. business-continuity). See Domains.
categorystringYesCategory code (e.g. us, sg). See Domains → List categories.
modestringYesControls how the answer is generated.
compliance — prioritises accuracy and maximum source citation, best for regulatory research.
advisory — generates more interpretive, guidance-oriented responses.
auto — automatically classifies your question and routes it to the appropriate mode.
model_idstringNoModel to use. Omit to use the current default model. See Available models.
streambooleanNoSet true to receive a Server-Sent Events stream. Default: false. See Streaming.
session_idstringNoPass the session_id from a previous response to continue a conversation with context.
knowledge_scopestringNoFilter knowledge sources: all (default — public + private), public (regulatory library only), private (your organisation's documents only). Requires an org with an active knowledge base for private.

Response

{
  "response": "# Business Continuity Management (BCM)\n\nBCM is the process for management to oversee and implement resilience, continuity, and response capabilities...",
  "sources": [
    {
      "uri": "s3://egret-docs/business-continuity/pdf/us/ffiec_itbooklet_businesscontinuitymanagement_v3.pdf",
      "filename": "ffiec_itbooklet_businesscontinuitymanagement_v3.pdf",
      "page_number": null,
      "excerpt": "BCM is the process for management to oversee and implement resilience, continuity, and response capabilities to safeguard employees, customers, and products and services.",
      "score": 0.8438505,
      "download_url": "https://egret-docs.s3.amazonaws.com/..."
    }
  ],
  "suggestions": [
    "What are the key differences between Business Continuity Planning and Business Continuity Management?",
    "How do organizations develop a comprehensive BCM strategy?",
    "What role does the board of directors play in BCM?"
  ],
  "context_quality": {
    "insufficient_context": false,
    "chunks_retrieved": 5,
    "avg_relevance_score": 0.815
  },
  "usage": {
    "input_tokens": 9042,
    "output_tokens": 597,
    "cost_usd": 0.0030067,
    "model": "us.anthropic.claude-3-5-haiku-20241022-v1:0"
  },
  "performance": {
    "retrieval_latency_ms": 2003,
    "generation_latency_ms": 12986,
    "total_latency_ms": 15111,
    "chunks_retrieved": 5,
    "avg_relevance_score": 0.815
  },
  "session_id": "53c719f0-4520-45e7-8406-3074c40bf9ce",
  "message_id": 120
}

Response fields

FieldDescription
responseThe generated answer in Markdown format, with inline source references (e.g. [Source 1])
sourcesArray of retrieved document passages. Each entry includes filename, excerpt, relevance score, relevance label, source_type, and a pre-signed download_url to the source PDF
sources[].relevance"Highly Relevant", "Relevant", or "Partially Relevant" — human-readable relevance label
sources[].source_type"document" (Phase B: "web") — the type of knowledge source
suggestionsFollow-up questions suggested by the model based on the retrieved context
context_qualityRetrieval diagnostics — insufficient_context: true means the knowledge base did not contain enough relevant material to answer confidently
usageToken counts, cost in USD, and the model used
performanceLatency breakdown for retrieval and generation
session_idPass this value as session_id in your next request to continue the conversation with context
message_idUnique identifier for this specific message within the session

Available models

The list of available models changes as new models are added. Always fetch the current list from the API rather than hard-coding a model ID:

GET https://api.getegret.com/v1/models/
Authorization: Bearer egret_...

Each model entry includes its model_id, name, tier, credit_cost, supports_streaming, and an is_default flag. Pass the model_id value in your query request. Omit model_id entirely to use whichever model has is_default: true.

See Billing for how credit costs map to your plan.

Next steps

  • Sessions — Continue a conversation across multiple queries
  • Streaming — Receive responses token-by-token via SSE
  • Billing — Understand credit consumption