Chat API
The Chat API runs retrieval over your indexed sources (and optional package scope), then generates an answer with citations. UsePOST /chat for a single JSON response, or POST /chat/stream for Server-Sent Events (event: token, event: done, event: error).
Endpoints
Request (POST /chat)
string
required
The question to ask the Ground Agent
string
Optional. When authenticated via JWT (dashboard), continues an existing conversation.
integer
default:"5"
Number of sources to use as context (1-10)
integer
default:"4000"
Maximum tokens for context window
boolean
default:"true"
Include pre-indexed global packages in search
string[]
Optional. Restrict retrieval to specific source IDs (e.g. “talk to one repo”).
string
Optional. Use
ground_docs to limit to Ground’s own documentation source when enabled.Streaming (POST /chat/stream)
Same fields as above, plus optional package_mentions (for example [{"package_name":"react","ecosystem":"npm"}]) to blend in on-demand package context. Consume the SSE stream in your client; the done event includes citations, timing, and conversation_id when persisted.
PDF context (POST /chat/upload-pdf)
Multipart form: file (PDF) and conversation_id. Requires JWT auth matching the conversation. Chunks are stored for ephemeral retrieval during that conversation’s chat turns.
Response
string
AI-generated answer based on Ground’s indexed documentation
array
List of sources used to generate the answer
number
Time taken to search Ground’s index
number
Time taken for AI to generate answer
number
Total response time
string
AI model used (e.g., “gpt-4o”)
Example
Response Example
Notes
- API key requests work for core Q&A; conversation persistence uses JWT (dashboard) with
/conversationsAPIs. - Model id and latency depend on your deployment’s Azure / LLM configuration.
Citations
Answers include source names, paths, and excerpts you can verify in the repo or doc.
Streaming
Use
/chat/stream for token-by-token UX in custom clients.Package scope
Combine indexed sources with on-demand package context where the API supports it.
PDF uploads
Attach PDFs per conversation for short-lived context (JWT).