import os
from qaip import Qaip
client = Qaip(
api_key=os.environ.get("QAIP_API_KEY"), # This is the default and can be omitted
)
response = client.completion(
messages=[{
"content": "content",
"role": "system",
}],
)
print(response.assistant_message_id)
Generates a completion based on the input messages and retrieval chunks. If the ‘stream’ parameter is set to true, the response is streamed. By default the stream is plain text (text/plain). Send the request header ‘Accept: text/event-stream’ to instead receive a Server-Sent Events (SSE) stream of ag-ui protocol events (delta text as TEXT_MESSAGE_CONTENT, grounding, citations and (opt-in) retrieved chunks as CUSTOM events, history ids and completion as RUN_STARTED / RUN_FINISHED).
Required scope: inference:run
POST
/
completions
Python
import os
from qaip import Qaip
client = Qaip(
api_key=os.environ.get("QAIP_API_KEY"), # This is the default and can be omitted
)
response = client.completion(
messages=[{
"content": "content",
"role": "system",
}],
)
print(response.assistant_message_id)
Whether to stream the response. If true, the response is streamed as 'text/plain' by default, or as an ag-ui Server-Sent Events stream ('text/event-stream') when the request sends the header 'Accept: text/event-stream'.
citation
boolean
default:true
Whether to include citations in the response
include_retrieved
boolean
default:false
Whether to return, separately from citations, every knowledge-base chunk
that was retrieved for this request and passed to the model as context
(after authorization filtering), whether or not the answer cited it.
When true, the JSON response carries them in the top-level retrieved
array, the SSE stream emits one or more CUSTOM events named retrieved
before RUN_FINISHED (split by encoded size; concatenate their values in
order to get the full list), and the persisted assistant message keeps them in
assistant_metadata.retrieved (see GET /conversations). The text/plain
stream cannot carry them in the body, so it only persists them. Intended for
callers that audit what the end-user was shown; off by default so the
response size and stored history of existing clients do not change.
include_redacted_input
boolean
default:false
Whether to return how the latest user message was redacted (see
RedactedInput), e.g. to show the end-user their question in redacted form.
The messages are redacted first, and both the retrieval query and the LLM
prompt are built from the redacted text. Only effective with
redaction_policy_id. The JSON response carries it in the top-level
redacted_input; the SSE stream emits one CUSTOM event named
redaction_applied as soon as the messages are redacted, before the search and
the answer text. The text/plain stream cannot carry it, and it is not stored in
the conversation history.
grounding
boolean
default:false
Whether to enable Gemini's Google Search grounding during answer
generation. Only effective when the completion model is a Gemini
model and the gemini_grounding feature is enabled on the server;
otherwise this flag is ignored.
redaction_policy_id
string | null
ID of a versioned redaction policy (built-in, or a tenant policy name) to
apply before anything leaves QAIP for an external provider: the retrieval
query sent to the embedding API, the retrieved knowledge-base chunks
(title / URL / text) and the conversation messages sent to the LLM.
The redaction boundaries are completions_query, completions_docs,
completions_messages, completions_messages_system (the system role
messages), completions_messages_assistant (the assistant role
messages) and completions_search_query_context (search_query.context);
a policy can exclude some of them via skippedBoundaries.
The messages are redacted first and the retrieval query is built from the
redacted user messages, so completions_query only applies when the policy
excludes a boundary the query is built from: completions_messages, or with
search_query.mode: rewrite also completions_messages_assistant and
completions_search_query_context (the rewrite may copy words from earlier
answers or from search_query.context). With search_query.mode: rewrite,
the LLM call that rewrites the query receives the same messages as the
answer, so it follows completions_messages as well, and
search_query.context follows completions_search_query_context.
When omitted or null (the default), no redaction is performed and the
input is sent to the external provider as-is. This is an explicit API
contract, not a fail-open behavior. Unknown IDs return
422 UNKNOWN_REDACTION_POLICY; an unavailable redactor returns
503 REDACTION_UNAVAILABLE and a redaction failure during generation
returns 503 REDACTION_FAILED (or RUN_ERROR with that code on the SSE
stream). The request is never forwarded unmasked.
Redacted chunks are also what citations and retrieved return, so
citation links can break when the URL itself contains masked values.
grounding: true may be combined with a policy: Gemini derives its search
queries from the redacted messages, but QAIP cannot intercept the built-in
grounding search itself, so the guarantee is weaker than the Agent run's
explicit google_query / google_result boundaries.
Minimum string length: 1
Pattern: ^[A-Za-z0-9._-]+$
tags
string[]
target tag names to be obtained
tag_ids
string[]
target tag IDs to be obtained
tag_filter_logic
enum<string>
default:OR
Logical operator for combining filter conditions
Available options:
AND,
OR
source_types
enum<string>[]
The type of the source
Available options:
crawl,
local_file,
google_drive,
github,
notion
file_types
enum<string>[]
The type of the source file
Available options:
html,
pdf,
ppt,
pptx,
pptm,
doc,
docx,
docm,
xls,
xlsx,
xlsm,
md,
txt,
jsonl,
png,
jpg,
webp,
heic,
heif,
wav,
mp3,
aiff,
aac,
m4a,
ogg,
flac,
mp4,
mpg,
mov,
avi,
flv,
webm,
wmv,
3gp,
notion_page
date_from
integer
Start date for content search (Unix timestamp in seconds)
Required range: x >= 1735639200
date_to
integer
End date for content search (Unix timestamp in seconds)
Required range: x >= 1735639200
domains
string[]
Array of domains to search within (supports partial matching)
metadata
object
(reserved for future use) Filter group with nested structure. Supports combining filters with AND/OR logic.
Show child attributes
source_metadata
object
Filter by individual source/file metadata from source_metadatas table
Show child attributes
chunk_metadata
object
Filter by chunk-level metadata from chunk_metadatas table
Show child attributes
metadata_filter
object
Filter by declared metadata columns (see /metadata_columns) pushed down directly to LanceDB (no PostgreSQL round-trip). Targets string/integer/string_list /integer_list typed columns. Keys must be declared via /metadata_columns or the request is rejected (400).
Show child attributes
use_postfilter
boolean
default:false
Whether to bypass LanceDB prefilter and apply WHERE after the
vector search (IVF_PQ) returns top-K. Significantly faster for
broad filters that cover most of the table, but may return
fewer than limit results when the hit rate is low.
limit
integer
default:10
Maximum number of chunks to retrieve as context for completion
Required range: 1 <= x <= 100
authz_policy
string
(reserved for future use) Name of the registered authz policy to
evaluate when retrieving context. Defaults to the reserved "default"
policy when omitted. Ignored when authz is disabled.
Pattern: ^[a-z][a-z0-9_-]{0,63}$
Example:
"external-chatbot"
principal_id
string
Identifier of the end-user (principal) on whose behalf this request is made. Used to look up the principal's authz subject attributes for policy evaluation. When omitted, subject attributes are empty (most restrictive). Ignored when authz is disabled.
Maximum string length: 256
Example:
"user-123"
conversation_id
string
Conversation to append this turn to. When omitted, a new conversation is
created server-side and its id is returned (response body for JSON, the
X-Conversation-Id header for streaming). Pass it back on subsequent turns
so the answer is persisted into the same conversation history tree.
When set, the past conversation is rebuilt server-side from the stored tree,
so only the latest user message in messages is used as the new input
(earlier messages entries are ignored). When search_query is omitted,
retrieval uses that latest question; set search_query to change it.
Example:
"550e8400-e29b-41d4-a716-446655440000"
parent_message_id
string
Id of the message node to branch this turn from (the parent of the new
user message). When omitted, the turn continues from the conversation's
current active leaf. Set it to fork a branch (e.g. editing an earlier
question). Must belong to conversation_id.
Example:
"f47ac10b-58cc-4372-a567-0e02b2c3d479"
regenerate
boolean
default:false
When true, the latest user message is NOT persisted again; instead a new
assistant answer is created as a sibling under parent_message_id (which must
reference an existing user message). Used to regenerate an answer.
truncation
enum<string>
default:auto
How to handle a reconstructed conversation that exceeds the model's context
budget (only relevant when conversation_id is set, i.e. history is rebuilt
server-side). "auto": drop the oldest turns until it fits (the latest question
is always kept). "disabled": return 400 if it does not fit.
Available options:
auto,
disabled
search_query
object
How to build the retrieval query. When omitted, a new conversation uses concat over
every user message, and a continuation (conversation_id set) uses only the latest
user message. When set, it applies the same way to both. The target turns are taken
from the conversation passed to the answer model (after redaction and truncation).
If the rewrite LLM call fails, the request fails and does not fall back to concat:
500 without stream, and RUN_ERROR on the SSE stream. A text/plain stream has
already returned 200, so like other generation failures it ends without any body.
Show child attributes
Response
Successful completion. If the 'stream' parameter is false, the response is returned as application/json. If the 'stream' parameter is true, the response is returned as a stream of plain text (text/plain) by default, or as an ag-ui Server-Sent Events stream (text/event-stream) when the request sends 'Accept: text/event-stream'.
created
integer
required
The Unix timestamp (in seconds) of when the completion was created
Example:
1677649420
choices
object[]
required
The completion choices generated by the model
Show child attributes
conversation_id
string | null
Target conversation id. For an existing conversation (conversation_id was supplied) it is always returned, even if this turn's answer was not persisted. For a new conversation it is null when nothing was persisted (e.g. no answer generated, or the history write failed).
Example:
"550e8400-e29b-41d4-a716-446655440000"
user_message_id
string | null
Id of the persisted user message node for this turn. Null when the turn was not persisted.
Example:
"f47ac10b-58cc-4372-a567-0e02b2c3d479"
assistant_message_id
string | null
Id of the persisted assistant message node (the new active leaf). Null when no assistant node was persisted.
Example:
"9b2e6f1a-3c4d-4e5f-8a9b-0c1d2e3f4a5b"
retrieved
object[] | null
Every knowledge-base chunk retrieved for this request and passed to the model as context (after authorization filtering), in retrieval order, whether or not the answer cited it. Null unless the request set include_retrieved: true; an empty array means nothing was retrieved.
Show child attributes
redacted_input
object | null
How the latest user message was redacted under the policy. Null unless the request set include_redacted_input: true with a redaction_policy_id.
The retrieval query actually used. Null unless the request set search_query.
Show child attributes
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"QAIP Docs","colors":{"primary":"#4E5766","light":"#ECF0F6","dark":"#030405"},"logo":{"light":"https://mintcdn.com/qaip/JULJYwLLg6eNrOP5/logo/light.png?fit=max\u0026auto=format\u0026n=JULJYwLLg6eNrOP5\u0026q=85\u0026s=8cdb9e6c41f4c5fa7aef814d60bff6b3","dark":"https://mintcdn.com/qaip/JULJYwLLg6eNrOP5/logo/dark.png?fit=max\u0026auto=format\u0026n=JULJYwLLg6eNrOP5\u0026q=85\u0026s=a4981c9a9c0cb9c4a994310f00a52700"},"favicon":"https://mintcdn.com/qaip/JULJYwLLg6eNrOP5/favicon.ico?fit=max\u0026auto=format\u0026n=JULJYwLLg6eNrOP5\u0026q=85\u0026s=b3451d8cf8ecc3e99b7a536659a095a9","navbar":{"links":[{"href":"mailto:qaip-support@qlonolink.com","label":"Support"}],"primary":{"type":"button","label":"Dashboard","href":"https://developer.qaip.com/dashboard/"}},"footer":{"socials":{"x":"https://x.com/qaipdev","github":"https://github.com/qlonolink"}},"seo":{"metatags":{"canonical":"https://developer.qaip.com"}},"integrations":{"clarity":{"projectId":"ulr9jpvf1v"},"ga4":{"measurementId":"G-THX8G16YJ1"}},"styling":{"latex":false},"navigation":{"global":{"anchors":[{"anchor":"Qiita","icon":"newspaper","href":"https://qiita.com/tags/qaip"},{"anchor":"Discord","icon":"discord","href":"https://discord.gg/2MdxWtYRue"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"qaip","hasAudioNarration":false,"actualSubdomain":"qaip","customDomains":["developer.qaip.com"],"gitSource":{"type":"github","owner":"qlonolink","repo":"qdev","deployBranch":"mintlify-prod","contentDirectory":"mintlify","isPrivate":true,"mountPath":"","label":"","_id":"6b10beab9ffae5051c4041a0"},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6aff489d7128032beac92015","clientVersion":"0.0.4448","searchFilterCounts":[{"language":"default","tag":"SDKs / API Reference","count":56},{"language":"default","tag":"References","count":56},{"language":"default","tag":"Documentation","count":33},{"language":"default","tag":"管理","count":9},{"language":"default","tag":"データソース","count":6},{"language":"default","tag":"Playground","count":5},{"language":"default","tag":"ユースケース","count":5},{"language":"default","tag":"Integrations","count":4},{"language":"default","tag":"QAIP入門","count":2},{"language":"default","tag":"Release Notes","count":2}]},"assistantConfig":{},"basePath":"/docs","hasChatPermissions":true,"hasWebMcpPermissions":true,"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":"rbac-expansion","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":"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":"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":"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":"turbopuffer-dual-write","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":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"control","enabled":true,"payload":{"type":"string","value":"control"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"auth-vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":"html.dark #topbar-cta-button{background:transparent!important;background-image:none!important;border:0!important;box-shadow:none!important}html.dark #topbar-cta-button :is(a,button){position:relative;border-radius:9999px!important;color:#030405!important;-webkit-text-fill-color:#030405!important;box-shadow:none!important;border:0!important;overflow:hidden}html.dark #topbar-cta-button :is(a,button)::before{content:\"\";position:absolute;inset:0;background:#EDF0F5;border-radius:inherit;z-index:10;pointer-events:none}html.dark #topbar-cta-button :is(a,button) :is(span,svg,strong){position:relative;z-index:20;color:#030405!important;-webkit-text-fill-color:#030405!important;text-shadow:none!important;mix-blend-mode:normal!important}html.dark #topbar-cta-button :is(a,button):hover::before{background:#F4F7FB}html.dark :where(aside,#sidebar) a[class*=\"bg-primary/10\"][class*=\"text-primary\"]{background:color-mix(in srgb, #6D92CC 10%, transparent)!important;color:#6D92CC!important}html.dark :where(aside,#sidebar) a:not([class*=\"bg-primary/10\"]):not([class*=\"primary-light/10\"]):hover{background:color-mix(in srgb, #6D92CC 5%, transparent);transition:background-color .15s ease}"}]}
{"page":{"pagePath":"api-reference/completions/generate-llm-completion","slug":"/api-reference/completions/generate-llm-completion","pageMetadata":{"title":"Generate LLM completion","description":"\u003cp> Generates a completion based on the input messages and retrieval chunks. If the 'stream' parameter is set to true, the response is streamed. By default the stream is plain text (text/plain). Send the request header 'Accept: text/event-stream' to instead receive a Server-Sent Events (SSE) stream of ag-ui protocol events (delta text as TEXT_MESSAGE_CONTENT, grounding, citations and (opt-in) retrieved chunks as CUSTOM events, history ids and completion as RUN_STARTED / RUN_FINISHED). \u003c/p> \u003cp> Required scope: `inference:run` \u003c/p>\n","deprecated":null,"version":null,"openapi":"/openapi.documented.yml post /completions","href":"/api-reference/completions/generate-llm-completion","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 ..._provideComponents(),\n ...props.components\n };\n return _jsxs(_Fragment, {\n children: [_jsx(\"p\", {\n children: \" Generates a completion based on the input messages and retrieval chunks. If the ‘stream’ parameter is set to true, the response is streamed. By default the stream is plain text (text/plain). Send the request header ‘Accept: text/event-stream’ to instead receive a Server-Sent Events (SSE) stream of ag-ui protocol events (delta text as TEXT_MESSAGE_CONTENT, grounding, citations and (opt-in) retrieved chunks as CUSTOM events, history ids and completion as RUN_STARTED / RUN_FINISHED). \"\n }), \"\\n\", _jsxs(\"p\", {\n children: [\" Required scope: \", _jsx(_components.code, {\n children: \"inference:run\"\n }), \" \"]\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":"Generate LLM completion","description":"\u003cp> Generates a completion based on the input messages and retrieval chunks. If the 'stream' parameter is set to true, the response is streamed. By default the stream is plain text (text/plain). Send the request header 'Accept: text/event-stream' to instead receive a Server-Sent Events (SSE) stream of ag-ui protocol events (delta text as TEXT_MESSAGE_CONTENT, grounding, citations and (opt-in) retrieved chunks as CUSTOM events, history ids and completion as RUN_STARTED / RUN_FINISHED). \u003c/p> \u003cp> Required scope: `inference:run` \u003c/p>\n","deprecated":null,"version":null,"openapi":"/openapi.documented.yml post /completions","href":"/api-reference/completions/generate-llm-completion","autogeneratedByOpenApi":true}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[],"codeExamples":{}},"jsLinks":[],"openApiReferenceData":{"operation":{"summary":"Generate LLM completion","description":"\u003cp> Generates a completion based on the input messages and retrieval chunks. If the 'stream' parameter is set to true, the response is streamed. By default the stream is plain text (text/plain). Send the request header 'Accept: text/event-stream' to instead receive a Server-Sent Events (SSE) stream of ag-ui protocol events (delta text as TEXT_MESSAGE_CONTENT, grounding, citations and (opt-in) retrieved chunks as CUSTOM events, history ids and completion as RUN_STARTED / RUN_FINISHED). \u003c/p> \u003cp> Required scope: `inference:run` \u003c/p>\n","tags":["completions"],"operationId":"completions","security":["33fdc68c-db69-40e3-a097-d02b791db742"],"requestBody":"21c3ecb4-ed8c-4758-97c7-d64d2ae8698b","responses":{"200":"c0e11c6d-a2c8-42d7-b5f8-b1d80a87027a","400":"834b5060-3096-402f-92d9-3d5c13acd737","401":"0fe479a2-cdee-4d14-ae82-8b7dc0998e3d","403":"f41cb81f-ccd4-42f8-8558-b21600eb340d","422":"16edb5d1-e249-4228-ac61-fdb34fc92022","429":"866348d0-5964-4bea-a934-c8d7669a821f","500":"4c13462e-1621-483d-897b-1a9e400a32a6","502":"3463fe1a-3bb2-4966-913e-7a846c1faa23","503":"faeedb04-e806-46ca-86bc-1e69c7279ebd"},"x-codeSamples":[{"lang":"Python","source":"import os\nfrom qaip import Qaip\n\nclient = Qaip(\n api_key=os.environ.get(\"QAIP_API_KEY\"), # This is the default and can be omitted\n)\nresponse = client.completion(\n messages=[{\n \"content\": \"content\",\n \"role\": \"system\",\n }],\n)\nprint(response.assistant_message_id)"},{"lang":"cURL","source":"curl https://developer.qaip.com/api/v1/completions \\\n -H 'Content-Type: application/json' \\\n -H \"x-api-key: $QAIP_API_KEY\" \\\n -d '{\n \"messages\": [\n {\n \"content\": \"content\",\n \"role\": \"system\"\n }\n ],\n \"authz_policy\": \"external-chatbot\",\n \"conversation_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"parent_message_id\": \"f47ac10b-58cc-4372-a567-0e02b2c3d479\",\n \"principal_id\": \"user-123\"\n }'"}],"method":"post","type":"path","servers":["36e4ae26-2b94-4748-8d04-bb7c3466c01d"],"path":"/completions","baseUrlOptions":["https://developer.qaip.com/api/v1"],"title":"Generate LLM completion","codeSamples":[{"lang":"Python","source":"import os\nfrom qaip import Qaip\n\nclient = Qaip(\n api_key=os.environ.get(\"QAIP_API_KEY\"), # This is the default and can be omitted\n)\nresponse = client.completion(\n messages=[{\n \"content\": \"content\",\n \"role\": \"system\",\n }],\n)\nprint(response.assistant_message_id)"},{"lang":"cURL","source":"curl https://developer.qaip.com/api/v1/completions \\\n -H 'Content-Type: application/json' \\\n -H \"x-api-key: $QAIP_API_KEY\" \\\n -d '{\n \"messages\": [\n {\n \"content\": \"content\",\n \"role\": \"system\"\n }\n ],\n \"authz_policy\": \"external-chatbot\",\n \"conversation_id\": \"550e8400-e29b-41d4-a716-446655440000\",\n \"parent_message_id\": \"f47ac10b-58cc-4372-a567-0e02b2c3d479\",\n \"principal_id\": \"user-123\"\n }'"}],"requiredOnlyExamples":false,"requestExampleType":"codeSamples","responseExampleType":"generated"},"dependencies":{"parameters":{},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["messages"],"properties":{"messages":{"type":"array","description":"The messages to generate completion for","items":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string","description":"The role of the message sender","enum":["system","user","assistant"],"isRequired":true,"uniqueKey":"messages.items.[INDEX].role","typeLabel":"enum\u003cstring>"},"content":{"type":"string","description":"The content of the message","isRequired":true,"uniqueKey":"messages.items.[INDEX].content","typeLabel":"string"}},"uniqueKey":"messages.items.[INDEX]","typeLabel":"object"},"isRequired":true,"uniqueKey":"messages","typeLabel":"object[]"},"stream":{"type":"boolean","description":"Whether to stream the response. If true, the response is streamed as 'text/plain' by default, or as an ag-ui Server-Sent Events stream ('text/event-stream') when the request sends the header 'Accept: text/event-stream'.\n","default":false,"uniqueKey":"stream","typeLabel":"boolean"},"citation":{"type":"boolean","description":"Whether to include citations in the response","default":true,"uniqueKey":"citation","typeLabel":"boolean"},"include_retrieved":{"type":"boolean","default":false,"description":"Whether to return, separately from `citations`, every knowledge-base chunk\nthat was retrieved for this request and passed to the model as context\n(after authorization filtering), whether or not the answer cited it.\nWhen true, the JSON response carries them in the top-level `retrieved`\narray, the SSE stream emits one or more CUSTOM events named `retrieved`\nbefore RUN_FINISHED (split by encoded size; concatenate their values in\norder to get the full list), and the persisted assistant message keeps them in\n`assistant_metadata.retrieved` (see GET /conversations). The text/plain\nstream cannot carry them in the body, so it only persists them. Intended for\ncallers that audit what the end-user was shown; off by default so the\nresponse size and stored history of existing clients do not change.\n","uniqueKey":"include_retrieved","typeLabel":"boolean"},"include_redacted_input":{"type":"boolean","default":false,"description":"Whether to return how the latest user message was redacted (see\n`RedactedInput`), e.g. to show the end-user their question in redacted form.\nThe messages are redacted first, and both the retrieval query and the LLM\nprompt are built from the redacted text. Only effective with\n`redaction_policy_id`. The JSON response carries it in the top-level\n`redacted_input`; the SSE stream emits one CUSTOM event named\n`redaction_applied` as soon as the messages are redacted, before the search and\nthe answer text. The text/plain stream cannot carry it, and it is not stored in\nthe conversation history.\n","uniqueKey":"include_redacted_input","typeLabel":"boolean"},"grounding":{"type":"boolean","default":false,"description":"Whether to enable Gemini's Google Search grounding during answer\ngeneration. Only effective when the completion model is a Gemini\nmodel and the `gemini_grounding` feature is enabled on the server;\notherwise this flag is ignored.\n","uniqueKey":"grounding","typeLabel":"boolean"},"redaction_policy_id":{"oneOf":[{"type":"string","minLength":1,"pattern":"^[A-Za-z0-9._-]+$","description":"ID of a versioned redaction policy (built-in, or a tenant policy name) to\napply before anything leaves QAIP for an external provider: the retrieval\nquery sent to the embedding API, the retrieved knowledge-base chunks\n(title / URL / text) and the conversation `messages` sent to the LLM.\nThe redaction boundaries are `completions_query`, `completions_docs`,\n`completions_messages`, `completions_messages_system` (the `system` role\nmessages), `completions_messages_assistant` (the `assistant` role\nmessages) and `completions_search_query_context` (`search_query.context`);\na policy can exclude some of them via `skippedBoundaries`.\nThe `messages` are redacted first and the retrieval query is built from the\nredacted user messages, so `completions_query` only applies when the policy\nexcludes a boundary the query is built from: `completions_messages`, or with\n`search_query.mode: rewrite` also `completions_messages_assistant` and\n`completions_search_query_context` (the rewrite may copy words from earlier\nanswers or from `search_query.context`). With `search_query.mode: rewrite`,\nthe LLM call that rewrites the query receives the same `messages` as the\nanswer, so it follows `completions_messages` as well, and\n`search_query.context` follows `completions_search_query_context`.\n\nWhen omitted or `null` (the default), **no redaction is performed and the\ninput is sent to the external provider as-is**. This is an explicit API\ncontract, not a fail-open behavior. Unknown IDs return\n`422 UNKNOWN_REDACTION_POLICY`; an unavailable redactor returns\n`503 REDACTION_UNAVAILABLE` and a redaction failure during generation\nreturns `503 REDACTION_FAILED` (or `RUN_ERROR` with that code on the SSE\nstream). The request is never forwarded unmasked.\n\nRedacted chunks are also what `citations` and `retrieved` return, so\ncitation links can break when the URL itself contains masked values.\n`grounding: true` may be combined with a policy: Gemini derives its search\nqueries from the redacted messages, but QAIP cannot intercept the built-in\ngrounding search itself, so the guarantee is weaker than the Agent run's\nexplicit `google_query` / `google_result` boundaries.\n","uniqueKey":"redaction_policy_id.oneOf.0","typeLabel":"string"},{"type":"null","minLength":1,"pattern":"^[A-Za-z0-9._-]+$","description":"ID of a versioned redaction policy (built-in, or a tenant policy name) to\napply before anything leaves QAIP for an external provider: the retrieval\nquery sent to the embedding API, the retrieved knowledge-base chunks\n(title / URL / text) and the conversation `messages` sent to the LLM.\nThe redaction boundaries are `completions_query`, `completions_docs`,\n`completions_messages`, `completions_messages_system` (the `system` role\nmessages), `completions_messages_assistant` (the `assistant` role\nmessages) and `completions_search_query_context` (`search_query.context`);\na policy can exclude some of them via `skippedBoundaries`.\nThe `messages` are redacted first and the retrieval query is built from the\nredacted user messages, so `completions_query` only applies when the policy\nexcludes a boundary the query is built from: `completions_messages`, or with\n`search_query.mode: rewrite` also `completions_messages_assistant` and\n`completions_search_query_context` (the rewrite may copy words from earlier\nanswers or from `search_query.context`). With `search_query.mode: rewrite`,\nthe LLM call that rewrites the query receives the same `messages` as the\nanswer, so it follows `completions_messages` as well, and\n`search_query.context` follows `completions_search_query_context`.\n\nWhen omitted or `null` (the default), **no redaction is performed and the\ninput is sent to the external provider as-is**. This is an explicit API\ncontract, not a fail-open behavior. Unknown IDs return\n`422 UNKNOWN_REDACTION_POLICY`; an unavailable redactor returns\n`503 REDACTION_UNAVAILABLE` and a redaction failure during generation\nreturns `503 REDACTION_FAILED` (or `RUN_ERROR` with that code on the SSE\nstream). The request is never forwarded unmasked.\n\nRedacted chunks are also what `citations` and `retrieved` return, so\ncitation links can break when the URL itself contains masked values.\n`grounding: true` may be combined with a policy: Gemini derives its search\nqueries from the redacted messages, but QAIP cannot intercept the built-in\ngrounding search itself, so the guarantee is weaker than the Agent run's\nexplicit `google_query` / `google_result` boundaries.\n","uniqueKey":"redaction_policy_id.oneOf.1","typeLabel":"null"}],"uniqueKey":"redaction_policy_id","typeLabel":"string | null"},"tags":{"type":"array","description":"target tag names to be obtained","items":{"type":"string","uniqueKey":"tags.items.[INDEX]","typeLabel":"string"},"uniqueKey":"tags","typeLabel":"string[]"},"tag_ids":{"type":"array","description":"target tag IDs to be obtained","items":{"type":"string","uniqueKey":"tag_ids.items.[INDEX]","typeLabel":"string"},"uniqueKey":"tag_ids","typeLabel":"string[]"},"tag_filter_logic":{"type":"string","enum":["AND","OR"],"default":"OR","description":"Logical operator for combining filter conditions","uniqueKey":"tag_filter_logic","typeLabel":"enum\u003cstring>"},"source_types":{"type":"array","items":{"type":"string","description":"The type of the source","enum":["crawl","local_file","google_drive","github","notion"],"uniqueKey":"source_types.items.[INDEX]","typeLabel":"enum\u003cstring>"},"uniqueKey":"source_types","typeLabel":"enum\u003cstring>[]"},"file_types":{"type":"array","items":{"type":"string","description":"The type of the source file","enum":["html","pdf","ppt","pptx","pptm","doc","docx","docm","xls","xlsx","xlsm","md","txt","jsonl","png","jpg","webp","heic","heif","wav","mp3","aiff","aac","m4a","ogg","flac","mp4","mpg","mov","avi","flv","webm","wmv","3gp","notion_page"],"uniqueKey":"file_types.items.[INDEX]","typeLabel":"enum\u003cstring>"},"uniqueKey":"file_types","typeLabel":"enum\u003cstring>[]"},"date_from":{"type":"integer","description":"Start date for content search (Unix timestamp in seconds)","minimum":1735639200,"uniqueKey":"date_from","typeLabel":"integer"},"date_to":{"type":"integer","description":"End date for content search (Unix timestamp in seconds)","minimum":1735639200,"uniqueKey":"date_to","typeLabel":"integer"},"domains":{"type":"array","description":"Array of domains to search within (supports partial matching)","items":{"type":"string","uniqueKey":"domains.items.[INDEX]","typeLabel":"string"},"uniqueKey":"domains","typeLabel":"string[]"},"metadata":{"type":"object","description":"(reserved for future use) Filter group with nested structure. Supports combining filters with AND/OR logic.","properties":{"logic":{"type":"string","enum":["AND","OR"],"default":"OR","description":"Logical operator for combining filter conditions","uniqueKey":"metadata.logic","typeLabel":"enum\u003cstring>"},"filters":{"type":"array","description":"Filters within this group (combined using the logic operator)","items":{"type":"object","description":"Metadata filter for filtering search results by key/value pairs","required":["key","type","operator"],"properties":{"key":{"type":"string","description":"Metadata key","isRequired":true,"uniqueKey":"metadata.filters.items.[INDEX].key","typeLabel":"string"},"type":{"type":"string","enum":["string","integer","float","date","datetime","string_list","integer_list"],"description":"Data type of the metadata value. string_list / integer_list are valid only for metadata_filter (declared LanceDB array columns); the PostgreSQL-backed metadata / source_metadata / chunk_metadata filters reject them.\n","isRequired":true,"uniqueKey":"metadata.filters.items.[INDEX].type","typeLabel":"enum\u003cstring>"},"operator":{"type":"string","enum":["eq","ne","gt","gte","lt","lte","between","contains"],"default":"eq","description":"Comparison operator. contains tests array membership and is valid only for string_list / integer_list columns in metadata_filter; conversely those array types accept only contains.\n","isRequired":true,"uniqueKey":"metadata.filters.items.[INDEX].operator","typeLabel":"enum\u003cstring>"},"val":{"description":"Metadata value (string or number). This is optional since min/max can be used for range queries.","uniqueKey":"metadata.filters.items.[INDEX].val","typeLabel":"any"},"min":{"description":"Minimum value for range queries (string or number)","uniqueKey":"metadata.filters.items.[INDEX].min","typeLabel":"any"},"max":{"description":"Maximum value for range queries (string or number)","uniqueKey":"metadata.filters.items.[INDEX].max","typeLabel":"any"}},"uniqueKey":"metadata.filters.items.[INDEX]","typeLabel":"object"},"uniqueKey":"metadata.filters","typeLabel":"object[]"},"groups":{"type":"array","description":"Nested subgroups","items":{"$circularRef":"580b0629-fd2b-49e2-982d-db0a42d0de6d"},"maxItems":10,"uniqueKey":"metadata.groups","typeLabel":"array"}},"uniqueKey":"metadata","typeLabel":"object"},"source_metadata":{"type":"object","description":"Filter by individual source/file metadata from source_metadatas table","properties":{"logic":{"type":"string","enum":["AND","OR"],"default":"OR","description":"Logical operator for combining filter conditions","uniqueKey":"source_metadata.logic","typeLabel":"enum\u003cstring>"},"filters":{"type":"array","description":"Filters within this group (combined using the logic operator)","items":{"type":"object","description":"Metadata filter for filtering search results by key/value pairs","required":["key","type","operator"],"properties":{"key":{"type":"string","description":"Metadata key","isRequired":true,"uniqueKey":"source_metadata.filters.items.[INDEX].key","typeLabel":"string"},"type":{"type":"string","enum":["string","integer","float","date","datetime","string_list","integer_list"],"description":"Data type of the metadata value. string_list / integer_list are valid only for metadata_filter (declared LanceDB array columns); the PostgreSQL-backed metadata / source_metadata / chunk_metadata filters reject them.\n","isRequired":true,"uniqueKey":"source_metadata.filters.items.[INDEX].type","typeLabel":"enum\u003cstring>"},"operator":{"type":"string","enum":["eq","ne","gt","gte","lt","lte","between","contains"],"default":"eq","description":"Comparison operator. contains tests array membership and is valid only for string_list / integer_list columns in metadata_filter; conversely those array types accept only contains.\n","isRequired":true,"uniqueKey":"source_metadata.filters.items.[INDEX].operator","typeLabel":"enum\u003cstring>"},"val":{"description":"Metadata value (string or number). This is optional since min/max can be used for range queries.","uniqueKey":"source_metadata.filters.items.[INDEX].val","typeLabel":"any"},"min":{"description":"Minimum value for range queries (string or number)","uniqueKey":"source_metadata.filters.items.[INDEX].min","typeLabel":"any"},"max":{"description":"Maximum value for range queries (string or number)","uniqueKey":"source_metadata.filters.items.[INDEX].max","typeLabel":"any"}},"uniqueKey":"source_metadata.filters.items.[INDEX]","typeLabel":"object"},"uniqueKey":"source_metadata.filters","typeLabel":"object[]"},"groups":{"type":"array","description":"Nested subgroups","items":{"$circularRef":"580b0629-fd2b-49e2-982d-db0a42d0de6d"},"maxItems":10,"uniqueKey":"source_metadata.groups","typeLabel":"array"}},"uniqueKey":"source_metadata","typeLabel":"object"},"chunk_metadata":{"type":"object","description":"Filter by chunk-level metadata from chunk_metadatas table","properties":{"logic":{"type":"string","enum":["AND","OR"],"default":"OR","description":"Logical operator for combining filter conditions","uniqueKey":"chunk_metadata.logic","typeLabel":"enum\u003cstring>"},"filters":{"type":"array","description":"Filters within this group (combined using the logic operator)","items":{"type":"object","description":"Metadata filter for filtering search results by key/value pairs","required":["key","type","operator"],"properties":{"key":{"type":"string","description":"Metadata key","isRequired":true,"uniqueKey":"chunk_metadata.filters.items.[INDEX].key","typeLabel":"string"},"type":{"type":"string","enum":["string","integer","float","date","datetime","string_list","integer_list"],"description":"Data type of the metadata value. string_list / integer_list are valid only for metadata_filter (declared LanceDB array columns); the PostgreSQL-backed metadata / source_metadata / chunk_metadata filters reject them.\n","isRequired":true,"uniqueKey":"chunk_metadata.filters.items.[INDEX].type","typeLabel":"enum\u003cstring>"},"operator":{"type":"string","enum":["eq","ne","gt","gte","lt","lte","between","contains"],"default":"eq","description":"Comparison operator. contains tests array membership and is valid only for string_list / integer_list columns in metadata_filter; conversely those array types accept only contains.\n","isRequired":true,"uniqueKey":"chunk_metadata.filters.items.[INDEX].operator","typeLabel":"enum\u003cstring>"},"val":{"description":"Metadata value (string or number). This is optional since min/max can be used for range queries.","uniqueKey":"chunk_metadata.filters.items.[INDEX].val","typeLabel":"any"},"min":{"description":"Minimum value for range queries (string or number)","uniqueKey":"chunk_metadata.filters.items.[INDEX].min","typeLabel":"any"},"max":{"description":"Maximum value for range queries (string or number)","uniqueKey":"chunk_metadata.filters.items.[INDEX].max","typeLabel":"any"}},"uniqueKey":"chunk_metadata.filters.items.[INDEX]","typeLabel":"object"},"uniqueKey":"chunk_metadata.filters","typeLabel":"object[]"},"groups":{"type":"array","description":"Nested subgroups","items":{"$circularRef":"580b0629-fd2b-49e2-982d-db0a42d0de6d"},"maxItems":10,"uniqueKey":"chunk_metadata.groups","typeLabel":"array"}},"uniqueKey":"chunk_metadata","typeLabel":"object"},"metadata_filter":{"type":"object","description":"Filter by declared metadata columns (see /metadata_columns) pushed down directly to LanceDB (no PostgreSQL round-trip). Targets string/integer/string_list /integer_list typed columns. Keys must be declared via /metadata_columns or the request is rejected (400).\n","properties":{"logic":{"type":"string","enum":["AND","OR"],"default":"OR","description":"Logical operator for combining filter conditions","uniqueKey":"metadata_filter.logic","typeLabel":"enum\u003cstring>"},"filters":{"type":"array","description":"Filters within this group (combined using the logic operator)","items":{"type":"object","description":"Metadata filter for filtering search results by key/value pairs","required":["key","type","operator"],"properties":{"key":{"type":"string","description":"Metadata key","isRequired":true,"uniqueKey":"metadata_filter.filters.items.[INDEX].key","typeLabel":"string"},"type":{"type":"string","enum":["string","integer","float","date","datetime","string_list","integer_list"],"description":"Data type of the metadata value. string_list / integer_list are valid only for metadata_filter (declared LanceDB array columns); the PostgreSQL-backed metadata / source_metadata / chunk_metadata filters reject them.\n","isRequired":true,"uniqueKey":"metadata_filter.filters.items.[INDEX].type","typeLabel":"enum\u003cstring>"},"operator":{"type":"string","enum":["eq","ne","gt","gte","lt","lte","between","contains"],"default":"eq","description":"Comparison operator. contains tests array membership and is valid only for string_list / integer_list columns in metadata_filter; conversely those array types accept only contains.\n","isRequired":true,"uniqueKey":"metadata_filter.filters.items.[INDEX].operator","typeLabel":"enum\u003cstring>"},"val":{"description":"Metadata value (string or number). This is optional since min/max can be used for range queries.","uniqueKey":"metadata_filter.filters.items.[INDEX].val","typeLabel":"any"},"min":{"description":"Minimum value for range queries (string or number)","uniqueKey":"metadata_filter.filters.items.[INDEX].min","typeLabel":"any"},"max":{"description":"Maximum value for range queries (string or number)","uniqueKey":"metadata_filter.filters.items.[INDEX].max","typeLabel":"any"}},"uniqueKey":"metadata_filter.filters.items.[INDEX]","typeLabel":"object"},"uniqueKey":"metadata_filter.filters","typeLabel":"object[]"},"groups":{"type":"array","description":"Nested subgroups","items":{"$circularRef":"580b0629-fd2b-49e2-982d-db0a42d0de6d"},"maxItems":10,"uniqueKey":"metadata_filter.groups","typeLabel":"array"}},"uniqueKey":"metadata_filter","typeLabel":"object"},"use_postfilter":{"type":"boolean","default":false,"description":"Whether to bypass LanceDB prefilter and apply WHERE after the\nvector search (IVF_PQ) returns top-K. Significantly faster for\nbroad filters that cover most of the table, but may return\nfewer than `limit` results when the hit rate is low.\n","uniqueKey":"use_postfilter","typeLabel":"boolean"},"limit":{"type":"integer","description":"Maximum number of chunks to retrieve as context for completion","minimum":1,"maximum":100,"default":10,"uniqueKey":"limit","typeLabel":"integer"},"authz_policy":{"type":"string","description":"(reserved for future use) Name of the registered authz policy to\nevaluate when retrieving context. Defaults to the reserved \"default\"\npolicy when omitted. Ignored when authz is disabled.\n","pattern":"^[a-z][a-z0-9_-]{0,63}$","example":"external-chatbot","uniqueKey":"authz_policy","typeLabel":"string"},"principal_id":{"type":"string","description":"Identifier of the end-user (principal) on whose behalf this request is made. Used to look up the principal's authz subject attributes for policy evaluation. When omitted, subject attributes are empty (most restrictive). Ignored when authz is disabled.\n","maxLength":256,"example":"user-123","uniqueKey":"principal_id","typeLabel":"string"},"conversation_id":{"type":"string","description":"Conversation to append this turn to. When omitted, a new conversation is\ncreated server-side and its id is returned (response body for JSON, the\nX-Conversation-Id header for streaming). Pass it back on subsequent turns\nso the answer is persisted into the same conversation history tree.\nWhen set, the past conversation is rebuilt server-side from the stored tree,\nso only the latest user message in `messages` is used as the new input\n(earlier `messages` entries are ignored). When `search_query` is omitted,\nretrieval uses that latest question; set `search_query` to change it.\n","example":"550e8400-e29b-41d4-a716-446655440000","uniqueKey":"conversation_id","typeLabel":"string"},"parent_message_id":{"type":"string","description":"Id of the message node to branch this turn from (the parent of the new\nuser message). When omitted, the turn continues from the conversation's\ncurrent active leaf. Set it to fork a branch (e.g. editing an earlier\nquestion). Must belong to conversation_id.\n","example":"f47ac10b-58cc-4372-a567-0e02b2c3d479","uniqueKey":"parent_message_id","typeLabel":"string"},"regenerate":{"type":"boolean","description":"When true, the latest user message is NOT persisted again; instead a new\nassistant answer is created as a sibling under parent_message_id (which must\nreference an existing user message). Used to regenerate an answer.\n","default":false,"uniqueKey":"regenerate","typeLabel":"boolean"},"truncation":{"type":"string","enum":["auto","disabled"],"default":"auto","description":"How to handle a reconstructed conversation that exceeds the model's context\nbudget (only relevant when conversation_id is set, i.e. history is rebuilt\nserver-side). \"auto\": drop the oldest turns until it fits (the latest question\nis always kept). \"disabled\": return 400 if it does not fit.\n","uniqueKey":"truncation","typeLabel":"enum\u003cstring>"},"search_query":{"type":"object","additionalProperties":false,"required":["mode"],"description":"How to build the retrieval query. When omitted, a new conversation uses `concat` over\nevery `user` message, and a continuation (`conversation_id` set) uses only the latest\n`user` message. When set, it applies the same way to both. The target turns are taken\nfrom the conversation passed to the answer model (after redaction and `truncation`).\nIf the `rewrite` LLM call fails, the request fails and does not fall back to `concat`:\n500 without `stream`, and `RUN_ERROR` on the SSE stream. A `text/plain` stream has\nalready returned 200, so like other generation failures it ends without any body.\n","properties":{"mode":{"type":"string","enum":["concat","rewrite"],"description":"How to build the retrieval query from the conversation. `concat` joins the `user`\nmessages with newlines. `rewrite` asks an LLM to turn the conversation (including the\n`assistant` answers) into one standalone query. It calls the LLM even when the target\nturns contain only one `user` message, so choose `concat` to search with the message as\nis.\n","isRequired":true,"uniqueKey":"search_query.mode","typeLabel":"enum\u003cstring>"},"history_turns":{"type":"integer","minimum":1,"description":"Use only the latest N `user` messages (the current question included) and the\n`assistant` answers between them. When omitted, every turn is used.\n`mode: concat` with `history_turns: 1` uses only the latest question.\n","uniqueKey":"search_query.history_turns","typeLabel":"integer"},"context":{"type":"string","minLength":1,"maxLength":4000,"description":"Background about the person asking (for example their department and job title)\nthat the `rewrite` LLM may use to resolve references such as \"my department\" in the\nquestion. It is passed to the rewrite LLM as data, not as instructions, and is not\nsent to the answer model. Only valid with `mode: rewrite` (400 otherwise). With a\n`redaction_policy_id` it is redacted at the `completions_search_query_context`\nboundary before it reaches the rewrite LLM.\n","uniqueKey":"search_query.context","typeLabel":"string"}},"uniqueKey":"search_query","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"messages":[{"content":"\u003cstring>"}],"stream":false,"citation":true,"include_retrieved":false,"include_redacted_input":false,"grounding":false,"redaction_policy_id":"\u003cstring>","tags":["\u003cstring>"],"tag_ids":["\u003cstring>"],"tag_filter_logic":"OR","source_types":[],"file_types":[],"date_from":1735639201,"date_to":1735639201,"domains":["\u003cstring>"],"metadata":{"logic":"OR","filters":[{"key":"\u003cstring>","operator":"eq","val":"\u003cunknown>","min":"\u003cunknown>","max":"\u003cunknown>"}],"groups":"\u003carray>"},"source_metadata":{"logic":"OR","filters":[{"key":"\u003cstring>","operator":"eq","val":"\u003cunknown>","min":"\u003cunknown>","max":"\u003cunknown>"}],"groups":"\u003carray>"},"chunk_metadata":{"logic":"OR","filters":[{"key":"\u003cstring>","operator":"eq","val":"\u003cunknown>","min":"\u003cunknown>","max":"\u003cunknown>"}],"groups":"\u003carray>"},"metadata_filter":{"logic":"OR","filters":[{"key":"\u003cstring>","operator":"eq","val":"\u003cunknown>","min":"\u003cunknown>","max":"\u003cunknown>"}],"groups":"\u003carray>"},"use_postfilter":false,"limit":10,"authz_policy":"external-chatbot","principal_id":"user-123","conversation_id":"550e8400-e29b-41d4-a716-446655440000","parent_message_id":"f47ac10b-58cc-4372-a567-0e02b2c3d479","regenerate":false,"truncation":"auto"}}},"exampleType":"generated"}},"exampleType":"generated"},"responses":{"c0e11c6d-a2c8-42d7-b5f8-b1d80a87027a":{"description":"Successful completion. If the 'stream' parameter is false, the response is returned as application/json. If the 'stream' parameter is true, the response is returned as a stream of plain text (text/plain) by default, or as an ag-ui Server-Sent Events stream (text/event-stream) when the request sends 'Accept: text/event-stream'.\n","content":{"application/json":{"schema":{"type":"object","required":["created","choices"],"properties":{"created":{"type":"integer","description":"The Unix timestamp (in seconds) of when the completion was created","example":1677649420,"isRequired":true,"uniqueKey":"created","typeLabel":"integer"},"choices":{"type":"array","description":"The completion choices generated by the model","items":{"type":"object","required":["index","message","finish_reason"],"properties":{"index":{"type":"integer","description":"The index of this completion choice","example":0,"isRequired":true,"uniqueKey":"choices.items.[INDEX].index","typeLabel":"integer"},"message":{"type":"object","required":["role","content"],"properties":{"role":{"type":"string","description":"The role of the message sender","enum":["assistant"],"example":"assistant","isRequired":true,"uniqueKey":"choices.items.[INDEX].message.role","typeLabel":"enum\u003cstring>"},"content":{"type":"string","description":"The content of the message","example":"Hello! How can I help you today?","isRequired":true,"uniqueKey":"choices.items.[INDEX].message.content","typeLabel":"string"}},"isRequired":true,"uniqueKey":"choices.items.[INDEX].message","typeLabel":"object"},"finish_reason":{"type":"string","description":"The reason why the model stopped generating tokens","example":"stop","isRequired":true,"uniqueKey":"choices.items.[INDEX].finish_reason","typeLabel":"string"},"citations":{"type":"array","description":"Array of search results","items":{"type":"object","required":["id","text","url","title","timestamp","file_type","page_number","source_type"],"properties":{"id":{"type":"string","description":"Content ID","isRequired":true,"uniqueKey":"choices.items.[INDEX].citations.items.[INDEX].id","typeLabel":"string"},"text":{"type":"string","description":"Content chunk from the source","isRequired":true,"uniqueKey":"choices.items.[INDEX].citations.items.[INDEX].text","typeLabel":"string"},"url":{"type":"string","description":"Source URL of the content","isRequired":true,"uniqueKey":"choices.items.[INDEX].citations.items.[INDEX].url","typeLabel":"string"},"title":{"type":"string","description":"Title of the content or document","isRequired":true,"uniqueKey":"choices.items.[INDEX].citations.items.[INDEX].title","typeLabel":"string"},"timestamp":{"type":"integer","description":"Unix timestamp when the content was indexed","isRequired":true,"uniqueKey":"choices.items.[INDEX].citations.items.[INDEX].timestamp","typeLabel":"integer"},"file_type":{"type":"string","description":"The type of the source file","enum":["html","pdf","ppt","pptx","pptm","doc","docx","docm","xls","xlsx","xlsm","md","txt","jsonl","png","jpg","webp","heic","heif","wav","mp3","aiff","aac","m4a","ogg","flac","mp4","mpg","mov","avi","flv","webm","wmv","3gp","notion_page"],"isRequired":true,"uniqueKey":"choices.items.[INDEX].citations.items.[INDEX].file_type","typeLabel":"enum\u003cstring>"},"page_number":{"type":"integer","description":"Page number for paginated documents like PDFs. Set to 0 for sources without page numbers","default":0,"isRequired":true,"uniqueKey":"choices.items.[INDEX].citations.items.[INDEX].page_number","typeLabel":"integer"},"source_type":{"type":"string","description":"The type of the source","enum":["crawl","local_file","google_drive","github","notion"],"isRequired":true,"uniqueKey":"choices.items.[INDEX].citations.items.[INDEX].source_type","typeLabel":"enum\u003cstring>"},"source_id":{"type":"string","description":"Optional source ID for the original source. For crawl content, use this value with GET /sources/{source_id}/raw to download the stored crawl file content. For local_file content, use GET /sources/{source_id} for source details.\n","uniqueKey":"choices.items.[INDEX].citations.items.[INDEX].source_id","typeLabel":"string"},"keywords":{"type":"array","items":{"type":"string","uniqueKey":"choices.items.[INDEX].citations.items.[INDEX].keywords.items.[INDEX]","typeLabel":"string"},"uniqueKey":"choices.items.[INDEX].citations.items.[INDEX].keywords","typeLabel":"string[]"}},"uniqueKey":"choices.items.[INDEX].citations.items.[INDEX]","typeLabel":"object"},"uniqueKey":"choices.items.[INDEX].citations","typeLabel":"object[]"},"web_citations":{"type":"array","description":"Web sources from Gemini's Google Search grounding, returned separately from `citations`. Present only when grounding was enabled and the model used web results.\n","items":{"type":"object","description":"A web source returned by Gemini's Google Search grounding. Distinct from Content (internal knowledge base citations); surfaced separately so clients can render web references apart from internal document citations.\n","required":["url","title"],"properties":{"url":{"type":"string","description":"URL of the grounded web source","isRequired":true,"uniqueKey":"choices.items.[INDEX].web_citations.items.[INDEX].url","typeLabel":"string"},"title":{"type":"string","description":"Title of the grounded web source","isRequired":true,"uniqueKey":"choices.items.[INDEX].web_citations.items.[INDEX].title","typeLabel":"string"}},"uniqueKey":"choices.items.[INDEX].web_citations.items.[INDEX]","typeLabel":"object"},"uniqueKey":"choices.items.[INDEX].web_citations","typeLabel":"object[]"},"search_suggestion":{"type":"string","description":"Google Search Suggestions HTML (searchEntryPoint.renderedContent) from Gemini grounding. Per Google's \"Grounding with Google Search\" terms, clients MUST display this content as provided whenever it is present. Present only when grounding produced search suggestions.\n","uniqueKey":"choices.items.[INDEX].search_suggestion","typeLabel":"string"},"web_search_queries":{"type":"array","description":"The Google Search queries Gemini issued for grounding. Present only when grounding was used.\n","items":{"type":"string","uniqueKey":"choices.items.[INDEX].web_search_queries.items.[INDEX]","typeLabel":"string"},"uniqueKey":"choices.items.[INDEX].web_search_queries","typeLabel":"string[]"}},"uniqueKey":"choices.items.[INDEX]","typeLabel":"object"},"isRequired":true,"uniqueKey":"choices","typeLabel":"object[]"},"conversation_id":{"oneOf":[{"type":"string","description":"Target conversation id. For an existing conversation (conversation_id was supplied) it is always returned, even if this turn's answer was not persisted. For a new conversation it is null when nothing was persisted (e.g. no answer generated, or the history write failed).\n","example":"550e8400-e29b-41d4-a716-446655440000","uniqueKey":"conversation_id.oneOf.0","typeLabel":"string"},{"type":"null","description":"Target conversation id. For an existing conversation (conversation_id was supplied) it is always returned, even if this turn's answer was not persisted. For a new conversation it is null when nothing was persisted (e.g. no answer generated, or the history write failed).\n","example":"550e8400-e29b-41d4-a716-446655440000","uniqueKey":"conversation_id.oneOf.1","typeLabel":"null"}],"uniqueKey":"conversation_id","typeLabel":"string | null"},"user_message_id":{"oneOf":[{"type":"string","description":"Id of the persisted user message node for this turn. Null when the turn was not persisted.\n","example":"f47ac10b-58cc-4372-a567-0e02b2c3d479","uniqueKey":"user_message_id.oneOf.0","typeLabel":"string"},{"type":"null","description":"Id of the persisted user message node for this turn. Null when the turn was not persisted.\n","example":"f47ac10b-58cc-4372-a567-0e02b2c3d479","uniqueKey":"user_message_id.oneOf.1","typeLabel":"null"}],"uniqueKey":"user_message_id","typeLabel":"string | null"},"assistant_message_id":{"oneOf":[{"type":"string","description":"Id of the persisted assistant message node (the new active leaf). Null when no assistant node was persisted.\n","example":"9b2e6f1a-3c4d-4e5f-8a9b-0c1d2e3f4a5b","uniqueKey":"assistant_message_id.oneOf.0","typeLabel":"string"},{"type":"null","description":"Id of the persisted assistant message node (the new active leaf). Null when no assistant node was persisted.\n","example":"9b2e6f1a-3c4d-4e5f-8a9b-0c1d2e3f4a5b","uniqueKey":"assistant_message_id.oneOf.1","typeLabel":"null"}],"uniqueKey":"assistant_message_id","typeLabel":"string | null"},"retrieved":{"oneOf":[{"type":"array","description":"Every knowledge-base chunk retrieved for this request and passed to the model as context (after authorization filtering), in retrieval order, whether or not the answer cited it. Null unless the request set `include_retrieved: true`; an empty array means nothing was retrieved.\n","items":{"type":"object","required":["id","text","url","title","timestamp","file_type","page_number","source_type"],"properties":{"id":{"type":"string","description":"Content ID","isRequired":true,"uniqueKey":"retrieved.oneOf.0.items.[INDEX].id","typeLabel":"string"},"text":{"type":"string","description":"Content chunk from the source","isRequired":true,"uniqueKey":"retrieved.oneOf.0.items.[INDEX].text","typeLabel":"string"},"url":{"type":"string","description":"Source URL of the content","isRequired":true,"uniqueKey":"retrieved.oneOf.0.items.[INDEX].url","typeLabel":"string"},"title":{"type":"string","description":"Title of the content or document","isRequired":true,"uniqueKey":"retrieved.oneOf.0.items.[INDEX].title","typeLabel":"string"},"timestamp":{"type":"integer","description":"Unix timestamp when the content was indexed","isRequired":true,"uniqueKey":"retrieved.oneOf.0.items.[INDEX].timestamp","typeLabel":"integer"},"file_type":{"type":"string","description":"The type of the source file","enum":["html","pdf","ppt","pptx","pptm","doc","docx","docm","xls","xlsx","xlsm","md","txt","jsonl","png","jpg","webp","heic","heif","wav","mp3","aiff","aac","m4a","ogg","flac","mp4","mpg","mov","avi","flv","webm","wmv","3gp","notion_page"],"isRequired":true,"uniqueKey":"retrieved.oneOf.0.items.[INDEX].file_type","typeLabel":"enum\u003cstring>"},"page_number":{"type":"integer","description":"Page number for paginated documents like PDFs. Set to 0 for sources without page numbers","default":0,"isRequired":true,"uniqueKey":"retrieved.oneOf.0.items.[INDEX].page_number","typeLabel":"integer"},"source_type":{"type":"string","description":"The type of the source","enum":["crawl","local_file","google_drive","github","notion"],"isRequired":true,"uniqueKey":"retrieved.oneOf.0.items.[INDEX].source_type","typeLabel":"enum\u003cstring>"},"source_id":{"type":"string","description":"Optional source ID for the original source. For crawl content, use this value with GET /sources/{source_id}/raw to download the stored crawl file content. For local_file content, use GET /sources/{source_id} for source details.\n","uniqueKey":"retrieved.oneOf.0.items.[INDEX].source_id","typeLabel":"string"},"keywords":{"type":"array","items":{"type":"string","uniqueKey":"retrieved.oneOf.0.items.[INDEX].keywords.items.[INDEX]","typeLabel":"string"},"uniqueKey":"retrieved.oneOf.0.items.[INDEX].keywords","typeLabel":"string[]"}},"uniqueKey":"retrieved.oneOf.0.items.[INDEX]","typeLabel":"object"},"uniqueKey":"retrieved.oneOf.0","typeLabel":"object[]"},{"type":"null","description":"Every knowledge-base chunk retrieved for this request and passed to the model as context (after authorization filtering), in retrieval order, whether or not the answer cited it. Null unless the request set `include_retrieved: true`; an empty array means nothing was retrieved.\n","items":{"type":"object","required":["id","text","url","title","timestamp","file_type","page_number","source_type"],"properties":{"id":{"type":"string","description":"Content ID"},"text":{"type":"string","description":"Content chunk from the source"},"url":{"type":"string","description":"Source URL of the content"},"title":{"type":"string","description":"Title of the content or document"},"timestamp":{"type":"integer","description":"Unix timestamp when the content was indexed"},"file_type":{"type":"string","description":"The type of the source file","enum":["html","pdf","ppt","pptx","pptm","doc","docx","docm","xls","xlsx","xlsm","md","txt","jsonl","png","jpg","webp","heic","heif","wav","mp3","aiff","aac","m4a","ogg","flac","mp4","mpg","mov","avi","flv","webm","wmv","3gp","notion_page"]},"page_number":{"type":"integer","description":"Page number for paginated documents like PDFs. Set to 0 for sources without page numbers","default":0},"source_type":{"type":"string","description":"The type of the source","enum":["crawl","local_file","google_drive","github","notion"]},"source_id":{"type":"string","description":"Optional source ID for the original source. For crawl content, use this value with GET /sources/{source_id}/raw to download the stored crawl file content. For local_file content, use GET /sources/{source_id} for source details.\n"},"keywords":{"type":"array","items":{"type":"string"}}}},"uniqueKey":"retrieved.oneOf.1","typeLabel":"null"}],"uniqueKey":"retrieved","typeLabel":"object[] | null"},"redacted_input":{"oneOf":[{"type":"object","description":"How the latest user message was redacted under the policy. Null unless the request set `include_redacted_input: true` with a `redaction_policy_id`.\n","required":["boundary","status"],"example":{"boundary":"completions_messages","status":"succeeded","masked_counts":{"N":1},"message":{"index":0,"content":"[氏名]さんと同行した件"}},"properties":{"boundary":{"type":"string","description":"A point where data leaves QAIP for an external provider. `initial_input`,\n`initial_input_system`, `initial_input_assistant`, `rag_query`, `rag_result`,\n`google_query`, `google_result`, `tool_result`, `external_table_result`,\n`x_query`, `xai_query`, `chartmetric_query` and `chartmetric_result` belong to\nAgent runs; `completions_messages`, `completions_messages_system`,\n`completions_messages_assistant`, `completions_search_query_context`,\n`completions_query` and `completions_docs` belong to `POST /completions`. The conversation history is split by role:\n`*_system` covers `system` messages, `*_assistant` covers `assistant` messages\n(including their tool call arguments), and `initial_input` /\n`completions_messages` cover every other role.\n","enum":["initial_input","initial_input_system","initial_input_assistant","rag_query","rag_result","google_query","google_result","tool_result","external_table_result","x_query","xai_query","chartmetric_query","chartmetric_result","completions_messages","completions_messages_system","completions_messages_assistant","completions_search_query_context","completions_query","completions_docs"],"isRequired":true,"uniqueKey":"redacted_input.oneOf.0.boundary","typeLabel":"enum\u003cstring>"},"status":{"type":"string","enum":["succeeded","skipped"],"description":"`succeeded` means the message was redacted. `skipped` means the policy excludes\nthis boundary (`skippedBoundaries`), so the message itself was not redacted; neither\n`masked_counts` nor `message` is returned then. Other boundaries, such as\n`completions_query` for the retrieval query, follow their own policy setting and are\nnot reported here.\n","isRequired":true,"uniqueKey":"redacted_input.oneOf.0.status","typeLabel":"enum\u003cstring>"},"masked_counts":{"oneOf":[{"type":"object","additionalProperties":{"type":"integer","uniqueKey":"redacted_input.oneOf.0.masked_counts.oneOf.0.additionalProperties","typeLabel":"integer"},"description":"Number of masks applied to the message text per category code (`N` name, `T`\nphone number, `E` email address, `A` address, `I` ID, `C` card number, `P`\npersonal information, `K` credential, `B` business confidential). One mask\ncounts once. Omitted or `null` when `status` is `skipped`.\n","uniqueKey":"redacted_input.oneOf.0.masked_counts.oneOf.0","typeLabel":"object"},{"type":"null","additionalProperties":{"type":"integer","uniqueKey":"redacted_input.oneOf.0.masked_counts.oneOf.1.additionalProperties","typeLabel":"integer"},"description":"Number of masks applied to the message text per category code (`N` name, `T`\nphone number, `E` email address, `A` address, `I` ID, `C` card number, `P`\npersonal information, `K` credential, `B` business confidential). One mask\ncounts once. Omitted or `null` when `status` is `skipped`.\n","uniqueKey":"redacted_input.oneOf.0.masked_counts.oneOf.1","typeLabel":"null"}],"uniqueKey":"redacted_input.oneOf.0.masked_counts","typeLabel":"object | null"},"message":{"oneOf":[{"type":"object","description":"The redacted message. Omitted or `null` when `status` is `skipped`.","required":["index"],"properties":{"index":{"type":"integer","description":"Position of the message in the conversation passed to the model. For a\n`POST /completions` continuation the server rebuilds the earlier turns from the\nstored history, so this counts those turns too.\n","isRequired":true,"uniqueKey":"redacted_input.oneOf.0.message.oneOf.0.index","typeLabel":"integer"},"id":{"oneOf":[{"type":"string","description":"Message id. Omitted or `null` for `POST /completions`.","uniqueKey":"redacted_input.oneOf.0.message.oneOf.0.id.oneOf.0","typeLabel":"string"},{"type":"null","description":"Message id. Omitted or `null` for `POST /completions`.","uniqueKey":"redacted_input.oneOf.0.message.oneOf.0.id.oneOf.1","typeLabel":"null"}],"uniqueKey":"redacted_input.oneOf.0.message.oneOf.0.id","typeLabel":"string | null"},"content":{"type":"string","description":"The redacted message text. For an Agent run with content parts, the text parts\nare joined. Omitted when the redacted text is too large to carry\nin one event (over 256 KiB encoded); `masked_counts` is still returned then.\n","uniqueKey":"redacted_input.oneOf.0.message.oneOf.0.content","typeLabel":"string"}},"additionalProperties":false,"uniqueKey":"redacted_input.oneOf.0.message.oneOf.0","typeLabel":"object"},{"type":"null","uniqueKey":"redacted_input.oneOf.0.message.oneOf.1","typeLabel":"null"}],"uniqueKey":"redacted_input.oneOf.0.message","typeLabel":"object | null"}},"additionalProperties":false,"uniqueKey":"redacted_input.oneOf.0","typeLabel":"object"},{"type":"null","uniqueKey":"redacted_input.oneOf.1","typeLabel":"null"}],"uniqueKey":"redacted_input","typeLabel":"object | null"},"search_query":{"oneOf":[{"type":"object","description":"The retrieval query actually used. Null unless the request set `search_query`.\n","required":["mode","query"],"properties":{"mode":{"type":"string","enum":["concat","rewrite"],"description":"How to build the retrieval query from the conversation. `concat` joins the `user`\nmessages with newlines. `rewrite` asks an LLM to turn the conversation (including the\n`assistant` answers) into one standalone query. It calls the LLM even when the target\nturns contain only one `user` message, so choose `concat` to search with the message as\nis.\n","isRequired":true,"uniqueKey":"search_query.oneOf.0.mode","typeLabel":"enum\u003cstring>"},"query":{"type":"string","description":"The query sent to retrieval. With a `redaction_policy_id` it is the redacted text,\nthe same as what was searched.\n","isRequired":true,"uniqueKey":"search_query.oneOf.0.query","typeLabel":"string"}},"additionalProperties":false,"uniqueKey":"search_query.oneOf.0","typeLabel":"object"},{"type":"null","uniqueKey":"search_query.oneOf.1","typeLabel":"null"}],"uniqueKey":"search_query","typeLabel":"object | null"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"created":1677649420,"choices":[{"index":0,"message":{"role":"assistant","content":"Hello! How can I help you today?"},"finish_reason":"stop","citations":[{"id":"\u003cstring>","text":"\u003cstring>","url":"\u003cstring>","title":"\u003cstring>","timestamp":123,"file_type":"html","page_number":0,"source_type":"crawl","source_id":"\u003cstring>","keywords":["\u003cstring>"]}],"web_citations":[{"url":"\u003cstring>","title":"\u003cstring>"}],"search_suggestion":"\u003cstring>","web_search_queries":["\u003cstring>"]}],"conversation_id":"550e8400-e29b-41d4-a716-446655440000","user_message_id":"f47ac10b-58cc-4372-a567-0e02b2c3d479","assistant_message_id":"9b2e6f1a-3c4d-4e5f-8a9b-0c1d2e3f4a5b","retrieved":[{"id":"\u003cstring>","text":"\u003cstring>","url":"\u003cstring>","title":"\u003cstring>","timestamp":123,"file_type":"html","page_number":0,"source_type":"crawl","source_id":"\u003cstring>","keywords":["\u003cstring>"]}],"redacted_input":{"boundary":"completions_messages","status":"succeeded","masked_counts":{"N":1},"message":{"index":0,"content":"[氏名]さんと同行した件"}},"search_query":{"mode":"concat","query":"\u003cstring>"}}}},"exampleType":"generated"},"text/plain":{"schema":{"type":"string","description":"In streaming mode, the server sends plain text responses, not JSON objects. Each chunk is just plain text (e.g., part of a message).\n","example":"Hello! How can I help you today?","uniqueKey":"","typeLabel":"string"},"examples":{"Example":{"title":"Example","value":"Hello! How can I help you today?"}},"exampleType":"generated"},"text/event-stream":{"schema":{"type":"string","description":"Returned when the request sends 'Accept: text/event-stream'. A Server-Sent Events stream of ag-ui protocol events, each encoded as a 'data: {json}' line (the JSON carries a 'type' discriminant, e.g. RUN_STARTED, TEXT_MESSAGE_CONTENT, CUSTOM, RUN_FINISHED). Body text arrives as TEXT_MESSAGE_CONTENT deltas; web grounding (web_citations / search_suggestion / web_search_queries) and internal KB citations arrive as CUSTOM events (name='grounding' / 'citations'); history ids arrive as a CUSTOM event (name='history_ids'). When the request sets `search_query`, the retrieval query arrives as a CUSTOM event (name='search_query', value `CompletionsSearchQueryResult`) before the body text. Generation failures terminate with RUN_ERROR, preserving code='INTERNAL_ERROR' and a safe message. The RUN_ERROR event also contains request_id (matching X-Request-ID), details (an object, currently empty), and retryable=false; generation, billing, or history persistence may have partially completed, so clients must not automatically retry. These fields extend the SSE event only; text/plain responses do not embed JSON errors. Agent run clients use the same event format through /agent/runs/{run_id}/events/stream.\n","example":"data: {\"type\":\"TEXT_MESSAGE_CONTENT\",\"messageId\":\"...\",\"delta\":\"Hello\"}","uniqueKey":"","typeLabel":"string"},"examples":{"Example":{"title":"Example","value":"data: {\"type\":\"TEXT_MESSAGE_CONTENT\",\"messageId\":\"...\",\"delta\":\"Hello\"}"}},"exampleType":"generated"}},"exampleType":"generated"},"834b5060-3096-402f-92d9-3d5c13acd737":{"description":"Bad Request - The request was malformed or invalid","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["message","type"],"properties":{"message":{"type":"string","description":"Human-readable error message","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","description":"Machine-readable error code","isRequired":true,"uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","description":"Stable public error category (for example unavailable), independent of the legacy error.type.","uniqueKey":"error.code","typeLabel":"string"},"request_id":{"type":"string","description":"Correlation ID shared with the response header and request logs.","uniqueKey":"error.request_id","typeLabel":"string"},"details":{"type":"object","additionalProperties":true,"description":"Structured error details without credentials or internal diagnostics. For REDACTION_UNAVAILABLE under online scheduling, reason is one of outside_hours, starting, unavailable, operator_paused. schedule contains timezone (Asia/Tokyo), weekdays (MON through SUN), usage_start_time and usage_end_time (HH:MM). Optional next_usage_start is an RFC 3339 timestamp.","uniqueKey":"error.details","typeLabel":"object"},"retryable":{"type":"boolean","description":"Whether the operation explicitly permits retry; status alone does not imply safe retry.","uniqueKey":"error.retryable","typeLabel":"boolean"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"\u003cstring>","code":"\u003cstring>","request_id":"\u003cstring>","details":{},"retryable":true}}}},"exampleType":"generated"}},"exampleType":"generated"},"0fe479a2-cdee-4d14-ae82-8b7dc0998e3d":{"description":"Unauthorized - Authentication failed","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["message","type"],"properties":{"message":{"type":"string","description":"Human-readable error message","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","description":"Machine-readable error code","isRequired":true,"uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","description":"Stable public error category (for example unavailable), independent of the legacy error.type.","uniqueKey":"error.code","typeLabel":"string"},"request_id":{"type":"string","description":"Correlation ID shared with the response header and request logs.","uniqueKey":"error.request_id","typeLabel":"string"},"details":{"type":"object","additionalProperties":true,"description":"Structured error details without credentials or internal diagnostics. For REDACTION_UNAVAILABLE under online scheduling, reason is one of outside_hours, starting, unavailable, operator_paused. schedule contains timezone (Asia/Tokyo), weekdays (MON through SUN), usage_start_time and usage_end_time (HH:MM). Optional next_usage_start is an RFC 3339 timestamp.","uniqueKey":"error.details","typeLabel":"object"},"retryable":{"type":"boolean","description":"Whether the operation explicitly permits retry; status alone does not imply safe retry.","uniqueKey":"error.retryable","typeLabel":"boolean"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"\u003cstring>","code":"\u003cstring>","request_id":"\u003cstring>","details":{},"retryable":true}}}},"exampleType":"generated"}},"exampleType":"generated"},"f41cb81f-ccd4-42f8-8558-b21600eb340d":{"description":"Forbidden - Insufficient permissions","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["message","type"],"properties":{"message":{"type":"string","description":"Human-readable error message","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","description":"Machine-readable error code","isRequired":true,"uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","description":"Stable public error category (for example unavailable), independent of the legacy error.type.","uniqueKey":"error.code","typeLabel":"string"},"request_id":{"type":"string","description":"Correlation ID shared with the response header and request logs.","uniqueKey":"error.request_id","typeLabel":"string"},"details":{"type":"object","additionalProperties":true,"description":"Structured error details without credentials or internal diagnostics. For REDACTION_UNAVAILABLE under online scheduling, reason is one of outside_hours, starting, unavailable, operator_paused. schedule contains timezone (Asia/Tokyo), weekdays (MON through SUN), usage_start_time and usage_end_time (HH:MM). Optional next_usage_start is an RFC 3339 timestamp.","uniqueKey":"error.details","typeLabel":"object"},"retryable":{"type":"boolean","description":"Whether the operation explicitly permits retry; status alone does not imply safe retry.","uniqueKey":"error.retryable","typeLabel":"boolean"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"\u003cstring>","code":"\u003cstring>","request_id":"\u003cstring>","details":{},"retryable":true}}}},"exampleType":"generated"}},"exampleType":"generated"},"16edb5d1-e249-4228-ac61-fdb34fc92022":{"description":"Unprocessable Entity. Returned when `redaction_policy_id` is unknown or\narchived (`error.type` = `UNKNOWN_REDACTION_POLICY`). No external provider is\ncalled and no conversation history is written.\n","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["message","type"],"properties":{"message":{"type":"string","description":"Human-readable error message","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","description":"Machine-readable error code","isRequired":true,"uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","description":"Stable public error category (for example unavailable), independent of the legacy error.type.","uniqueKey":"error.code","typeLabel":"string"},"request_id":{"type":"string","description":"Correlation ID shared with the response header and request logs.","uniqueKey":"error.request_id","typeLabel":"string"},"details":{"type":"object","additionalProperties":true,"description":"Structured error details without credentials or internal diagnostics. For REDACTION_UNAVAILABLE under online scheduling, reason is one of outside_hours, starting, unavailable, operator_paused. schedule contains timezone (Asia/Tokyo), weekdays (MON through SUN), usage_start_time and usage_end_time (HH:MM). Optional next_usage_start is an RFC 3339 timestamp.","uniqueKey":"error.details","typeLabel":"object"},"retryable":{"type":"boolean","description":"Whether the operation explicitly permits retry; status alone does not imply safe retry.","uniqueKey":"error.retryable","typeLabel":"boolean"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"\u003cstring>","code":"\u003cstring>","request_id":"\u003cstring>","details":{},"retryable":true}}}},"exampleType":"generated"}},"exampleType":"generated"},"866348d0-5964-4bea-a934-c8d7669a821f":{"description":"Too Many Requests - Rate limit exceeded","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["message","type"],"properties":{"message":{"type":"string","description":"Human-readable error message","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","description":"Machine-readable error code","isRequired":true,"uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","description":"Stable public error category (for example unavailable), independent of the legacy error.type.","uniqueKey":"error.code","typeLabel":"string"},"request_id":{"type":"string","description":"Correlation ID shared with the response header and request logs.","uniqueKey":"error.request_id","typeLabel":"string"},"details":{"type":"object","additionalProperties":true,"description":"Structured error details without credentials or internal diagnostics. For REDACTION_UNAVAILABLE under online scheduling, reason is one of outside_hours, starting, unavailable, operator_paused. schedule contains timezone (Asia/Tokyo), weekdays (MON through SUN), usage_start_time and usage_end_time (HH:MM). Optional next_usage_start is an RFC 3339 timestamp.","uniqueKey":"error.details","typeLabel":"object"},"retryable":{"type":"boolean","description":"Whether the operation explicitly permits retry; status alone does not imply safe retry.","uniqueKey":"error.retryable","typeLabel":"boolean"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"\u003cstring>","code":"\u003cstring>","request_id":"\u003cstring>","details":{},"retryable":true}}}},"exampleType":"generated"}},"exampleType":"generated"},"4c13462e-1621-483d-897b-1a9e400a32a6":{"description":"Internal Server Error","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["message","type"],"properties":{"message":{"type":"string","description":"Human-readable error message","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","description":"Machine-readable error code","isRequired":true,"uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","description":"Stable public error category (for example unavailable), independent of the legacy error.type.","uniqueKey":"error.code","typeLabel":"string"},"request_id":{"type":"string","description":"Correlation ID shared with the response header and request logs.","uniqueKey":"error.request_id","typeLabel":"string"},"details":{"type":"object","additionalProperties":true,"description":"Structured error details without credentials or internal diagnostics. For REDACTION_UNAVAILABLE under online scheduling, reason is one of outside_hours, starting, unavailable, operator_paused. schedule contains timezone (Asia/Tokyo), weekdays (MON through SUN), usage_start_time and usage_end_time (HH:MM). Optional next_usage_start is an RFC 3339 timestamp.","uniqueKey":"error.details","typeLabel":"object"},"retryable":{"type":"boolean","description":"Whether the operation explicitly permits retry; status alone does not imply safe retry.","uniqueKey":"error.retryable","typeLabel":"boolean"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"\u003cstring>","code":"\u003cstring>","request_id":"\u003cstring>","details":{},"retryable":true}}}},"exampleType":"generated"}},"exampleType":"generated"},"3463fe1a-3bb2-4966-913e-7a846c1faa23":{"description":"The application proxy could not obtain an upstream response before forwarding response headers. The error code is unavailable and retryable is false: upstream side effects may have completed, so a 502 alone does not make retrying safe. Check the operation's idempotency and recovery contract before retrying. A failure after streaming has started instead aborts the stream without appending this JSON body. CDN or load-balancer generated errors may have a different body and are not described by this response.","headers":{"X-Request-ID":{"description":"Correlation ID shared with the error body and application logs.","required":true,"schema":{"type":"string"},"example":"019d3200-0000-7000-8000-000000000001"}},"content":{"application/json":{"schema":{"type":"object","additionalProperties":false,"required":["error"],"properties":{"error":{"type":"object","additionalProperties":false,"required":["code","message","request_id","retryable","details"],"properties":{"code":{"type":"string","description":"Stable machine-readable error code","isRequired":true,"uniqueKey":"error.code","typeLabel":"string"},"message":{"type":"string","description":"Human-readable message; callers must not match it","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"request_id":{"type":"string","description":"Request ID shared with logs and traces","isRequired":true,"uniqueKey":"error.request_id","typeLabel":"string"},"retryable":{"type":"boolean","description":"Whether retrying after the indicated delay can succeed","isRequired":true,"uniqueKey":"error.retryable","typeLabel":"boolean"},"details":{"type":"object","description":"Structured, non-secret error details","additionalProperties":true,"isRequired":true,"uniqueKey":"error.details","typeLabel":"object"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"example":{"error":{"code":"unavailable","message":"The upstream service is unavailable.","request_id":"019d3200-0000-7000-8000-000000000001","retryable":false,"details":{}}},"examples":{"Example":{"title":"Example","value":{"error":{"code":"unavailable","message":"The upstream service is unavailable.","request_id":"019d3200-0000-7000-8000-000000000001","retryable":false,"details":{}}}}},"exampleType":"examples"}},"exampleType":"examples"},"faeedb04-e806-46ca-86bc-1e69c7279ebd":{"description":"Service Unavailable. Returned when `redaction_policy_id` is specified but the\nredactor is not configured or not reachable (`REDACTION_UNAVAILABLE`), or when\nredaction failed during a non-streaming request (`REDACTION_FAILED`). The\nrequest is never forwarded unmasked. Neither affects requests without\n`redaction_policy_id`.\nWith online scheduling, `REDACTION_UNAVAILABLE` has `error.code=unavailable`\nand `error.details.reason`: `outside_hours`, `starting`, `operator_paused`,\nor `unavailable`. `error.details.schedule` contains the actual `timezone`,\n`weekdays`, `usage_start_time`, and `usage_end_time`;\noptional `next_usage_start` is an RFC 3339 timestamp.\nThis is checked before new work is accepted; already accepted work continues.\nNeither the HTTP status nor the reason alone permits automatic retry.\n","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["message","type"],"properties":{"message":{"type":"string","description":"Human-readable error message","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","description":"Machine-readable error code","isRequired":true,"uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","description":"Stable public error category (for example unavailable), independent of the legacy error.type.","uniqueKey":"error.code","typeLabel":"string"},"request_id":{"type":"string","description":"Correlation ID shared with the response header and request logs.","uniqueKey":"error.request_id","typeLabel":"string"},"details":{"type":"object","additionalProperties":true,"description":"Structured error details without credentials or internal diagnostics. For REDACTION_UNAVAILABLE under online scheduling, reason is one of outside_hours, starting, unavailable, operator_paused. schedule contains timezone (Asia/Tokyo), weekdays (MON through SUN), usage_start_time and usage_end_time (HH:MM). Optional next_usage_start is an RFC 3339 timestamp.","uniqueKey":"error.details","typeLabel":"object"},"retryable":{"type":"boolean","description":"Whether the operation explicitly permits retry; status alone does not imply safe retry.","uniqueKey":"error.retryable","typeLabel":"boolean"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"\u003cstring>","code":"\u003cstring>","request_id":"\u003cstring>","details":{},"retryable":true}}}},"exampleType":"generated"}},"exampleType":"generated"}},"security":{"33fdc68c-db69-40e3-a097-d02b791db742":{"ApiKeyAuth":{"type":"apiKey","in":"header","name":"x-api-key","description":"API key for authentication","scopes":[],"schemeName":"ApiKeyAuth"}}},"servers":{"36e4ae26-2b94-4748-8d04-bb7c3466c01d":{"url":"https://developer.qaip.com/api/v1","description":"API base path"}},"schemas":{"580b0629-fd2b-49e2-982d-db0a42d0de6d":{"type":"object","description":"(reserved for future use) Filter group with nested structure. Supports combining filters with AND/OR logic.","properties":{"logic":{"type":"string","enum":["AND","OR"],"default":"OR","description":"Logical operator for combining filter conditions"},"filters":{"type":"array","description":"Filters within this group (combined using the logic operator)","items":{"type":"object","description":"Metadata filter for filtering search results by key/value pairs","required":["key","type","operator"],"properties":{"key":{"type":"string","description":"Metadata key","isRequired":true},"type":{"type":"string","enum":["string","integer","float","date","datetime","string_list","integer_list"],"description":"Data type of the metadata value. string_list / integer_list are valid only for metadata_filter (declared LanceDB array columns); the PostgreSQL-backed metadata / source_metadata / chunk_metadata filters reject them.\n","isRequired":true},"operator":{"type":"string","enum":["eq","ne","gt","gte","lt","lte","between","contains"],"default":"eq","description":"Comparison operator. contains tests array membership and is valid only for string_list / integer_list columns in metadata_filter; conversely those array types accept only contains.\n","isRequired":true},"val":{"description":"Metadata value (string or number). This is optional since min/max can be used for range queries."},"min":{"description":"Minimum value for range queries (string or number)"},"max":{"description":"Maximum value for range queries (string or number)"}}}},"groups":{"type":"array","description":"Nested subgroups","items":{"$circularRef":"580b0629-fd2b-49e2-982d-db0a42d0de6d"},"maxItems":10}}}},"processedSecurityOptions":[{"schemes":[{"scheme":{"type":"apiKey","in":"header","name":"x-api-key","description":"API key for authentication","scopes":[],"schemeName":"ApiKeyAuth"},"schema":{"title":"x-api-key","type":"string","description":"API key for authentication","isRequired":true,"typeLabel":"string","deprecated":false},"schemeName":"ApiKeyAuth","name":"x-api-key"}],"title":"ApiKeyAuth"}]},"originalFileLocation":"openapi.documented.yml"},"subdomain":"qaip","siteName":"QAIP Docs","title":"Generate LLM completion - QAIP Docs","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-11-05T13:04:15.986Z","originalFileLocation":"api-reference/completions/generate-llm-completion.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=\"Generates a completion based on the input messages and retrieval chunks. If the \u0026#x27;stream\u0026#x27; parameter is set to true, the response is streamed. By default the stream is plain text (text/plain). Send the request header \u0026#x27;Accept: text/event-stream\u0026#x27; to instead receive a Server-Sent Events (SSE) stream of ag-ui protocol events (delta text as TEXT_MESSAGE_CONTENT, grounding, citations and (opt-in) retrieved chunks as CUSTOM events, history ids and completion as RUN_STARTED / RUN_FINISHED). Required scope: inference:run\">\u003cmeta data-mint-head name=\"application-name\" content=\"QAIP Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/qaip/voqm0scHDaB6y0Aj/_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=\"/docs/mintlify-assets/_mintlify/favicons/qaip/voqm0scHDaB6y0Aj/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/qaip/voqm0scHDaB6y0Aj/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/qaip/voqm0scHDaB6y0Aj/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/qaip/voqm0scHDaB6y0Aj/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/docs/mintlify-assets/_mintlify/favicons/qaip/voqm0scHDaB6y0Aj/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/docs/mintlify-assets/_mintlify/favicons/qaip/voqm0scHDaB6y0Aj/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/docs/mintlify-assets/_mintlify/favicons/qaip/voqm0scHDaB6y0Aj/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/docs/mintlify-assets/_mintlify/favicons/qaip/voqm0scHDaB6y0Aj/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Generate LLM completion - QAIP Docs\">\u003cmeta data-mint-head property=\"og:description\" content=\"Generates a completion based on the input messages and retrieval chunks. If the \u0026#x27;stream\u0026#x27; parameter is set to true, the response is streamed. By default the stream is plain text (text/plain). Send the request header \u0026#x27;Accept: text/event-stream\u0026#x27; to instead receive a Server-Sent Events (SSE) stream of ag-ui protocol events (delta text as TEXT_MESSAGE_CONTENT, grounding, citations and (opt-in) retrieved chunks as CUSTOM events, history ids and completion as RUN_STARTED / RUN_FINISHED). Required scope: inference:run\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"QAIP Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://developer.qaip.com/api-reference/completions/generate-llm-completion\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://qaip.mintlify.site/docs/_mintlify/api/og/v2?division=References\u0026amp;title=Generate+LLM+completion\u0026amp;description=%3Cp%3E+Generates+a+completion+based+on+the+input+messages+and+retrieval+chunks.+If+the+%27stream%27+parameter+is+set+to+true%2C+the+response+is+streamed.+By+default+the+\u0026amp;theme=7715936a0403f6c796fc23ba\u0026amp;signature=86e54bc6f4d33ec47622115f6f2e9cd31f5f95500067cfbfe186d4e2581e7b55\">\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=\"Generate LLM completion - QAIP Docs\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Generates a completion based on the input messages and retrieval chunks. If the \u0026#x27;stream\u0026#x27; parameter is set to true, the response is streamed. By default the stream is plain text (text/plain). Send the request header \u0026#x27;Accept: text/event-stream\u0026#x27; to instead receive a Server-Sent Events (SSE) stream of ag-ui protocol events (delta text as TEXT_MESSAGE_CONTENT, grounding, citations and (opt-in) retrieved chunks as CUSTOM events, history ids and completion as RUN_STARTED / RUN_FINISHED). Required scope: inference:run\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://qaip.mintlify.site/docs/_mintlify/api/og/v2?division=References\u0026amp;title=Generate+LLM+completion\u0026amp;description=%3Cp%3E+Generates+a+completion+based+on+the+input+messages+and+retrieval+chunks.+If+the+%27stream%27+parameter+is+set+to+true%2C+the+response+is+streamed.+By+default+the+\u0026amp;theme=7715936a0403f6c796fc23ba\u0026amp;signature=86e54bc6f4d33ec47622115f6f2e9cd31f5f95500067cfbfe186d4e2581e7b55\">\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=\"/docs/mintlify-assets/_mintlify/favicons/qaip/voqm0scHDaB6y0Aj/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"QAIP Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#4E5766\">\u003clink data-mint-head rel=\"canonical\" href=\"https://developer.qaip.com/api-reference/completions/generate-llm-completion\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/docs/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/docs/api-reference/completions/generate-llm-completion.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://developer.qaip.com/#organization\",\"name\":\"QAIP Docs\",\"url\":\"https://developer.qaip.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/qaip/JULJYwLLg6eNrOP5/logo/light.png?fit=max\u0026auto=format\u0026n=JULJYwLLg6eNrOP5\u0026q=85\u0026s=8cdb9e6c41f4c5fa7aef814d60bff6b3\"}},{\"@type\":\"WebSite\",\"@id\":\"https://developer.qaip.com#website\",\"name\":\"QAIP Docs\",\"url\":\"https://developer.qaip.com\",\"publisher\":{\"@id\":\"https://developer.qaip.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://developer.qaip.com/api-reference/completions/generate-llm-completion#webpage\",\"url\":\"https://developer.qaip.com/api-reference/completions/generate-llm-completion\",\"name\":\"Generate LLM completion\",\"description\":\"Generates a completion based on the input messages and retrieval chunks. If the 'stream' parameter is set to true, the response is streamed. By default the stream is plain text (text/plain). Send the request header 'Accept: text/event-stream' to instead receive a Server-Sent Events (SSE) stream of ag-ui protocol events (delta text as TEXT_MESSAGE_CONTENT, grounding, citations and (opt-in) retrieved chunks as CUSTOM events, history ids and completion as RUN_STARTED / RUN_FINISHED). Required scope: inference:run\",\"dateModified\":\"2026-11-05T13:04:15.986Z\",\"isPartOf\":{\"@id\":\"https://developer.qaip.com#website\"},\"breadcrumb\":{\"@id\":\"https://developer.qaip.com/api-reference/completions/generate-llm-completion#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://developer.qaip.com/api-reference/completions/generate-llm-completion#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"References\",\"item\":\"https://developer.qaip.com/sdks\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Generate LLM completion\",\"item\":\"https://developer.qaip.com/api-reference/completions/generate-llm-completion\"}]},{\"@type\":[\"TechArticle\",\"APIReference\"],\"@id\":\"https://developer.qaip.com/api-reference/completions/generate-llm-completion#apireference\",\"headline\":\"Generate LLM completion\",\"name\":\"Generate LLM completion\",\"description\":\"Generates a completion based on the input messages and retrieval chunks. If the 'stream' parameter is set to true, the response is streamed. By default the stream is plain text (text/plain). Send the request header 'Accept: text/event-stream' to instead receive a Server-Sent Events (SSE) stream of ag-ui protocol events (delta text as TEXT_MESSAGE_CONTENT, grounding, citations and (opt-in) retrieved chunks as CUSTOM events, history ids and completion as RUN_STARTED / RUN_FINISHED). Required scope: inference:run\",\"url\":\"https://developer.qaip.com/api-reference/completions/generate-llm-completion\",\"mainEntityOfPage\":{\"@id\":\"https://developer.qaip.com/api-reference/completions/generate-llm-completion#webpage\"},\"dateModified\":\"2026-11-05T13:04:15.986Z\",\"publisher\":{\"@id\":\"https://developer.qaip.com/#organization\"},\"isPartOf\":{\"@id\":\"https://developer.qaip.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"QAIP Docs\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"QAIP Docs\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/docs/api-reference/completions/generate-llm-completion.md","siteName":"QAIP Docs","nav":{"global":{"anchors":[{"anchor":"Qiita","icon":"newspaper","href":"https://qiita.com/tags/qaip"},{"anchor":"Discord","icon":"discord","href":"https://discord.gg/2MdxWtYRue"}]},"tabs":[{"tab":"Documentation","pages":[{"title":"Documentation","href":"/introduction"}]},{"tab":"SDKs / API Reference","groups":[{"group":"References","pages":[{"title":"SDK イントロダクション","description":"QAIPはPython SDKを提供しています。SDKを利用することで、簡単にQAIPの機能をアプリケーションに組み込むことができます。","href":"/sdks"},{"title":"Generate LLM completion","deprecated":null,"version":null,"openapi":"/openapi.documented.yml post /completions","href":"/api-reference/completions/generate-llm-completion"},{"title":"Get content","description":"\u003cp> Get through indexed content. \u003c/p> \u003cp> Required scope: `knowledge:read` \u003c/p>\n","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /contents/{id}","href":"/api-reference/content/get-content"},{"title":"Search content","deprecated":null,"version":null,"openapi":"/openapi.documented.yml post /search","href":"/api-reference/search/search-content"},{"title":"Data extraction","deprecated":null,"version":null,"openapi":"/openapi.documented.yml post /extract","href":"/api-reference/extract/data-extraction"},{"title":"Create agent run","deprecated":null,"version":null,"openapi":"/openapi.documented.yml post /agent/runs","href":"/api-reference/agent/create-agent-run"},{"title":"Get agent run","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /agent/runs/{run_id}","href":"/api-reference/agent/get-agent-run"},{"title":"List agent run events","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /agent/runs/{run_id}/events","href":"/api-reference/agent/list-agent-run-events"},{"title":"Stream persisted agent run events","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /agent/runs/{run_id}/events/stream","href":"/api-reference/agent/stream-persisted-agent-run-events"},{"title":"Get agent run result","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /agent/runs/{run_id}/result","href":"/api-reference/agent/get-agent-run-result"},{"title":"Cancel agent run","deprecated":null,"version":null,"openapi":"/openapi.documented.yml post /agent/runs/{run_id}/cancel","href":"/api-reference/agent/cancel-agent-run"},{"title":"List agent conversation threads","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /agent/threads","href":"/api-reference/agent/list-agent-conversation-threads"},{"title":"Get an agent thread's run tree","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /agent/threads/{thread_id}","href":"/api-reference/agent/get-an-agent-threads-run-tree"},{"title":"List tags","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /tags","href":"/api-reference/tags/list-tags"},{"title":"Create tag source group","deprecated":null,"version":null,"openapi":"/openapi.documented.yml post /tag-source-groups","href":"/api-reference/tag-source-groups/create-tag-source-group"},{"title":"Delete tag source group","deprecated":null,"version":null,"openapi":"/openapi.documented.yml delete /tag-source-groups","href":"/api-reference/tag-source-groups/delete-tag-source-group"},{"title":"List sources","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /sources","href":"/api-reference/sources/list-sources"},{"title":"Get source details","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /sources/{source_id}","href":"/api-reference/sources/get-source-details"},{"title":"Download crawl source raw file","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /sources/{source_id}/raw","href":"/api-reference/sources/download-crawl-source-raw-file"},{"title":"Get source metadata","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /sources/{source_id}/metadata","href":"/api-reference/sources/get-source-metadata"},{"title":"Set source metadata","deprecated":null,"version":null,"openapi":"/openapi.documented.yml put /sources/{source_id}/metadata","href":"/api-reference/sources/set-source-metadata"},{"title":"Delete source metadata","deprecated":null,"version":null,"openapi":"/openapi.documented.yml delete /sources/{source_id}/metadata","href":"/api-reference/sources/delete-source-metadata"},{"title":"Batch set source metadata","deprecated":null,"version":null,"openapi":"/openapi.documented.yml post /sources/metadata/batch","href":"/api-reference/sources/batch-set-source-metadata"},{"title":"List local file groups","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /local-file-groups","href":"/api-reference/local-file-groups/list-local-file-groups"},{"title":"Create local file group","deprecated":null,"version":null,"openapi":"/openapi.documented.yml post /local-file-groups","href":"/api-reference/local-file-groups/create-local-file-group"},{"title":"Get local file group","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /local-file-groups/{id}","href":"/api-reference/local-file-groups/get-local-file-group"},{"title":"Start deletion of local file group","deprecated":null,"version":null,"openapi":"/openapi.documented.yml delete /local-file-groups/{id}","href":"/api-reference/local-file-groups/start-deletion-of-local-file-group"},{"title":"List Google Drive data sources","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /google-drives","href":"/api-reference/google-drives/list-google-drive-data-sources"},{"title":"Create a Google Drive data source","deprecated":null,"version":null,"openapi":"/openapi.documented.yml post /google-drives","href":"/api-reference/google-drives/create-a-google-drive-data-source"},{"title":"Get Google Drive data source details","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /google-drives/{id}","href":"/api-reference/google-drives/get-google-drive-data-source-details"},{"title":"Start deletion of Google Drive data source","deprecated":null,"version":null,"openapi":"/openapi.documented.yml delete /google-drives/{id}","href":"/api-reference/google-drives/start-deletion-of-google-drive-data-source"},{"title":"Get Google Drive setting","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /google-drive-settings/{id}","href":"/api-reference/google-drive-settings/get-google-drive-setting"},{"title":"Update Google Drive setting","deprecated":null,"version":null,"openapi":"/openapi.documented.yml put /google-drive-settings/{id}","href":"/api-reference/google-drive-settings/update-google-drive-setting"},{"title":"List web crawl data sources","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /crawls","href":"/api-reference/crawls/list-web-crawl-data-sources"},{"title":"Create a web crawl data source","deprecated":null,"version":null,"openapi":"/openapi.documented.yml post /crawls","href":"/api-reference/crawls/create-a-web-crawl-data-source"},{"title":"Get web crawl data source details","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /crawls/{id}","href":"/api-reference/crawls/get-web-crawl-data-source-details"},{"title":"Start deletion of web crawl data source","deprecated":null,"version":null,"openapi":"/openapi.documented.yml delete /crawls/{id}","href":"/api-reference/crawls/start-deletion-of-web-crawl-data-source"},{"title":"Get web crawl setting","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /crawl-settings/{id}","href":"/api-reference/crawl-settings/get-web-crawl-setting"},{"title":"Update web crawl setting","deprecated":null,"version":null,"openapi":"/openapi.documented.yml put /crawl-settings/{id}","href":"/api-reference/crawl-settings/update-web-crawl-setting"},{"title":"List GitHub data sources","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /githubs","href":"/api-reference/githubs/list-github-data-sources"},{"title":"Create a GitHub data source","deprecated":null,"version":null,"openapi":"/openapi.documented.yml post /githubs","href":"/api-reference/githubs/create-a-github-data-source"},{"title":"Get GitHub data source details","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /githubs/{id}","href":"/api-reference/githubs/get-github-data-source-details"},{"title":"Start deletion of GitHub data source","deprecated":null,"version":null,"openapi":"/openapi.documented.yml delete /githubs/{id}","href":"/api-reference/githubs/start-deletion-of-github-data-source"},{"title":"Get GitHub setting","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /github-settings/{id}","href":"/api-reference/github-settings/get-github-setting"},{"title":"Update GitHub setting","deprecated":null,"version":null,"openapi":"/openapi.documented.yml put /github-settings/{id}","href":"/api-reference/github-settings/update-github-setting"},{"title":"List Notion data sources","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /notions","href":"/api-reference/notions/list-notion-data-sources"},{"title":"Create a Notion data source","deprecated":null,"version":null,"openapi":"/openapi.documented.yml post /notions","href":"/api-reference/notions/create-a-notion-data-source"},{"title":"Get Notion data source details","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /notions/{id}","href":"/api-reference/notions/get-notion-data-source-details"},{"title":"Start deletion of Notion data source","deprecated":null,"version":null,"openapi":"/openapi.documented.yml delete /notions/{id}","href":"/api-reference/notions/start-deletion-of-notion-data-source"},{"title":"Get Notion setting","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /notion-settings/{id}","href":"/api-reference/notion-settings/get-notion-setting"},{"title":"Update Notion setting","deprecated":null,"version":null,"openapi":"/openapi.documented.yml put /notion-settings/{id}","href":"/api-reference/notion-settings/update-notion-setting"},{"title":"List secrets","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /secrets","href":"/api-reference/secrets/list-secrets"},{"title":"Create a secret","deprecated":null,"version":null,"openapi":"/openapi.documented.yml post /secrets","href":"/api-reference/secrets/create-a-secret"},{"title":"Get secret details","deprecated":null,"version":null,"openapi":"/openapi.documented.yml get /secrets/{secret_id}","href":"/api-reference/secrets/get-secret-details"},{"title":"Update a secret","deprecated":null,"version":null,"openapi":"/openapi.documented.yml put /secrets/{secret_id}","href":"/api-reference/secrets/update-a-secret"},{"title":"Delete a secret","deprecated":null,"version":null,"openapi":"/openapi.documented.yml delete /secrets/{secret_id}","href":"/api-reference/secrets/delete-a-secret"}]}]},{"tab":"Release Notes","pages":[{"title":"Release Notes","href":"/release-notes"}]}]},"basePath":"","title":"Generate LLM completion - QAIP Docs","deploymentId":"dpl_hSqyvJ4yQMj8zFViHgqnZFPm1xMv","buildId":"dpl_hSqyvJ4yQMj8zFViHgqnZFPm1xMv","dynamics":["c2aa737661","2b790eda92","b0f84f53ff","a9bb46feb3"],"chunks":["OpenApiReferenceProvider-dMMLDTIU.js","snippetPresets-QcUypRGT.js","utils-Br4-Z8t0.js","style-to-object-BY3JEAdk.js","utils-GmDMK9BG.js","v4-DIgz8zy6.js","addTypeLabelsToSchema-CImT44J1.js","conditional-requirements-CFM0id0Q.js","cloneDeep-De0u6l-0.js","_Uint8Array-DFGmIAJe.js","isObject-FP1Yky1u.js","ApiExamples-eUm2Ge_e.js","usePlaygroundInputsStore-BAilauYF.js","shallow-Z0k_fL-l.js","isEqual-BBOkDGmR.js","CodeSnippets-DORhwN-0.js","CodeSnippet-DV5Lj4DY.js","use-playground-group-access-CM_BSfmB.js","Page-_65rMYFd.js","api-description-markdown-nWfwWSzV.js","DynamicMarkdown-C-ybrQe5.js","SectionHeading-mysGfPJl.js","MethodPill-B29O_3ra.js","getPastedJson-Bnk6wgbx.js","Check2Icon-CWFt9B5t.js","axios-CsQoIw0U.js","Markdown-B2fY8v6N.js","AssistantPageLink-BsAGvIMN.js","dist-B4jGo7gd.js","lib-DMeTj1gb.js","lib-B8HbPgcC.js","katex-Dbtb6Wk7.js","html-void-elements-mCSPHezU.js","marked.esm-CZWythHk.js"]}