data: {"type":"start"}
data: {"type":"text-start","id":"msg_abc"}
data: {"type":"text-delta","delta":"Progesterone during the luteal phase "}
data: {"type":"data-sources","data":[{"id":"CXH-00835","score":0.92,"text":"...","metadata":{"doi":"10.1093/humrep/dead156","year":2023}}]}
data: {"type":"finish","finishReason":"stop"}
Have a conversation
Have a conversation — streaming or sync
Dual-mode endpoint. By default (stream omitted or true) returns a streaming
UIMessage SSE response compatible with the Vercel AI SDK useChat hook. Send
stream: false to receive a synchronous JSON response (the SyncResponse shape)
suited for Claude Skills, MCP tool calls, and agent pipelines.
Server-to-server (the only supported pattern for web), or
native-mobile-direct via a short-lived session token minted by
your backend through POST /v1/session-tokens (native mobile only,
not browser/JS — see “API keys” above). Never embed your long-lived key in any client,
browser or mobile.
Rate limits are communicated via X-RateLimit-* headers on every
response and are shared with /v1/query per API key
(see “Rate limits” above). When a 429 is returned, honour
Retry-After before retrying.
Bearer token used by every /v1/* endpoint. Two kinds of key work here:
Long-lived partner key (cxh_pk_live_*) — issued by
CollectiveX Health (contact partners@collectivex.health). Keep
it server-side only — never expose it in client bundles or
mobile app code. This rule is absolute and does not change for
any endpoint.
Short-lived session key — minted server-side via
POST /v1/session-tokens from a long-lived key. Safe to hand
to a native mobile client only — not a browser or other
JavaScript context, see "API keys" in the description above.
It's scoped to /v1/query and /v1/chat only, expires in at
most 60 minutes, and can't mint further session keys.
POST /v1/session-tokens itself only ever accepts the
long-lived key.
Body
application/json
Request body for POST /v1/chat. Uses additionalProperties: false (mirrors Zod .strict()
on the server). Any unknown field returns 400 invalid_request naming the offending field.
Retrieval tuning knobs (topK, rerank, rerankModel, rerankLimit, minScore, filter, mode,
includeRelationships) are intentionally stripped — we curate retrieval; partners don't tune.
When true (default), returns text/event-stream SSE. When false, returns
application/json SyncResponse. Cannot be combined with other streaming
negotiation headers.
Latency note: sync mode waits for the complete generation before the
first response byte (~18s p50 measured in production); streaming
delivers the first answer tokens at roughly half that (~9s p50).
Prefer streaming for anything user-facing — see "Latency: prefer
streaming" in the introduction.
Response
OK. Content type depends on the stream field in the request body:
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Collective X API","colors":{"primary":"#1a3f52","light":"#6aade4","dark":"#101828"},"logo":{"light":"https://mintcdn.com/collective-x/XmdndrtGclqPo6DR/logo/light.svg?fit=max\u0026auto=format\u0026n=XmdndrtGclqPo6DR\u0026q=85\u0026s=a7e95b40e54fc2a5bb8a468486937833","dark":"https://mintcdn.com/collective-x/XmdndrtGclqPo6DR/logo/dark.svg?fit=max\u0026auto=format\u0026n=XmdndrtGclqPo6DR\u0026q=85\u0026s=e49aacf5db1549f425bb1876eb3006ad"},"favicon":"https://mintcdn.com/collective-x/XmdndrtGclqPo6DR/favicon.png?fit=max\u0026auto=format\u0026n=XmdndrtGclqPo6DR\u0026q=85\u0026s=78206f470882a5ed0733d80506b8c90a","navbar":{"links":[{"href":"https://api.collectivex.health","label":"Status"}]},"footer":{},"contextual":{"options":["copy","view","chatgpt","claude","perplexity","mcp","cursor","vscode"],"display":"header"},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"collective-x","hasAudioNarration":false,"actualSubdomain":"collective-x","customDomains":["docs.collectivex.health"],"gitSource":{"type":"github","owner":"collective-x","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":""},"chroma":{"latestBuiltDeploymentHistoryId":"6aa635006cb71c753f702f70","collectionId":"75e7c7d0-413f-4f2e-8fac-bcec7f6e2d60","liveDeploymentHistoryId":"6aa635006cb71c753f702f70","schemaVersion":"v3"},"entitlements":{"AI_CHAT":{"status":"DISABLED"}},"buildId":"6aa635006cb71c753f702f70","clientVersion":"0.0.4006","searchFilterCounts":[{"language":"default","tag":"Guides","count":6},{"language":"default","tag":"API Reference","count":5},{"language":"default","tag":"Getting Started","count":3},{"language":"default","tag":"Features","count":2},{"language":"default","tag":"Async jobs","count":2},{"language":"default","tag":"Reference","count":1},{"language":"default","tag":"Ask a question","count":1},{"language":"default","tag":"Have a conversation","count":1},{"language":"default","tag":"Session tokens","count":1}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"api-reference/have-a-conversation/have-a-conversation-—-streaming-or-sync","slug":"/api-reference/have-a-conversation/have-a-conversation-—-streaming-or-sync","pageMetadata":{"title":"Have a conversation — streaming or sync","description":"Dual-mode endpoint. By default (`stream` omitted or `true`) returns a streaming\nUIMessage SSE response compatible with the Vercel AI SDK `useChat` hook. Send\n`stream: false` to receive a synchronous JSON response (the `SyncResponse` shape)\nsuited for Claude Skills, MCP tool calls, and agent pipelines.\n\n**Server-to-server (the only supported pattern for web), or\nnative-mobile-direct via a short-lived session token** minted by\nyour backend through `POST /v1/session-tokens` (native mobile only,\nnot browser/JS — see \"API keys\" above). Never embed your long-lived key in any client,\nbrowser or mobile.\n\nRate limits are communicated via `X-RateLimit-*` headers on every\nresponse and are shared with `/v1/query` per API key\n(see \"Rate limits\" above). When a 429 is returned, honour\n`Retry-After` before retrying.\n","deprecated":null,"version":null,"openapi":"/openapi.yaml post /v1/chat","href":"/api-reference/have-a-conversation/have-a-conversation-—-streaming-or-sync","autogeneratedByOpenApi":true},"description":{"compiledSource":"\"use strict\";\nconst {Fragment: _Fragment, jsx: _jsx, jsxs: _jsxs} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n code: \"code\",\n p: \"p\",\n strong: \"strong\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsxs(_Fragment, {\n children: [_jsxs(_components.p, {\n children: [\"Dual-mode endpoint. By default (\", _jsx(_components.code, {\n children: \"stream\"\n }), \" omitted or \", _jsx(_components.code, {\n children: \"true\"\n }), \") returns a streaming\\nUIMessage SSE response compatible with the Vercel AI SDK \", _jsx(_components.code, {\n children: \"useChat\"\n }), \" hook. Send\\n\", _jsx(_components.code, {\n children: \"stream: false\"\n }), \" to receive a synchronous JSON response (the \", _jsx(_components.code, {\n children: \"SyncResponse\"\n }), \" shape)\\nsuited for Claude Skills, MCP tool calls, and agent pipelines.\"]\n }), \"\\n\", _jsxs(_components.p, {\n children: [_jsx(_components.strong, {\n children: \"Server-to-server (the only supported pattern for web), or\\nnative-mobile-direct via a short-lived session token\"\n }), \" minted by\\nyour backend through \", _jsx(_components.code, {\n children: \"POST /v1/session-tokens\"\n }), \" (native mobile only,\\nnot browser/JS — see “API keys” above). Never embed your long-lived key in any client,\\nbrowser or mobile.\"]\n }), \"\\n\", _jsxs(_components.p, {\n children: [\"Rate limits are communicated via \", _jsx(_components.code, {\n children: \"X-RateLimit-*\"\n }), \" headers on every\\nresponse and are shared with \", _jsx(_components.code, {\n children: \"/v1/query\"\n }), \" per API key\\n(see “Rate limits” above). When a 429 is returned, honour\\n\", _jsx(_components.code, {\n children: \"Retry-After\"\n }), \" before retrying.\"]\n })]\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){return _jsx(_Fragment,{})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Have a conversation — streaming or sync","description":"Dual-mode endpoint. By default (`stream` omitted or `true`) returns a streaming\nUIMessage SSE response compatible with the Vercel AI SDK `useChat` hook. Send\n`stream: false` to receive a synchronous JSON response (the `SyncResponse` shape)\nsuited for Claude Skills, MCP tool calls, and agent pipelines.\n\n**Server-to-server (the only supported pattern for web), or\nnative-mobile-direct via a short-lived session token** minted by\nyour backend through `POST /v1/session-tokens` (native mobile only,\nnot browser/JS — see \"API keys\" above). Never embed your long-lived key in any client,\nbrowser or mobile.\n\nRate limits are communicated via `X-RateLimit-*` headers on every\nresponse and are shared with `/v1/query` per API key\n(see \"Rate limits\" above). When a 429 is returned, honour\n`Retry-After` before retrying.\n","deprecated":null,"version":null,"openapi":"/openapi.yaml post /v1/chat","href":"/api-reference/have-a-conversation/have-a-conversation-—-streaming-or-sync","autogeneratedByOpenApi":true}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[],"codeExamples":{}},"jsLinks":[],"openApiReferenceData":{"operation":{"operationId":"postChat","summary":"Have a conversation — streaming or sync","tags":["Have a conversation"],"description":"Dual-mode endpoint. By default (`stream` omitted or `true`) returns a streaming\nUIMessage SSE response compatible with the Vercel AI SDK `useChat` hook. Send\n`stream: false` to receive a synchronous JSON response (the `SyncResponse` shape)\nsuited for Claude Skills, MCP tool calls, and agent pipelines.\n\n**Server-to-server (the only supported pattern for web), or\nnative-mobile-direct via a short-lived session token** minted by\nyour backend through `POST /v1/session-tokens` (native mobile only,\nnot browser/JS — see \"API keys\" above). Never embed your long-lived key in any client,\nbrowser or mobile.\n\nRate limits are communicated via `X-RateLimit-*` headers on every\nresponse and are shared with `/v1/query` per API key\n(see \"Rate limits\" above). When a 429 is returned, honour\n`Retry-After` before retrying.\n","security":["6acead53-d14e-478b-946d-f9b96320b416"],"requestBody":"82152c09-c633-4725-8916-23b3de0d5c2d","responses":{"200":"aeb0f0c9-83ef-445d-9238-9aef3bbb76dc","400":"f4076c97-bbfc-470e-b4da-2e58a4ad111a","401":"ca8e1800-0d2e-4ba4-91ff-bd2078687a3e","403":"45d8408d-b697-49b6-825c-54f9514bb7af","429":"5de3fa24-3d90-4e12-9d60-f1c31079802e","500":"e05a1332-ec73-42bb-83aa-cf3b8df04dea","502":"14af4a9e-d4bc-44e9-8d98-70cca3b48e11","503":"13a49fed-e214-43e9-983d-e14676b16de1"},"method":"post","type":"path","servers":["3aec66e8-ea38-412b-92a2-04eeb1a50e2f"],"path":"/v1/chat","baseUrlOptions":["https://api.collectivex.health"],"title":"Have a conversation — streaming or sync","codeSamples":[],"requiredOnlyExamples":false,"requestExampleType":"generated","responseExampleType":"generated"},"dependencies":{"parameters":{},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"description":"Request body for POST /v1/chat. Uses additionalProperties: false (mirrors Zod .strict()\non the server). Any unknown field returns 400 invalid_request naming the offending field.\nRetrieval tuning knobs (topK, rerank, rerankModel, rerankLimit, minScore, filter, mode,\nincludeRelationships) are intentionally stripped — we curate retrieval; partners don't tune.\n","required":["messages"],"properties":{"messages":{"type":"array","description":"Conversation history as AI SDK v6 UIMessage objects. Only the last 10 messages\nare used (matched to the internal pipeline's slice cap).\n","minItems":1,"items":{"type":"object","description":"AI SDK v6 UIMessage shape. id + role + parts are the load-bearing fields.\n`file` parts are rejected with `400 invalid_request` on every endpoint —\nthis API's contract is text questions in, grounded text answers out, and\nfile URLs are never forwarded upstream. Text parts (and, on replayed\nassistant history, the `data-*` parts our own stream emits) are accepted.\n","required":["id","role","parts"],"properties":{"id":{"type":"string","description":"Unique message identifier. AI SDK clients (e.g. useChat) auto-generate\nthis; raw HTTP callers MUST provide it (any opaque string — e.g. UUID,\npartner-side conversation row id). validateUIMessages rejects messages\nwithout an id.\n","isRequired":true,"uniqueKey":"messages.items.[INDEX].id","typeLabel":"string"},"role":{"type":"string","enum":["user","assistant","system"],"description":"Message sender role.","isRequired":true,"uniqueKey":"messages.items.[INDEX].role","typeLabel":"enum\u003cstring>"},"parts":{"type":"array","description":"Message content as an array of parts. Each part has a `type` field.\nFor user messages: use `{ \"type\": \"text\", \"text\": \"...\" }`.\nFor assistant messages: the API returns text-delta parts assembled into parts.\n","items":{"type":"object","description":"A single content part within a UIMessage.","required":["type"],"properties":{"type":{"type":"string","description":"Part type. Common values: \"text\", \"tool-invocation\", \"tool-result\".","isRequired":true,"uniqueKey":"messages.items.[INDEX].parts.items.[INDEX].type","typeLabel":"string"},"text":{"type":"string","description":"Text content (present when type is \"text\").","uniqueKey":"messages.items.[INDEX].parts.items.[INDEX].text","typeLabel":"string"}},"uniqueKey":"messages.items.[INDEX].parts.items.[INDEX]","typeLabel":"object"},"isRequired":true,"uniqueKey":"messages.items.[INDEX].parts","typeLabel":"object[]"}},"uniqueKey":"messages.items.[INDEX]","typeLabel":"object"},"isRequired":true,"uniqueKey":"messages","typeLabel":"object[]"},"stream":{"type":"boolean","default":true,"description":"When true (default), returns text/event-stream SSE. When false, returns\napplication/json SyncResponse. Cannot be combined with other streaming\nnegotiation headers.\n\nLatency note: sync mode waits for the complete generation before the\nfirst response byte (~18s p50 measured in production); streaming\ndelivers the first answer tokens at roughly half that (~9s p50).\nPrefer streaming for anything user-facing — see \"Latency: prefer\nstreaming\" in the introduction.\n","uniqueKey":"stream","typeLabel":"boolean"}},"uniqueKey":"","typeLabel":"object"},"examples":{"stream_request":{"title":"stream_request","value":{"messages":[{"id":"msg_smoke_1","role":"user","parts":[{"type":"text","text":"How does luteal-phase progesterone affect sleep?"}]}]}},"sync_request":{"title":"sync_request","value":{"stream":false,"messages":[{"id":"msg_smoke_1","role":"user","parts":[{"type":"text","text":"How does luteal-phase progesterone affect sleep?"}]}]}}},"exampleType":"examples"}},"exampleType":"examples"},"responses":{"aeb0f0c9-83ef-445d-9238-9aef3bbb76dc":{"description":"OK. Content type depends on the `stream` field in the request body:\n- `stream: true` (default): `text/event-stream` — AI SDK v6 UIMessage SSE protocol.\n- `stream: false`: `application/json` — SyncResponse flat envelope.\n","headers":{"X-Request-Id":{"description":"UUID correlation key for this request (propagated to PostHog + Langfuse).","required":true,"schema":{"type":"string","format":"uuid","example":"550e8400-e29b-41d4-a716-446655440000"}},"X-RateLimit-Limit":{"description":"Maximum requests per minute for this key (shared budget with /v1/query, /v1/jobs/{id}, and /v1/session-tokens; per-key configurable, default 60).","required":true,"schema":{"type":"integer","example":60}},"X-RateLimit-Remaining":{"description":"Requests remaining in the current per-minute rate-limit window.","required":true,"schema":{"type":"integer","example":59}},"X-RateLimit-Reset":{"description":"Unix timestamp (seconds) when the per-minute rate-limit window resets.","required":true,"schema":{"type":"integer","example":1717000060}},"X-RateLimit-Limit-Daily":{"description":"Present only when this key has a configured daily (rpd) budget. Maximum requests per day.","required":false,"schema":{"type":"integer","example":5000}},"X-RateLimit-Remaining-Daily":{"description":"Present only when this key has a configured daily (rpd) budget. Requests remaining in the current day's window.","required":false,"schema":{"type":"integer","example":4321}},"X-RateLimit-Reset-Daily":{"description":"Present only when this key has a configured daily (rpd) budget. Unix timestamp (seconds) when the daily window resets.","required":false,"schema":{"type":"integer","example":1717003600}}},"content":{"text/event-stream":{"schema":{"type":"string","description":"AI SDK v6 UIMessage stream protocol. The response header\n`x-vercel-ai-ui-message-stream: v1` is always present on streaming responses.\n\nEach line is a server-sent event of the form `data: \u003cjson>\\n\\n`.\n\nPartner-visible chunk types (inclusion list — all others are filtered):\n- `start` / `finish` / `start-step` / `finish-step`: control flow brackets\n- `text-start` / `text-delta` / `text-end`: streamed answer text\n- `data-sources`: citation array (one chunk per response)\n- `data-deferral`: emitted when corpus lacks strong evidence (no answer)\n- `data-crisis`: emitted when a safety classifier fires before retrieval\n- `error` / `abort`: error propagation\n\nSee https://ai-sdk.dev/docs/ai-sdk-ui/stream-protocol for full chunk format.\n","uniqueKey":"","typeLabel":"string"},"examples":{"grounded_stream":{"title":"grounded_stream","value":"data: {\"type\":\"start\"}\n\ndata: {\"type\":\"text-start\",\"id\":\"msg_abc\"}\n\ndata: {\"type\":\"text-delta\",\"delta\":\"Progesterone during the luteal phase \"}\n\ndata: {\"type\":\"data-sources\",\"data\":[{\"id\":\"CXH-00835\",\"score\":0.92,\"text\":\"...\",\"metadata\":{\"doi\":\"10.1093/humrep/dead156\",\"year\":2023}}]}\n\ndata: {\"type\":\"finish\",\"finishReason\":\"stop\"}\n"},"deferral_stream":{"title":"deferral_stream","value":"data: {\"type\":\"start\"}\n\ndata: {\"type\":\"data-deferral\",\"data\":{\"originalQuery\":\"How do I lose weight fast?\"}}\n\ndata: {\"type\":\"finish\",\"finishReason\":\"stop\"}\n"}},"exampleType":"examples"},"application/json":{"schema":{"type":"object","description":"Flat JSON envelope returned when stream=false. Always contains request_id, answer,\nand citations. The deferral and crisis fields are mutually exclusive optional fields\npresent when the pipeline short-circuits before generating an answer.\n","required":["request_id","answer","citations"],"properties":{"request_id":{"type":"string","format":"uuid","description":"UUID minted per request. Use for support correlation across PostHog / Langfuse / logs.","isRequired":true,"uniqueKey":"request_id","typeLabel":"string\u003cuuid>"},"answer":{"type":"string","description":"The model's answer string. Empty string (\"\") on deferral or crisis short-circuit\n(the pipeline refuses to generate an answer without grounded evidence).\n","isRequired":true,"uniqueKey":"answer","typeLabel":"string"},"citations":{"type":"array","description":"Retrieved citations from the peer-reviewed corpus. Empty array on deferral or crisis.\nNever fabricate or paraphrase a citation that is not in this array.\n","items":{"type":"object","description":"A single research citation from the CollectiveX Health corpus.","required":["id","score","text"],"properties":{"id":{"type":"string","description":"Corpus-internal citation ID (e.g. \"CXH-00835\"). Use as an inline citation reference.","isRequired":true,"uniqueKey":"citations.items.[INDEX].id","typeLabel":"string"},"score":{"type":"number","format":"float","minimum":0,"maximum":1,"description":"Retrieval relevance score. Higher is more relevant.","isRequired":true,"uniqueKey":"citations.items.[INDEX].score","typeLabel":"number\u003cfloat>"},"text":{"type":"string","description":"Excerpt from the source paper used to ground the answer.","isRequired":true,"uniqueKey":"citations.items.[INDEX].text","typeLabel":"string"},"metadata":{"type":"object","description":"Bibliographic metadata. Strict allowlist — fields not listed here are\nstripped at the `/v1/*` boundary so partners never see Agentset-internal\nfield names. Source of truth: `lib/api/v1/citation-sanitizer.ts`\n(`PARTNER_METADATA_ALLOWLIST`).\n","additionalProperties":false,"properties":{"cxh_id":{"type":"string","description":"Canonical paper identifier in the CollectiveX Health corpus.","example":"CXH-00835","uniqueKey":"citations.items.[INDEX].metadata.cxh_id","typeLabel":"string"},"doi":{"type":"string","description":"Peer-reviewed DOI of the source paper.","example":"10.1093/humrep/dead156","uniqueKey":"citations.items.[INDEX].metadata.doi","typeLabel":"string"},"year":{"type":"string","description":"Publication year as it appears in the corpus catalog. Emitted as a\nstring at runtime (#191) — partners that want a number should\n`parseInt(year, 10)` on the partner side. The corpus also includes\nnon-numeric values like `\"in press\"` for unpublished work.\n","example":"2023","uniqueKey":"citations.items.[INDEX].metadata.year","typeLabel":"string"},"journal":{"type":"string","description":"Peer-review journal name.","example":"Human Reproduction","uniqueKey":"citations.items.[INDEX].metadata.journal","typeLabel":"string"},"authors":{"oneOf":[{"type":"string","description":"Author list — either a single joined string or an array of\nauthor strings; both forms occur in corpus metadata.\n","example":"Shultz et al.","uniqueKey":"citations.items.[INDEX].metadata.authors.oneOf.0","typeLabel":"string"},{"type":"array","items":{"type":"string","uniqueKey":"citations.items.[INDEX].metadata.authors.oneOf.1.items.[INDEX]","typeLabel":"string"},"description":"Author list — either a single joined string or an array of\nauthor strings; both forms occur in corpus metadata.\n","example":"Shultz et al.","uniqueKey":"citations.items.[INDEX].metadata.authors.oneOf.1","typeLabel":"string[]"}],"uniqueKey":"citations.items.[INDEX].metadata.authors","typeLabel":"string | string[]"},"title":{"type":"string","description":"Paper title.","example":"Sex hormone profiles in normal menstruating females","uniqueKey":"citations.items.[INDEX].metadata.title","typeLabel":"string"},"page_number":{"type":"integer","description":"Page within the source paper this excerpt came from.","example":4,"uniqueKey":"citations.items.[INDEX].metadata.page_number","typeLabel":"integer"}},"uniqueKey":"citations.items.[INDEX].metadata","typeLabel":"object"}},"uniqueKey":"citations.items.[INDEX]","typeLabel":"object"},"isRequired":true,"uniqueKey":"citations","typeLabel":"object[]"},"deferral":{"oneOf":[{"type":"null","description":"Present when the corpus lacks strong evidence for the query. Present the originalQuery\nback to the user and do not synthesize an answer from training data.\n","uniqueKey":"deferral.oneOf.0","typeLabel":"null"},{"type":"object","description":"Present when the corpus lacks strong evidence for the query. Present the originalQuery\nback to the user and do not synthesize an answer from training data.\n","required":["originalQuery"],"properties":{"originalQuery":{"type":"string","description":"The query that triggered the deferral.","isRequired":true,"uniqueKey":"deferral.oneOf.1.originalQuery","typeLabel":"string"}},"uniqueKey":"deferral.oneOf.1","typeLabel":"object"}],"uniqueKey":"deferral","typeLabel":"null | object"},"crisis":{"oneOf":[{"type":"null","description":"Present when a safety classifier fires before retrieval (self-harm, acute symptoms,\nIPV). Show the resources verbatim and route the user away from research framing.\n","uniqueKey":"crisis.oneOf.0","typeLabel":"null"},{"type":"object","description":"Present when a safety classifier fires before retrieval (self-harm, acute symptoms,\nIPV). Show the resources verbatim and route the user away from research framing.\n","required":["category","locale","originalQuery","resources"],"properties":{"category":{"type":"string","enum":["self-harm","acute-symptom","ipv"],"description":"Safety category that triggered the classifier.","isRequired":true,"uniqueKey":"crisis.oneOf.1.category","typeLabel":"enum\u003cstring>"},"locale":{"type":"string","description":"Detected locale (e.g. \"US\", \"GB\"). Used to select region-appropriate resources.","example":"US","isRequired":true,"uniqueKey":"crisis.oneOf.1.locale","typeLabel":"string"},"originalQuery":{"type":"string","description":"The query that triggered the crisis classifier.","isRequired":true,"uniqueKey":"crisis.oneOf.1.originalQuery","typeLabel":"string"},"resources":{"type":"array","description":"Crisis resources to show verbatim. Never omit or reorder.","items":{"type":"object","description":"A single crisis support resource. Render verbatim — do not reorder, summarise, or\nomit fields. Source of truth: `lib/safety/crisis-resources.ts`.\n","required":["region","name","description"],"properties":{"region":{"type":"string","enum":["US","UK","global"],"description":"Region this resource applies to.","example":"US","isRequired":true,"uniqueKey":"crisis.oneOf.1.resources.items.[INDEX].region","typeLabel":"enum\u003cstring>"},"name":{"type":"string","description":"Human-readable resource name.","example":"988 Suicide \u0026 Crisis Lifeline","isRequired":true,"uniqueKey":"crisis.oneOf.1.resources.items.[INDEX].name","typeLabel":"string"},"description":{"type":"string","description":"Short context line shown next to the resource.","example":"24/7 free, confidential support for people in distress.","isRequired":true,"uniqueKey":"crisis.oneOf.1.resources.items.[INDEX].description","typeLabel":"string"},"phone":{"type":"string","description":"Phone or SMS contact (optional). Format varies by region.","example":"988","uniqueKey":"crisis.oneOf.1.resources.items.[INDEX].phone","typeLabel":"string"},"hours":{"type":"string","description":"Operating hours, when not 24/7 (optional).","example":"Mon–Fri 9am–5pm ET","uniqueKey":"crisis.oneOf.1.resources.items.[INDEX].hours","typeLabel":"string"}},"uniqueKey":"crisis.oneOf.1.resources.items.[INDEX]","typeLabel":"object"},"isRequired":true,"uniqueKey":"crisis.oneOf.1.resources","typeLabel":"object[]"}},"uniqueKey":"crisis.oneOf.1","typeLabel":"object"}],"uniqueKey":"crisis","typeLabel":"null | object"},"error":{"description":"Present when the generation pipeline emitted an error (v1.1, optional). The message\nis always a generic sanitized string — internal error details are never exposed.\nWith no usable content the response status is 502; alongside a partial answer or a\ndeferral/crisis short-circuit the status stays 200 and this field flags the failure.\n","type":"object","required":["message"],"properties":{"message":{"type":"string","description":"Generic human-readable failure message. Safe to display; do not parse.","example":"Generation failed. Please retry.","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"}},"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"grounded_sync":{"title":"grounded_sync","value":{"request_id":"a1b2c3d4-e5f6-7890-abcd-ef1234567890","answer":"Progesterone during the luteal phase has a thermogenic effect...","citations":[{"id":"CXH-00835","score":0.92,"text":"Transdermal estradiol was associated with significant reductions...","metadata":{"cxh_id":"CXH-00835","doi":"10.1093/humrep/dead156","year":2023}}]}},"deferral_sync":{"title":"deferral_sync","value":{"request_id":"b2c3d4e5-f6a7-8901-bcde-f12345678901","answer":"","citations":[],"deferral":{"originalQuery":"How do I lose weight fast?"}}},"crisis_sync":{"title":"crisis_sync","value":{"request_id":"c3d4e5f6-a7b8-9012-cdef-123456789012","answer":"","citations":[],"crisis":{"category":"self-harm","locale":"US","originalQuery":"I want to hurt myself","resources":[{"region":"US","name":"988 Suicide \u0026 Crisis Lifeline","description":"24/7 free, confidential support for people in distress.","phone":"988"}]}}}},"exampleType":"examples"}},"exampleType":"examples"},"f4076c97-bbfc-470e-b4da-2e58a4ad111a":{"description":"400 Bad Request. The request body failed Zod .strict() validation. The error message\nnames the offending field (e.g. \"Unknown field: topK\"). Fix the request body.\n","headers":{"X-Request-Id":{"description":"Request UUID.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"type":"object","description":"Standard partner API error envelope (D-09). Mirrors Anthropic/OpenAI error shape.\nParse `error.code` for machine-readable error classification.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message","request_id"],"properties":{"code":{"type":"string","description":"Machine-readable error code (D-10 locked enum). Use this for branching logic.\nAdding new codes is a minor version bump per the versioning policy.\n","enum":["unauthorized","forbidden","rate_limited","invalid_request","corpus_unavailable","grounding_deferral","crisis_resources","not_found","internal_error"],"isRequired":true,"uniqueKey":"error.code","typeLabel":"enum\u003cstring>"},"message":{"type":"string","description":"Human-readable error description. Use for logging; do not parse programmatically.","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"request_id":{"type":"string","format":"uuid","description":"UUID for this request. Include when contacting support.","isRequired":true,"uniqueKey":"error.request_id","typeLabel":"string\u003cuuid>"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"example":{"error":{"code":"invalid_request","message":"Unknown field: topK. The /v1/chat endpoint does not accept retrieval tuning parameters.","request_id":"550e8400-e29b-41d4-a716-446655440000"}},"examples":{"Example":{"title":"Example","value":{"error":{"code":"invalid_request","message":"Unknown field: topK. The /v1/chat endpoint does not accept retrieval tuning parameters.","request_id":"550e8400-e29b-41d4-a716-446655440000"}}}},"exampleType":"examples"}},"exampleType":"examples"},"ca8e1800-0d2e-4ba4-91ff-bd2078687a3e":{"description":"401 Unauthorized. Missing, malformed, or invalid API key. Check that the Authorization\nheader is present and has the form `Bearer \u003ckey>`. An EXPIRED session token also\nreturns 401, with an \"API key expired\" message — session-token clients should treat\nthat specific message as \"request a fresh token from your backend\", not as an alert.\nSession tokens additionally return 401 whenever the session-token feature is disabled\n(the feature flag is a kill switch for outstanding keys).\n","headers":{"X-Request-Id":{"description":"Request UUID.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"type":"object","description":"Standard partner API error envelope (D-09). Mirrors Anthropic/OpenAI error shape.\nParse `error.code` for machine-readable error classification.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message","request_id"],"properties":{"code":{"type":"string","description":"Machine-readable error code (D-10 locked enum). Use this for branching logic.\nAdding new codes is a minor version bump per the versioning policy.\n","enum":["unauthorized","forbidden","rate_limited","invalid_request","corpus_unavailable","grounding_deferral","crisis_resources","not_found","internal_error"],"isRequired":true,"uniqueKey":"error.code","typeLabel":"enum\u003cstring>"},"message":{"type":"string","description":"Human-readable error description. Use for logging; do not parse programmatically.","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"request_id":{"type":"string","format":"uuid","description":"UUID for this request. Include when contacting support.","isRequired":true,"uniqueKey":"error.request_id","typeLabel":"string\u003cuuid>"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"example":{"error":{"code":"unauthorized","message":"Missing or malformed Authorization header. Expected: Bearer \u003ckey>","request_id":"550e8400-e29b-41d4-a716-446655440000"}},"examples":{"Example":{"title":"Example","value":{"error":{"code":"unauthorized","message":"Missing or malformed Authorization header. Expected: Bearer \u003ckey>","request_id":"550e8400-e29b-41d4-a716-446655440000"}}}},"exampleType":"examples"}},"exampleType":"examples"},"45d8408d-b697-49b6-825c-54f9514bb7af":{"description":"403 Forbidden. Key is valid but does not have permission for this operation. Four\ncases, distinguishable by `error.message`: (1) the key's scope excludes this\nendpoint — e.g. a session token calling anything other than /v1/query or /v1/chat,\nincluding /v1/session-tokens itself; (2) the key's total request allowance is\nexhausted (\"…allowance is exhausted. Mint a new session token.\" — permanent for\nthat key, do not retry; mint a new token); (3) \"This session token is not usable.\nMint a new one.\" — a SERVER-SIDE provisioning fault, not a client mistake: do NOT\nre-mint in a loop (each mint is a metered request and the replacement will fail the\nsame way) — surface the error and contact partners@collectivex.health; (4) an\naccount-level restriction — contact partners@collectivex.health.\n","headers":{"X-Request-Id":{"description":"Request UUID.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"type":"object","description":"Standard partner API error envelope (D-09). Mirrors Anthropic/OpenAI error shape.\nParse `error.code` for machine-readable error classification.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message","request_id"],"properties":{"code":{"type":"string","description":"Machine-readable error code (D-10 locked enum). Use this for branching logic.\nAdding new codes is a minor version bump per the versioning policy.\n","enum":["unauthorized","forbidden","rate_limited","invalid_request","corpus_unavailable","grounding_deferral","crisis_resources","not_found","internal_error"],"isRequired":true,"uniqueKey":"error.code","typeLabel":"enum\u003cstring>"},"message":{"type":"string","description":"Human-readable error description. Use for logging; do not parse programmatically.","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"request_id":{"type":"string","format":"uuid","description":"UUID for this request. Include when contacting support.","isRequired":true,"uniqueKey":"error.request_id","typeLabel":"string\u003cuuid>"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"example":{"error":{"code":"forbidden","message":"This key does not have permission to access /v1/chat.","request_id":"550e8400-e29b-41d4-a716-446655440000"}},"examples":{"Example":{"title":"Example","value":{"error":{"code":"forbidden","message":"This key does not have permission to access /v1/chat.","request_id":"550e8400-e29b-41d4-a716-446655440000"}}}},"exampleType":"examples"}},"exampleType":"examples"},"5de3fa24-3d90-4e12-9d60-f1c31079802e":{"description":"429 Too Many Requests. Rate limit exceeded. Read the Retry-After header (seconds)\nbefore retrying. Also check X-RateLimit-Remaining on successful responses to\nself-throttle before hitting 429. Limits are per-key configurable (a partner may\nhave a non-default requests-per-minute ceiling and/or a requests-per-day ceiling);\nX-RateLimit-* on this response always reflects whichever budget was exceeded.\n","headers":{"Retry-After":{"description":"Seconds until the rate-limit window resets. Wait this long before retrying.","required":true,"schema":{"type":"integer","example":37}},"X-Request-Id":{"description":"Request UUID.","schema":{"type":"string","format":"uuid"}},"X-RateLimit-Limit":{"description":"Maximum requests for the window that was exceeded (per-minute by default, or per-day if this key has a daily budget and that's what was hit).","schema":{"type":"integer","example":60}},"X-RateLimit-Remaining":{"description":"Requests remaining (0 when rate-limited).","schema":{"type":"integer","example":0}},"X-RateLimit-Reset":{"description":"Unix timestamp (seconds) when the window resets.","schema":{"type":"integer"}}},"content":{"application/json":{"schema":{"type":"object","description":"Standard partner API error envelope (D-09). Mirrors Anthropic/OpenAI error shape.\nParse `error.code` for machine-readable error classification.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message","request_id"],"properties":{"code":{"type":"string","description":"Machine-readable error code (D-10 locked enum). Use this for branching logic.\nAdding new codes is a minor version bump per the versioning policy.\n","enum":["unauthorized","forbidden","rate_limited","invalid_request","corpus_unavailable","grounding_deferral","crisis_resources","not_found","internal_error"],"isRequired":true,"uniqueKey":"error.code","typeLabel":"enum\u003cstring>"},"message":{"type":"string","description":"Human-readable error description. Use for logging; do not parse programmatically.","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"request_id":{"type":"string","format":"uuid","description":"UUID for this request. Include when contacting support.","isRequired":true,"uniqueKey":"error.request_id","typeLabel":"string\u003cuuid>"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"example":{"error":{"code":"rate_limited","message":"Rate limit exceeded. Retry after 37s.","request_id":"550e8400-e29b-41d4-a716-446655440000"}},"examples":{"Example":{"title":"Example","value":{"error":{"code":"rate_limited","message":"Rate limit exceeded. Retry after 37s.","request_id":"550e8400-e29b-41d4-a716-446655440000"}}}},"exampleType":"examples"}},"exampleType":"examples"},"e05a1332-ec73-42bb-83aa-cf3b8df04dea":{"description":"500 Internal Server Error. Unexpected server-side failure. Retry with exponential\nbackoff. If persistent, contact partners@collectivex.health with the request_id.\n","headers":{"X-Request-Id":{"description":"Request UUID.","schema":{"type":"string","format":"uuid"}}},"content":{"application/json":{"schema":{"type":"object","description":"Standard partner API error envelope (D-09). Mirrors Anthropic/OpenAI error shape.\nParse `error.code` for machine-readable error classification.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message","request_id"],"properties":{"code":{"type":"string","description":"Machine-readable error code (D-10 locked enum). Use this for branching logic.\nAdding new codes is a minor version bump per the versioning policy.\n","enum":["unauthorized","forbidden","rate_limited","invalid_request","corpus_unavailable","grounding_deferral","crisis_resources","not_found","internal_error"],"isRequired":true,"uniqueKey":"error.code","typeLabel":"enum\u003cstring>"},"message":{"type":"string","description":"Human-readable error description. Use for logging; do not parse programmatically.","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"request_id":{"type":"string","format":"uuid","description":"UUID for this request. Include when contacting support.","isRequired":true,"uniqueKey":"error.request_id","typeLabel":"string\u003cuuid>"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"example":{"error":{"code":"internal_error","message":"An unexpected error occurred. Please retry.","request_id":"550e8400-e29b-41d4-a716-446655440000"}},"examples":{"Example":{"title":"Example","value":{"error":{"code":"internal_error","message":"An unexpected error occurred. Please retry.","request_id":"550e8400-e29b-41d4-a716-446655440000"}}}},"exampleType":"examples"}},"exampleType":"examples"},"14af4a9e-d4bc-44e9-8d98-70cca3b48e11":{"description":"Sync mode (`stream: false`) only. The generation pipeline failed and no usable\ncontent was produced (empty answer, no deferral, no crisis). The body is still\nthe SyncResponse envelope: use `request_id` for support correlation and `error.message`\nfor display. Retry with backoff. When a PARTIAL answer (or a deferral/crisis\nshort-circuit) exists alongside a pipeline error, the endpoint returns 200 with\nthe optional `error` field populated instead.\n","content":{"application/json":{"schema":{"type":"object","description":"Flat JSON envelope returned when stream=false. Always contains request_id, answer,\nand citations. The deferral and crisis fields are mutually exclusive optional fields\npresent when the pipeline short-circuits before generating an answer.\n","required":["request_id","answer","citations"],"properties":{"request_id":{"type":"string","format":"uuid","description":"UUID minted per request. Use for support correlation across PostHog / Langfuse / logs.","isRequired":true,"uniqueKey":"request_id","typeLabel":"string\u003cuuid>"},"answer":{"type":"string","description":"The model's answer string. Empty string (\"\") on deferral or crisis short-circuit\n(the pipeline refuses to generate an answer without grounded evidence).\n","isRequired":true,"uniqueKey":"answer","typeLabel":"string"},"citations":{"type":"array","description":"Retrieved citations from the peer-reviewed corpus. Empty array on deferral or crisis.\nNever fabricate or paraphrase a citation that is not in this array.\n","items":{"type":"object","description":"A single research citation from the CollectiveX Health corpus.","required":["id","score","text"],"properties":{"id":{"type":"string","description":"Corpus-internal citation ID (e.g. \"CXH-00835\"). Use as an inline citation reference.","isRequired":true,"uniqueKey":"citations.items.[INDEX].id","typeLabel":"string"},"score":{"type":"number","format":"float","minimum":0,"maximum":1,"description":"Retrieval relevance score. Higher is more relevant.","isRequired":true,"uniqueKey":"citations.items.[INDEX].score","typeLabel":"number\u003cfloat>"},"text":{"type":"string","description":"Excerpt from the source paper used to ground the answer.","isRequired":true,"uniqueKey":"citations.items.[INDEX].text","typeLabel":"string"},"metadata":{"type":"object","description":"Bibliographic metadata. Strict allowlist — fields not listed here are\nstripped at the `/v1/*` boundary so partners never see Agentset-internal\nfield names. Source of truth: `lib/api/v1/citation-sanitizer.ts`\n(`PARTNER_METADATA_ALLOWLIST`).\n","additionalProperties":false,"properties":{"cxh_id":{"type":"string","description":"Canonical paper identifier in the CollectiveX Health corpus.","example":"CXH-00835","uniqueKey":"citations.items.[INDEX].metadata.cxh_id","typeLabel":"string"},"doi":{"type":"string","description":"Peer-reviewed DOI of the source paper.","example":"10.1093/humrep/dead156","uniqueKey":"citations.items.[INDEX].metadata.doi","typeLabel":"string"},"year":{"type":"string","description":"Publication year as it appears in the corpus catalog. Emitted as a\nstring at runtime (#191) — partners that want a number should\n`parseInt(year, 10)` on the partner side. The corpus also includes\nnon-numeric values like `\"in press\"` for unpublished work.\n","example":"2023","uniqueKey":"citations.items.[INDEX].metadata.year","typeLabel":"string"},"journal":{"type":"string","description":"Peer-review journal name.","example":"Human Reproduction","uniqueKey":"citations.items.[INDEX].metadata.journal","typeLabel":"string"},"authors":{"oneOf":[{"type":"string","description":"Author list — either a single joined string or an array of\nauthor strings; both forms occur in corpus metadata.\n","example":"Shultz et al.","uniqueKey":"citations.items.[INDEX].metadata.authors.oneOf.0","typeLabel":"string"},{"type":"array","items":{"type":"string","uniqueKey":"citations.items.[INDEX].metadata.authors.oneOf.1.items.[INDEX]","typeLabel":"string"},"description":"Author list — either a single joined string or an array of\nauthor strings; both forms occur in corpus metadata.\n","example":"Shultz et al.","uniqueKey":"citations.items.[INDEX].metadata.authors.oneOf.1","typeLabel":"string[]"}],"uniqueKey":"citations.items.[INDEX].metadata.authors","typeLabel":"string | string[]"},"title":{"type":"string","description":"Paper title.","example":"Sex hormone profiles in normal menstruating females","uniqueKey":"citations.items.[INDEX].metadata.title","typeLabel":"string"},"page_number":{"type":"integer","description":"Page within the source paper this excerpt came from.","example":4,"uniqueKey":"citations.items.[INDEX].metadata.page_number","typeLabel":"integer"}},"uniqueKey":"citations.items.[INDEX].metadata","typeLabel":"object"}},"uniqueKey":"citations.items.[INDEX]","typeLabel":"object"},"isRequired":true,"uniqueKey":"citations","typeLabel":"object[]"},"deferral":{"oneOf":[{"type":"null","description":"Present when the corpus lacks strong evidence for the query. Present the originalQuery\nback to the user and do not synthesize an answer from training data.\n","uniqueKey":"deferral.oneOf.0","typeLabel":"null"},{"type":"object","description":"Present when the corpus lacks strong evidence for the query. Present the originalQuery\nback to the user and do not synthesize an answer from training data.\n","required":["originalQuery"],"properties":{"originalQuery":{"type":"string","description":"The query that triggered the deferral.","isRequired":true,"uniqueKey":"deferral.oneOf.1.originalQuery","typeLabel":"string"}},"uniqueKey":"deferral.oneOf.1","typeLabel":"object"}],"uniqueKey":"deferral","typeLabel":"null | object"},"crisis":{"oneOf":[{"type":"null","description":"Present when a safety classifier fires before retrieval (self-harm, acute symptoms,\nIPV). Show the resources verbatim and route the user away from research framing.\n","uniqueKey":"crisis.oneOf.0","typeLabel":"null"},{"type":"object","description":"Present when a safety classifier fires before retrieval (self-harm, acute symptoms,\nIPV). Show the resources verbatim and route the user away from research framing.\n","required":["category","locale","originalQuery","resources"],"properties":{"category":{"type":"string","enum":["self-harm","acute-symptom","ipv"],"description":"Safety category that triggered the classifier.","isRequired":true,"uniqueKey":"crisis.oneOf.1.category","typeLabel":"enum\u003cstring>"},"locale":{"type":"string","description":"Detected locale (e.g. \"US\", \"GB\"). Used to select region-appropriate resources.","example":"US","isRequired":true,"uniqueKey":"crisis.oneOf.1.locale","typeLabel":"string"},"originalQuery":{"type":"string","description":"The query that triggered the crisis classifier.","isRequired":true,"uniqueKey":"crisis.oneOf.1.originalQuery","typeLabel":"string"},"resources":{"type":"array","description":"Crisis resources to show verbatim. Never omit or reorder.","items":{"type":"object","description":"A single crisis support resource. Render verbatim — do not reorder, summarise, or\nomit fields. Source of truth: `lib/safety/crisis-resources.ts`.\n","required":["region","name","description"],"properties":{"region":{"type":"string","enum":["US","UK","global"],"description":"Region this resource applies to.","example":"US","isRequired":true,"uniqueKey":"crisis.oneOf.1.resources.items.[INDEX].region","typeLabel":"enum\u003cstring>"},"name":{"type":"string","description":"Human-readable resource name.","example":"988 Suicide \u0026 Crisis Lifeline","isRequired":true,"uniqueKey":"crisis.oneOf.1.resources.items.[INDEX].name","typeLabel":"string"},"description":{"type":"string","description":"Short context line shown next to the resource.","example":"24/7 free, confidential support for people in distress.","isRequired":true,"uniqueKey":"crisis.oneOf.1.resources.items.[INDEX].description","typeLabel":"string"},"phone":{"type":"string","description":"Phone or SMS contact (optional). Format varies by region.","example":"988","uniqueKey":"crisis.oneOf.1.resources.items.[INDEX].phone","typeLabel":"string"},"hours":{"type":"string","description":"Operating hours, when not 24/7 (optional).","example":"Mon–Fri 9am–5pm ET","uniqueKey":"crisis.oneOf.1.resources.items.[INDEX].hours","typeLabel":"string"}},"uniqueKey":"crisis.oneOf.1.resources.items.[INDEX]","typeLabel":"object"},"isRequired":true,"uniqueKey":"crisis.oneOf.1.resources","typeLabel":"object[]"}},"uniqueKey":"crisis.oneOf.1","typeLabel":"object"}],"uniqueKey":"crisis","typeLabel":"null | object"},"error":{"description":"Present when the generation pipeline emitted an error (v1.1, optional). The message\nis always a generic sanitized string — internal error details are never exposed.\nWith no usable content the response status is 502; alongside a partial answer or a\ndeferral/crisis short-circuit the status stays 200 and this field flags the failure.\n","type":"object","required":["message"],"properties":{"message":{"type":"string","description":"Generic human-readable failure message. Safe to display; do not parse.","example":"Generation failed. Please retry.","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"}},"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"generation_failed_sync":{"title":"generation_failed_sync","value":{"request_id":"d4e5f6a7-b8c9-0123-def1-234567890123","answer":"","citations":[],"error":{"message":"Generation failed. Please retry."}}}},"exampleType":"examples"}},"exampleType":"examples"},"13a49fed-e214-43e9-983d-e14676b16de1":{"description":"503 Service Unavailable. A transient condition — retry with exponential\nbackoff. Two distinct causes share this status code, distinguishable by\n`error.code`:\n - `corpus_unavailable`: the research corpus (Agentset) is temporarily\n unavailable.\n - `internal_error`: an upstream dependency required to authenticate or\n rate-limit the request (Unkey) is temporarily unavailable — includes\n the \"rate-limit service degraded\" case described under \"Rate limits\"\n above. This variant always carries a `Retry-After` header.\n","headers":{"X-Request-Id":{"description":"Request UUID.","schema":{"type":"string","format":"uuid"}},"Retry-After":{"description":"Seconds to wait before retrying. Present on the `internal_error` (Unkey-outage) variant; absent on `corpus_unavailable`.","required":false,"schema":{"type":"integer","example":5}}},"content":{"application/json":{"schema":{"type":"object","description":"Standard partner API error envelope (D-09). Mirrors Anthropic/OpenAI error shape.\nParse `error.code` for machine-readable error classification.\n","required":["error"],"properties":{"error":{"type":"object","required":["code","message","request_id"],"properties":{"code":{"type":"string","description":"Machine-readable error code (D-10 locked enum). Use this for branching logic.\nAdding new codes is a minor version bump per the versioning policy.\n","enum":["unauthorized","forbidden","rate_limited","invalid_request","corpus_unavailable","grounding_deferral","crisis_resources","not_found","internal_error"],"isRequired":true,"uniqueKey":"error.code","typeLabel":"enum\u003cstring>"},"message":{"type":"string","description":"Human-readable error description. Use for logging; do not parse programmatically.","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"request_id":{"type":"string","format":"uuid","description":"UUID for this request. Include when contacting support.","isRequired":true,"uniqueKey":"error.request_id","typeLabel":"string\u003cuuid>"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"corpus_unavailable":{"title":"corpus_unavailable","value":{"error":{"code":"corpus_unavailable","message":"Research corpus temporarily unavailable. Please retry.","request_id":"550e8400-e29b-41d4-a716-446655440000"}}},"auth_or_ratelimit_service_unavailable":{"title":"auth_or_ratelimit_service_unavailable","value":{"error":{"code":"internal_error","message":"Rate limit service temporarily unavailable. Please retry.","request_id":"660e8400-e29b-41d4-a716-446655440001"}}}},"exampleType":"examples"}},"exampleType":"examples"}},"security":{"6acead53-d14e-478b-946d-f9b96320b416":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"cxh_pk_live_*","description":"Bearer token used by every `/v1/*` endpoint. Two kinds of key work here:\n - **Long-lived partner key** (`cxh_pk_live_*`) — issued by\n CollectiveX Health (contact partners@collectivex.health). Keep\n it server-side only — never expose it in client bundles or\n mobile app code. This rule is absolute and does not change for\n any endpoint.\n - **Short-lived session key** — minted server-side via\n `POST /v1/session-tokens` from a long-lived key. Safe to hand\n to a native mobile client only — not a browser or other\n JavaScript context, see \"API keys\" in the description above.\n It's scoped to `/v1/query` and `/v1/chat` only, expires in at\n most 60 minutes, and can't mint further session keys.\n `POST /v1/session-tokens` itself only ever accepts the\n long-lived key.\n","scopes":[]}}},"servers":{"3aec66e8-ea38-412b-92a2-04eeb1a50e2f":{"url":"https://api.collectivex.health","description":"Production partner API"}},"processedSecurityOptions":[{"schemes":[{"scheme":{"type":"http","scheme":"bearer","bearerFormat":"cxh_pk_live_*","description":"Bearer token used by every `/v1/*` endpoint. Two kinds of key work here:\n - **Long-lived partner key** (`cxh_pk_live_*`) — issued by\n CollectiveX Health (contact partners@collectivex.health). Keep\n it server-side only — never expose it in client bundles or\n mobile app code. This rule is absolute and does not change for\n any endpoint.\n - **Short-lived session key** — minted server-side via\n `POST /v1/session-tokens` from a long-lived key. Safe to hand\n to a native mobile client only — not a browser or other\n JavaScript context, see \"API keys\" in the description above.\n It's scoped to `/v1/query` and `/v1/chat` only, expires in at\n most 60 minutes, and can't mint further session keys.\n `POST /v1/session-tokens` itself only ever accepts the\n long-lived key.\n","scopes":[]},"schema":{"title":"Bearer Auth","type":"string","isRequired":true,"description":"Bearer token used by every `/v1/*` endpoint. Two kinds of key work here:\n - **Long-lived partner key** (`cxh_pk_live_*`) — issued by\n CollectiveX Health (contact partners@collectivex.health). Keep\n it server-side only — never expose it in client bundles or\n mobile app code. This rule is absolute and does not change for\n any endpoint.\n - **Short-lived session key** — minted server-side via\n `POST /v1/session-tokens` from a long-lived key. Safe to hand\n to a native mobile client only — not a browser or other\n JavaScript context, see \"API keys\" in the description above.\n It's scoped to `/v1/query` and `/v1/chat` only, expires in at\n most 60 minutes, and can't mint further session keys.\n `POST /v1/session-tokens` itself only ever accepts the\n long-lived key.\n","format":"bearer","typeLabel":"string\u003cbearer>","deprecated":false},"schemeName":"bearerAuth","name":"Authorization"}],"title":"bearerAuth"}]},"originalFileLocation":"openapi.yaml"},"subdomain":"collective-x","siteName":"Collective X API","title":"Have a conversation — streaming or sync - Collective X API","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-09-13T05:30:51.771Z","originalFileLocation":"api-reference/have-a-conversation/have-a-conversation-—-streaming-or-sync.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Dual-mode endpoint. By default (stream omitted or true) returns a streaming UIMessage SSE response compatible with the Vercel AI SDK useChat hook. Send stream: false to receive a synchronous JSON response (the SyncResponse shape) suited for Claude Skills, MCP tool calls, and agent pipelines. Server-to-server (the only supported pattern for web), or native-mobile-direct via a short-lived session token minted by your backend through POST /v1/session-tokens (native mobile only, not browser/JS — see \u0026quot;API keys\u0026quot; above). Never embed your long-lived key in any client, browser or mobile. Rate limits are communicated via X-RateLimit-* headers on every response and are shared with /v1/query per API key (see \u0026quot;Rate limits\u0026quot; above). When a 429 is returned, honour Retry-After before retrying.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Collective X API\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/collective-x/0_4ikjEQ7vib8PG9/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/collective-x/0_4ikjEQ7vib8PG9/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/collective-x/0_4ikjEQ7vib8PG9/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/collective-x/0_4ikjEQ7vib8PG9/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/collective-x/0_4ikjEQ7vib8PG9/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/collective-x/0_4ikjEQ7vib8PG9/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/collective-x/0_4ikjEQ7vib8PG9/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/collective-x/0_4ikjEQ7vib8PG9/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/collective-x/0_4ikjEQ7vib8PG9/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Have a conversation — streaming or sync - Collective X API\">\u003cmeta data-mint-head property=\"og:description\" content=\"Dual-mode endpoint. By default (stream omitted or true) returns a streaming UIMessage SSE response compatible with the Vercel AI SDK useChat hook. Send stream: false to receive a synchronous JSON response (the SyncResponse shape) suited for Claude Skills, MCP tool calls, and agent pipelines. Server-to-server (the only supported pattern for web), or native-mobile-direct via a short-lived session token minted by your backend through POST /v1/session-tokens (native mobile only, not browser/JS — see \u0026quot;API keys\u0026quot; above). Never embed your long-lived key in any client, browser or mobile. Rate limits are communicated via X-RateLimit-* headers on every response and are shared with /v1/query per API key (see \u0026quot;Rate limits\u0026quot; above). When a 429 is returned, honour Retry-After before retrying.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Collective X API\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.collectivex.health/api-reference/have-a-conversation/have-a-conversation-—-streaming-or-sync\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://collective-x.mintlify.app/_mintlify/api/og/v2?division=Have+a+conversation\u0026amp;title=Have+a+conversation+%E2%80%94+streaming+or+sync\u0026amp;description=Dual-mode+endpoint.+By+default+%28%60stream%60+omitted+or+%60true%60%29+returns+a+streaming%0AUIMessage+SSE+response+compatible+with+the+Vercel+AI+SDK+%60useChat%60+hook.+Send%0A%60s\u0026amp;theme=bb4e877d2136d284fc6ff9a0\u0026amp;signature=760fcd9383a1322aca5ed0fffd3de38ddc12ba260782b5a8aa960f1d2a4b6c1e\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Have a conversation — streaming or sync - Collective X API\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Dual-mode endpoint. By default (stream omitted or true) returns a streaming UIMessage SSE response compatible with the Vercel AI SDK useChat hook. Send stream: false to receive a synchronous JSON response (the SyncResponse shape) suited for Claude Skills, MCP tool calls, and agent pipelines. Server-to-server (the only supported pattern for web), or native-mobile-direct via a short-lived session token minted by your backend through POST /v1/session-tokens (native mobile only, not browser/JS — see \u0026quot;API keys\u0026quot; above). Never embed your long-lived key in any client, browser or mobile. Rate limits are communicated via X-RateLimit-* headers on every response and are shared with /v1/query per API key (see \u0026quot;Rate limits\u0026quot; above). When a 429 is returned, honour Retry-After before retrying.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://collective-x.mintlify.app/_mintlify/api/og/v2?division=Have+a+conversation\u0026amp;title=Have+a+conversation+%E2%80%94+streaming+or+sync\u0026amp;description=Dual-mode+endpoint.+By+default+%28%60stream%60+omitted+or+%60true%60%29+returns+a+streaming%0AUIMessage+SSE+response+compatible+with+the+Vercel+AI+SDK+%60useChat%60+hook.+Send%0A%60s\u0026amp;theme=bb4e877d2136d284fc6ff9a0\u0026amp;signature=760fcd9383a1322aca5ed0fffd3de38ddc12ba260782b5a8aa960f1d2a4b6c1e\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/collective-x/0_4ikjEQ7vib8PG9/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Collective X API\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#1a3f52\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.collectivex.health/api-reference/have-a-conversation/have-a-conversation-—-streaming-or-sync\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/api-reference/have-a-conversation/have-a-conversation-%E2%80%94-streaming-or-sync.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.collectivex.health/#organization\",\"name\":\"Collective X API\",\"url\":\"https://docs.collectivex.health\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/collective-x/XmdndrtGclqPo6DR/logo/light.svg?fit=max\u0026auto=format\u0026n=XmdndrtGclqPo6DR\u0026q=85\u0026s=a7e95b40e54fc2a5bb8a468486937833\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.collectivex.health#website\",\"name\":\"Collective X API\",\"url\":\"https://docs.collectivex.health\",\"publisher\":{\"@id\":\"https://docs.collectivex.health/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.collectivex.health/api-reference/have-a-conversation/have-a-conversation-%E2%80%94-streaming-or-sync#webpage\",\"url\":\"https://docs.collectivex.health/api-reference/have-a-conversation/have-a-conversation-%E2%80%94-streaming-or-sync\",\"name\":\"Have a conversation — streaming or sync\",\"description\":\"Dual-mode endpoint. By default (stream omitted or true) returns a streaming UIMessage SSE response compatible with the Vercel AI SDK useChat hook. Send stream: false to receive a synchronous JSON response (the SyncResponse shape) suited for Claude Skills, MCP tool calls, and agent pipelines. Server-to-server (the only supported pattern for web), or native-mobile-direct via a short-lived session token minted by your backend through POST /v1/session-tokens (native mobile only, not browser/JS — see \\\"API keys\\\" above). Never embed your long-lived key in any client, browser or mobile. Rate limits are communicated via X-RateLimit-* headers on every response and are shared with /v1/query per API key (see \\\"Rate limits\\\" above). When a 429 is returned, honour Retry-After before retrying.\",\"dateModified\":\"2026-09-13T05:30:51.771Z\",\"isPartOf\":{\"@id\":\"https://docs.collectivex.health#website\"},\"breadcrumb\":{\"@id\":\"https://docs.collectivex.health/api-reference/have-a-conversation/have-a-conversation-%E2%80%94-streaming-or-sync#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.collectivex.health/api-reference/have-a-conversation/have-a-conversation-%E2%80%94-streaming-or-sync#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Collective X API\",\"item\":\"https://docs.collectivex.health\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Have a conversation — streaming or sync\",\"item\":\"https://docs.collectivex.health/api-reference/have-a-conversation/have-a-conversation-%E2%80%94-streaming-or-sync\"}]},{\"@type\":[\"TechArticle\",\"APIReference\"],\"@id\":\"https://docs.collectivex.health/api-reference/have-a-conversation/have-a-conversation-%E2%80%94-streaming-or-sync#apireference\",\"headline\":\"Have a conversation — streaming or sync\",\"name\":\"Have a conversation — streaming or sync\",\"description\":\"Dual-mode endpoint. By default (stream omitted or true) returns a streaming UIMessage SSE response compatible with the Vercel AI SDK useChat hook. Send stream: false to receive a synchronous JSON response (the SyncResponse shape) suited for Claude Skills, MCP tool calls, and agent pipelines. Server-to-server (the only supported pattern for web), or native-mobile-direct via a short-lived session token minted by your backend through POST /v1/session-tokens (native mobile only, not browser/JS — see \\\"API keys\\\" above). Never embed your long-lived key in any client, browser or mobile. Rate limits are communicated via X-RateLimit-* headers on every response and are shared with /v1/query per API key (see \\\"Rate limits\\\" above). When a 429 is returned, honour Retry-After before retrying.\",\"url\":\"https://docs.collectivex.health/api-reference/have-a-conversation/have-a-conversation-%E2%80%94-streaming-or-sync\",\"mainEntityOfPage\":{\"@id\":\"https://docs.collectivex.health/api-reference/have-a-conversation/have-a-conversation-%E2%80%94-streaming-or-sync#webpage\"},\"dateModified\":\"2026-09-13T05:30:51.771Z\",\"publisher\":{\"@id\":\"https://docs.collectivex.health/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.collectivex.health#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Collective X API\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"Collective X API","nav":{"global":null,"tabs":[{"tab":"API Reference","groups":[{"group":"Ask a question","pages":[{"title":"Ask a question — one-shot JSON answer","description":"One-shot, synchronous endpoint. Always returns `application/json` (the\n`SyncResponse` shape) — there is no streaming mode and no `stream` field.\nThis is the recommended path for Claude Skills, MCP tool calls, agent\npipelines, and any caller that wants the full answer before processing —\nthe same contract as `stream: false` on `POST /v1/chat`, promoted to its\nown named path with a question-shaped request body. Both endpoints remain\nfully supported; there is no deprecation or migration deadline for\n`stream: false` on `/v1/chat`.\n\n**Server-to-server (the only supported pattern for web), or\nnative-mobile-direct via a short-lived session token** minted by\nyour backend through `POST /v1/session-tokens` (native mobile only,\nnot browser/JS — see \"API keys\" above). Never embed your long-lived key in any client,\nbrowser or mobile.\n\nInternally this is the exact same pipeline as `/v1/chat` — same\nretrieval, safety, and grounding behavior. Nothing about answer quality\nchanges based on which endpoint you call.\n\nRate limits are communicated via `X-RateLimit-*` headers on every\nresponse and are shared with `/v1/chat` per API key\n(same rate-limit namespace, same key — see \"Rate limits\" above).\nWhen a 429 is returned, honour `Retry-After` before retrying.\n","deprecated":null,"version":null,"openapi":"/openapi.yaml post /v1/query","href":"/api-reference/ask-a-question/ask-a-question-—-one-shot-json-answer"}]},{"group":"Have a conversation","pages":[{"title":"Have a conversation — streaming or sync","deprecated":null,"version":null,"openapi":"/openapi.yaml post /v1/chat","href":"/api-reference/have-a-conversation/have-a-conversation-—-streaming-or-sync"}]},{"group":"Async jobs","pages":[{"title":"Submit a question as an async job (asynchronous /v1/query)","description":"Submit exactly the request body you would send to `POST /v1/query`\nand get a job id back immediately, instead of waiting for the\ngrounded answer on an open connection. The answer is produced in\nthe background and read with `GET /v1/jobs/{id}` — see the \"Async\njobs\" tag description for the lifecycle, retention, and a polling\nrecipe.\n\n**Validation is identical to `/v1/query`, and happens now.** The\nbody must contain exactly one of `question` or `messages` (one\nuser message), may set `response_format`, and may not contain\nanything else. Every `400` this endpoint returns — unknown field,\nboth/neither shape, empty or whitespace-only question, a message\nwith a `file` part, a non-`user` role — is one `/v1/query` would\nhave returned for the same body. Nothing is accepted here only to\nfail an hour of polling later. One extra rule applies only here:\nthe body is persisted and echoed back on every poll, so it is\ncapped at 32 KiB of JSON.\n\n**What runs, and when.** On `202` the job is `queued` and starts\nrunning immediately, in the background. It is the same\nretrieval + safety + generation pipeline `/v1/query` uses, with the\nsame published tone and the same deferral/crisis behaviour — so\nthe eventual `result` is exactly the `QueryResponse` you would have\nreceived synchronously. Expect the job to finish in the same\n10–40 s a synchronous call takes; a job is never faster than the\nsync call, it just doesn't make you wait on the socket.\n\n**Metering.** Submitting is one metered request against your\nper-key budget (the same pool as `/v1/query`, `/v1/chat`, and\npolling). The background execution is not metered again.\n\n**Server-to-server only, with your long-lived key.** A session\ntoken gets `403 forbidden` here, exactly as on `GET /v1/jobs/{id}`.\nNever embed your long-lived key in a client.\n","deprecated":null,"version":null,"openapi":"/openapi.yaml post /v1/jobs","href":"/api-reference/async-jobs/submit-a-question-as-an-async-job-asynchronous-v1query"},{"title":"Poll an async job's status","deprecated":null,"version":null,"openapi":"/openapi.yaml get /v1/jobs/{id}","href":"/api-reference/async-jobs/poll-an-async-jobs-status"}]},{"group":"Session tokens","pages":[{"title":"Mint a short-lived, scoped session token for a mobile client","deprecated":null,"version":null,"openapi":"/openapi.yaml post /v1/session-tokens","href":"/api-reference/session-tokens/mint-a-short-lived-scoped-session-token-for-a-mobile-client"}]}]},{"tab":"Guides","pages":[{"title":"Guides","href":""}]}]},"title":"Have a conversation — streaming or sync - Collective X API","buildId":"dpl_2xiSHD9XEvLsPGPcfoMtkLTB3dy9","deploymentId":"dpl_2xiSHD9XEvLsPGPcfoMtkLTB3dy9","dynamics":["c2aa737661","2b790eda92","b0f84f53ff","a9bb46feb3"],"chunks":["OpenApiReferenceProvider-DmVyH30O.js","utils-BHQqGGOd.js","cloneDeep-izs3Hzxb.js","_Uint8Array-BVIqJ90l.js","isObjectLike-C8vmzPEN.js","isArray-Dcu1dQ5t.js","utils-CD-E4BIt.js","toString-BX-iyh8G.js","isSymbol-CSH9U2Gm.js","addUniqueKeysToSchema-Bp5Lq9Ds.js","snippetPresets-C4xAVCFP.js","style-to-object-BY3JEAdk.js","v4-DIgz8zy6.js","ApiExamples-CgXVLxUC.js","isEqual-BfaiBbcl.js","usePlaygroundInputsStore-BF8I5oUf.js","shallow-Byd0lWnC.js","getApiPlaygroundDisplay-BGOZG1OK.js","CodeSnippet-CpvQL0CY.js","CodeSnippets-B8wkBKXa.js","Page-CBCH2P7b.js","getPastedJson-Ry3scI3Y.js","icon-D7a9HcdD.js","MethodPill-CJ8pmHhz.js","DuplicateIcon-rh1HJF0t.js","createIcon-DvGznqYs.js","DynamicMarkdown-Cc6AuSHS.js","SectionHeading-B4A0S-ep.js","axios-vUo_bRtp.js","Markdown-Cc16CX65.js","clsx-Cs6nMGht.js","lib-DuNMoZ05.js","lib-B8HbPgcC.js","html-void-elements-mCSPHezU.js","dist-zbf22OZA.js","katex-YMM-FMeD.js","marked.esm-CZWythHk.js","AssistantPageLink-C_fs-y5n.js"]}