Threads
Learn how to orchestrate conversational threads with the Alfa (Preview) API.
Learn how to orchestrate conversational threads with the Alfa (Preview) API.
This API is currently in Preview.
Threads keep every Alfa API exchange stateful so you can execute long-running research, pause work, and resume with full context. Each thread stores metadata, message history, task progress, and structured artifacts generated during analysis.
POST /v2/threads to create a new thread and GET /v2/threads to discover existing ones.POST /v2/threads/{thread_id}/messages and stream events using gRPC or SSE streaming.GET /v2/threads/{thread_id}/messages and GET /v2/threads/{thread_id}/artifacts/{artifact_id} respectively.Review the API reference after finishing this guide to inspect every request and response schema.
Submit the user prompt with POST /v2/threads/{thread_id}/messages. Use gRPC or SSE streaming to receive incremental reasoning, artifacts, and completion events in real time.
Threads are lightweight resources. You can list, rename, or delete them without touching other workloads.
Deleting a thread removes all artifacts and history permanently. Be careful when issuing DELETE /v2/threads/{thread_id}.
POST /v2/threads/{thread_id}/messages validates the caller has access to the thread, queues the task, and returns immediately. To receive real-time updates, use gRPC or SSE streaming.
To stream thread events in real time, see the streaming guide for both gRPC and SSE options. If a stream closes before completion, call GET /v2/threads/{thread_id}/progress to check status.
Use the history endpoint to build up the log of chat messages sent over the course of a conversation, and the artifacts endpoint to retrieve structured data output.
Artifacts are structured data outputs (such as tables, charts, or JSON objects) generated during thread execution. Unlike plain text responses, artifacts contain formatted data that can be retrieved and rendered separately using their unique artifact_id.
Tie artifact IDs to the message_id returned by GET /v2/threads/{thread_id}/messages so you can render both the prose answer and the structured data.
Alfa responses include citations that link claims in the generated text back to their source material. Citations appear in three places:
GET /v2/threads/{thread_id}/messages includes a citations array with source metadata.Each citation carries a citation_type that identifies the source category (such as web, news_development, or document) along with type-specific fields like URLs, snippet positions, and article counts. Use this metadata to build source attribution UI — for example, rendering footnotes, expandable source cards, or inline reference links for end users.
For the full list of citation types, field schemas, and JSON examples, see the streaming guide which covers both SSE and gRPC citation formats.
Attach supporting documents directly to a thread so the model can cite them during follow-up prompts. The endpoint expects multipart form data and associates the uploaded blob with the specified thread.
Store the returned file_id next to the thread metadata so later POST /v2/threads/{thread_id}/messages calls can reference the uploaded evidence in user prompts.
Use the cancellation endpoint to stop the currently processing message whenever a user changes their mind. The API records a “User cancelled” entry in the thread so downstream reviewers can see why work halted.