post https://gw.ask-ai.co/external-search/ask/stream
This endpoint serves as the core interface for the Ask-AI API, designed to process and respond to user questions.
Upon submission of a question, a response in an SSE stream format will be returned.
You can read more here: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events
Event types
candidate_answers
: Pre-generated candidate answers.generative
: A generative response in progress.generative_done
: Event indicating the generative response is done
Chunk Statuses
PENDING
: Stream is pending.RUNNING
: Stream in progress.DONE
: Stream finished.FAILED
: An error occurred.
Server Sent Events
CandidateAnswersEvent
CandidateAnswersEvent
class CandidateAnswersEvent():
question_id: str,
status: ChunkStatus,
event_type: "candidate_answers"
data: {
candidate_answers: List[{
uuid: str
confidence: float
doc_id: str
title: str
html_short: str
html_long: str
source_icon: str
source_id: str
source_type: str
text: str
url: str
valid_url: str
preview_type: str
inner_hierarchy: Optional[List[str]]
reader_is_article_or_section: bool
raw_generated_text: str
source_is_public: Optional[bool]
document_metadata: Optional[{
created_at: Optional[str],
updated_at: Optional[str]
}]
}]
}
Event for delivering candidate answers, with data payload containing a list of candidate answers.
GenerativeEvent
GenerativeEvent
class GenerativeEvent():
question_id: str,
status: ChunkStatus,
event_type: "generative"
data: {
delta: str
attributions: list[{
doc_id: str
chunk_id: str | None = None
title: str | None = None
url: str | None = None
source_id: str | None = None
source_icon: str | None = None
source_type: str | None = None
confidence: float | None = None
chunk_type: str | None = None
preview_type: str | None = None
}]
footnotes: str
}
Event for streaming a generative answer chunk, with data payload containing:
delta
: A piece of the generative answer (used for streaming).attributions
: Document references supporting the answer.footnotes
: Footnote content to supplement the answer.
GenerativeDoneEvent
GenerativeDoneEvent
class GenerativeDoneEvent():
question_id: str,
status: ChunkStatus,
event_type: "generative_done"
data: None
Event indicating that the generative response is complete.
ErrorEvent
ErrorEvent
class ErrorEvent():
status: "FAILED"
reason: str
error: str
debug_info: DebugInfo | None = None
is_retryable: bool | None = None
Event indicating an error, with the available error information and a flag indicating if the request can be retried.
HeartbeatEvent
HeartbeatEvent
A ping event