Creates a model response for a conversation. This is the only inference endpoint:
every workload goes through it, distinguished by its scope.
Protégé parameters
string
Alias for the workload name, for clients where a body field is easier than a
header. Must match ^[a-z0-9_-]{1,63}$.x-protege-workload wins when both are present. Omitting both attributes the
call to the main workload of the default project. See
Projects and workloads.
string
default:"default"
Project slug, ^[a-z0-9-]{1,63}$. Provisioned on first use.
string
default:"main"
Workload name, ^[a-z0-9_-]{1,63}$. Provisioned on first use.
string
required
A model id from the catalog, for example deepseek-v4-flash. The
provider-pinned form (alibaba/qwen-flash) is accepted and normalises to the
same canonical id, which is what comes back in the response.
Standard parameters
array
required
The conversation so far. Each message has a role of system, user,
assistant or tool, and content.
boolean
default:"false"
Stream partial deltas as server-sent events. See Streaming.
integer
Upper bound on generated tokens. Output bills at several times input on most
models, so this is the highest-leverage cost control you have before any
routing decision.
number
default:"1"
Sampling temperature between 0 and 2. Lower is more deterministic.
number
default:"1"
Nucleus sampling. Set this or temperature, not both.
string | array
Up to four sequences that halt generation.
object
Set {"type": "json_object"} to constrain output to valid JSON. Schema-shaped
output is usually cheaper and more reliably scored than free text, which is why
it often clears an eval on a smaller model.
array
Tool definitions the model may call, in OpenAI function-calling format.
string | object
auto, none, required, or a specific tool.
integer
Best-effort determinism for repeated identical requests.
string
Stable end-user or tenant identifier. Use this to separate tenants within one
task rather than encoding the tenant into the task name.
object
Up to 16 string key-value pairs echoed back on the response. Useful for
carrying your own request or trace IDs.
Request
curl https://api.protege.sh/v1/chat/completions \ -H "Authorization: Bearer $PROTEGE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "task": "invoice_extraction", "model": "deepseek-v4-flash", "messages": [ {"role": "system", "content": "Return only the total, as a number."}, {"role": "user", "content": "INVOICE #4412 ... TOTAL 1,284.00 USD"} ], "max_tokens": 16, "response_format": {"type": "json_object"} }'
from openai import OpenAIclient = OpenAI( base_url="https://api.protege.sh/v1", api_key=os.environ["PROTEGE_API_KEY"],)resp = client.chat.completions.create( model="deepseek-v4-flash", messages=[ {"role": "system", "content": "Return only the total, as a number."}, {"role": "user", "content": invoice_text}, ], max_tokens=16, extra_body={"task": "invoice_extraction"},)
const resp = await client.chat.completions.create({ model: "deepseek-v4-flash", messages: [ { role: "system", content: "Return only the total, as a number." }, { role: "user", content: invoiceText }, ], max_tokens: 16, // @ts-expect-error - `task` is a Protégé extension task: "invoice_extraction",});
Response
string
Unique identifier for the completion.
string
Always chat.completion.
string
The model that actually served the call. With model: "deepseek-v4-flash" this is the
resolved route, not the string you sent.
array
Show properties
integer
object
role and content, plus tool_calls when tools were used.
string
stop, length, tool_calls or content_filter.
object
prompt_tokens, completion_tokens and total_tokens.
Response headers
Header
Meaning
x-protege-project
The project the call was attributed to
x-protege-workload
The workload it was attributed to
x-request-id
Identifier to quote when reporting a problem
x-ratelimit-limit-requests
Requests permitted in the window
x-ratelimit-remaining-requests
Requests left
x-ratelimit-reset-requests
Seconds until reset
Log the first two. Seeing default and main when you expected otherwise means
the header was dropped or task was stripped by your SDK.
Set stream: true to receive chat.completion.chunk events as server-sent
events, terminated by data: [DONE].
curl https://api.protege.sh/v1/chat/completions \ -H "Authorization: Bearer $PROTEGE_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "task": "support_draft_reply", "model": "deepseek-v4-flash", "stream": true, "messages": [{"role": "user", "content": "Draft a reply about a late order."}] }'
Scope and rate-limit headers arrive with the response head, before the first
chunk.
Errors
Status codes, error shapes, and which are worth retrying.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Protégé","description":"One OpenAI-compatible endpoint for every model call. Label each call with the task it belongs to, and Protégé routes it to the cheapest model that clears that task's eval.","colors":{"primary":"#cc4a0e","light":"#ffa477","dark":"#cc4a0e"},"favicon":"https://mintcdn.com/protege/aiqUBB9yS7MsdqS1/images/favicon.svg?fit=max\u0026auto=format\u0026n=aiqUBB9yS7MsdqS1\u0026q=85\u0026s=4530b4cd35b05e87529fbdc1d9098924","api":{"mdx":{"auth":{"method":"bearer"},"server":"https://api.protege.sh/v1"}},"navbar":{"links":[{"href":"https://protege.sh/benchmarks/","label":"Benchmarks"}],"primary":{"type":"button","label":"Book a call","href":"https://cal.com/tushar-ironlabs"}},"footer":{"links":[{"header":"Protégé","items":[{"label":"Home","href":"https://protege.sh/"},{"label":"Benchmarks","href":"https://protege.sh/benchmarks"},{"label":"Research","href":"https://protege.sh/research"}]},{"header":"Contact","items":[{"label":"tushar@protege.sh","href":"mailto:tushar@protege.sh"},{"label":"Book a call","href":"https://cal.com/tushar-ironlabs"}]}]},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"protege","hasAudioNarration":false,"actualSubdomain":"protege","customDomains":["docs.protege.sh"],"gitSource":{"type":"github","owner":"irona-ai","repo":"protege-docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":"","_id":"6b10fb819ffae5051c41ba63"},"entitlements":{},"buildId":"6aea225c26bfe900c3454405:success","clientVersion":"0.0.4448","searchFilterCounts":[{"language":"default","tag":"Documentation","count":11},{"language":"default","tag":"Concepts","count":4},{"language":"default","tag":"Get started","count":4},{"language":"default","tag":"API reference","count":3},{"language":"default","tag":"Reference","count":3},{"language":"default","tag":"Tutorials","count":3}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableContextualStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"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":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"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":[]}
{"page":{"pagePath":"api-reference/chat-completions","slug":"/api-reference/chat-completions","pageMetadata":{"title":"Create chat completion","description":"POST /v1/chat/completions. The OpenAI chat completions body, plus task.","api":"POST https://api.protege.sh/v1/chat/completions","href":"/api-reference/chat-completions"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"POST /v1/chat/completions. The OpenAI chat completions body, plus task.\"\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,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,p:`p`,pre:`pre`,span:`span`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,..._provideComponents(),...props.components},{Card,CodeBlock,CodeGroup,Expandable,Heading,ParamField,ResponseField,Table}=_components;if(!Card)_missingMdxReference(`Card`,true);if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!CodeGroup)_missingMdxReference(`CodeGroup`,true);if(!Expandable)_missingMdxReference(`Expandable`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!ParamField)_missingMdxReference(`ParamField`,true);if(!ResponseField)_missingMdxReference(`ResponseField`,true);if(!Table)_missingMdxReference(`Table`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`Creates a model response for a conversation. This is the only inference endpoint:\nevery workload goes through it, distinguished by its scope.`}),`\n`,_jsx(Heading,{level:`2`,id:`protégé-parameters`,children:`Protégé parameters`}),`\n`,_jsxs(ParamField,{body:`task`,type:`string`,id:`param-task`,children:[_jsxs(_components.p,{children:[`Alias for the workload name, for clients where a body field is easier than a\nheader. Must match `,_jsx(_components.code,{children:`^[a-z0-9_-]{1,63}$`}),`.`]}),_jsxs(_components.p,{children:[_jsx(_components.code,{children:`x-protege-workload`}),` wins when both are present. Omitting both attributes the\ncall to the `,_jsx(_components.code,{children:`main`}),` workload of the `,_jsx(_components.code,{children:`default`}),` project. See\n`,_jsx(_components.a,{href:`/concepts/projects-and-workloads`,children:`Projects and workloads`}),`.`]})]}),`\n`,_jsx(ParamField,{header:`x-protege-project`,type:`string`,default:`default`,id:`param-x-protege-project`,children:_jsxs(_components.p,{children:[`Project slug, `,_jsx(_components.code,{children:`^[a-z0-9-]{1,63}$`}),`. Provisioned on first use.`]})}),`\n`,_jsx(ParamField,{header:`x-protege-workload`,type:`string`,default:`main`,id:`param-x-protege-workload`,children:_jsxs(_components.p,{children:[`Workload name, `,_jsx(_components.code,{children:`^[a-z0-9_-]{1,63}$`}),`. Provisioned on first use.`]})}),`\n`,_jsx(ParamField,{body:`model`,type:`string`,required:true,id:`param-model`,children:_jsxs(_components.p,{children:[`A model id from the catalog, for example `,_jsx(_components.code,{children:`deepseek-v4-flash`}),`. The\nprovider-pinned form (`,_jsx(_components.code,{children:`alibaba/qwen-flash`}),`) is accepted and normalises to the\nsame canonical id, which is what comes back in the response.`]})}),`\n`,_jsx(Heading,{level:`2`,id:`standard-parameters`,children:`Standard parameters`}),`\n`,_jsx(ParamField,{body:`messages`,type:`array`,required:true,id:`param-messages`,children:_jsxs(_components.p,{children:[`The conversation so far. Each message has a `,_jsx(_components.code,{children:`role`}),` of `,_jsx(_components.code,{children:`system`}),`, `,_jsx(_components.code,{children:`user`}),`,\n`,_jsx(_components.code,{children:`assistant`}),` or `,_jsx(_components.code,{children:`tool`}),`, and `,_jsx(_components.code,{children:`content`}),`.`]})}),`\n`,_jsx(ParamField,{body:`stream`,type:`boolean`,default:`false`,id:`param-stream`,children:_jsxs(_components.p,{children:[`Stream partial deltas as server-sent events. See `,_jsx(_components.a,{href:`#streaming`,children:`Streaming`}),`.`]})}),`\n`,_jsx(ParamField,{body:`max_tokens`,type:`integer`,id:`param-max-tokens`,children:_jsx(_components.p,{children:`Upper bound on generated tokens. Output bills at several times input on most\nmodels, so this is the highest-leverage cost control you have before any\nrouting decision.`})}),`\n`,_jsx(ParamField,{body:`temperature`,type:`number`,default:`1`,id:`param-temperature`,children:_jsx(_components.p,{children:`Sampling temperature between 0 and 2. Lower is more deterministic.`})}),`\n`,_jsx(ParamField,{body:`top_p`,type:`number`,default:`1`,id:`param-top-p`,children:_jsxs(_components.p,{children:[`Nucleus sampling. Set this or `,_jsx(_components.code,{children:`temperature`}),`, not both.`]})}),`\n`,_jsx(ParamField,{body:`stop`,type:`string | array`,id:`param-stop`,children:_jsx(_components.p,{children:`Up to four sequences that halt generation.`})}),`\n`,_jsx(ParamField,{body:`response_format`,type:`object`,id:`param-response-format`,children:_jsxs(_components.p,{children:[`Set `,_jsx(_components.code,{children:`{\"type\": \"json_object\"}`}),` to constrain output to valid JSON. Schema-shaped\noutput is usually cheaper and more reliably scored than free text, which is why\nit often clears an eval on a smaller model.`]})}),`\n`,_jsx(ParamField,{body:`tools`,type:`array`,id:`param-tools`,children:_jsx(_components.p,{children:`Tool definitions the model may call, in OpenAI function-calling format.`})}),`\n`,_jsx(ParamField,{body:`tool_choice`,type:`string | object`,id:`param-tool-choice`,children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`auto`}),`, `,_jsx(_components.code,{children:`none`}),`, `,_jsx(_components.code,{children:`required`}),`, or a specific tool.`]})}),`\n`,_jsx(ParamField,{body:`seed`,type:`integer`,id:`param-seed`,children:_jsx(_components.p,{children:`Best-effort determinism for repeated identical requests.`})}),`\n`,_jsx(ParamField,{body:`user`,type:`string`,id:`param-user`,children:_jsx(_components.p,{children:`Stable end-user or tenant identifier. Use this to separate tenants within one\ntask rather than encoding the tenant into the task name.`})}),`\n`,_jsx(ParamField,{body:`metadata`,type:`object`,id:`param-metadata`,children:_jsx(_components.p,{children:`Up to 16 string key-value pairs echoed back on the response. Useful for\ncarrying your own request or trace IDs.`})}),`\n`,_jsx(Heading,{level:`2`,id:`request`,children:`Request`}),`\n`,_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`cURL`,numberOfLines:`13`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`13`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` https://api.protege.sh/v1/chat/completions`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Authorization: Bearer `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$PROTEGE_API_KEY`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Content-Type: application/json\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"task\": \"invoice_extraction\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"model\": \"deepseek-v4-flash\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"messages\": [`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` {\"role\": \"system\", \"content\": \"Return only the total, as a number.\"},`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` {\"role\": \"user\", \"content\": \"INVOICE #4412 ... TOTAL 1,284.00 USD\"}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ],`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"max_tokens\": 16,`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"response_format\": {\"type\": \"json_object\"}`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }'`})}),`\n`]})})}),_jsx(CodeBlock,{filename:`Python`,numberOfLines:`16`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`16`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` openai `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OpenAI`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`client `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OpenAI(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` base_url`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"https://api.protege.sh/v1\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` api_key`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`os.environ[`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"PROTEGE_API_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`],`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`resp `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` client.chat.completions.create(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"deepseek-v4-flash\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` messages`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"system\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Return only the total, as a number.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`},`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: invoice_text},`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ],`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` max_tokens`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`16`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` extra_body`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"task\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"invoice_extraction\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`},`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`]})})}),_jsx(CodeBlock,{filename:`TypeScript`,numberOfLines:`10`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`10`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` resp`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` client`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`chat`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`completions`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`create`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` model:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"deepseek-v4-flash\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` messages:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`role:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"system\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`content:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Return only the total, as a number.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` { `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`role:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`content:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` invoiceText`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ],`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` max_tokens:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 16`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:\" // @ts-expect-error - `task` is a Protégé extension\"})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` task:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"invoice_extraction\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`]})})})]}),`\n`,_jsx(Heading,{level:`2`,id:`response`,children:`Response`}),`\n`,_jsx(ResponseField,{name:`id`,type:`string`,id:`param-id`,children:_jsx(_components.p,{children:`Unique identifier for the completion.`})}),`\n`,_jsx(ResponseField,{name:`object`,type:`string`,id:`param-object`,children:_jsxs(_components.p,{children:[`Always `,_jsx(_components.code,{children:`chat.completion`}),`.`]})}),`\n`,_jsx(ResponseField,{name:`model`,type:`string`,id:`param-model-1`,children:_jsxs(_components.p,{children:[`The model that actually served the call. With `,_jsx(_components.code,{children:`model: \"deepseek-v4-flash\"`}),` this is the\nresolved route, not the string you sent.`]})}),`\n`,_jsx(ResponseField,{name:`choices`,type:`array`,id:`param-choices`,children:_jsxs(Expandable,{title:`properties`,children:[_jsx(ResponseField,{name:`index`,type:`integer`,id:`param-index`}),_jsx(ResponseField,{name:`message`,type:`object`,id:`param-message`,children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`role`}),` and `,_jsx(_components.code,{children:`content`}),`, plus `,_jsx(_components.code,{children:`tool_calls`}),` when tools were used.`]})}),_jsx(ResponseField,{name:`finish_reason`,type:`string`,id:`param-finish-reason`,children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`stop`}),`, `,_jsx(_components.code,{children:`length`}),`, `,_jsx(_components.code,{children:`tool_calls`}),` or `,_jsx(_components.code,{children:`content_filter`}),`.`]})})]})}),`\n`,_jsx(ResponseField,{name:`usage`,type:`object`,id:`param-usage`,children:_jsxs(_components.p,{children:[_jsx(_components.code,{children:`prompt_tokens`}),`, `,_jsx(_components.code,{children:`completion_tokens`}),` and `,_jsx(_components.code,{children:`total_tokens`}),`.`]})}),`\n`,_jsx(Heading,{level:`3`,id:`response-headers`,children:`Response headers`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Header`}),_jsx(_components.th,{children:`Meaning`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`x-protege-project`})}),_jsx(_components.td,{children:`The project the call was attributed to`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`x-protege-workload`})}),_jsx(_components.td,{children:`The workload it was attributed to`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`x-request-id`})}),_jsx(_components.td,{children:`Identifier to quote when reporting a problem`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`x-ratelimit-limit-requests`})}),_jsx(_components.td,{children:`Requests permitted in the window`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`x-ratelimit-remaining-requests`})}),_jsx(_components.td,{children:`Requests left`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:_jsx(_components.code,{children:`x-ratelimit-reset-requests`})}),_jsx(_components.td,{children:`Seconds until reset`})]})]})]}),`\n`,_jsxs(_components.p,{children:[`Log the first two. Seeing `,_jsx(_components.code,{children:`default`}),` and `,_jsx(_components.code,{children:`main`}),` when you expected otherwise means\nthe header was dropped or `,_jsx(_components.code,{children:`task`}),` was stripped by your SDK.`]}),`\n`,_jsx(CodeBlock,{filename:`Response`,numberOfLines:`14`,language:`json`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`json`,children:_jsxs(_components.code,{language:`json`,numberOfLines:`14`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`{`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"id\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"chatcmpl-9f2a7c31\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"object\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"chat.completion\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"created\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`1786531200`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"model\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"deepseek-v4-flash\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"choices\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: [`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"index\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"message\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: { `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"assistant\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"{`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`total`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\\"`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`: 1284.00}\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"finish_reason\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"stop\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ],`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:` \"usage\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: { `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"prompt_tokens\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`812`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"completion_tokens\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`11`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#116329`,\"--shiki-dark\":`#9CDCFE`},children:`\"total_tokens\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`823`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`}`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`streaming`,children:`Streaming`}),`\n`,_jsxs(_components.p,{children:[`Set `,_jsx(_components.code,{children:`stream: true`}),` to receive `,_jsx(_components.code,{children:`chat.completion.chunk`}),` events as server-sent\nevents, terminated by `,_jsx(_components.code,{children:`data: [DONE]`}),`.`]}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`9`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`9`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` https://api.protege.sh/v1/chat/completions`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Authorization: Bearer `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`$PROTEGE_API_KEY`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Content-Type: application/json\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"task\": \"support_draft_reply\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"model\": \"deepseek-v4-flash\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"stream\": true,`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"messages\": [{\"role\": \"user\", \"content\": \"Draft a reply about a late order.\"}]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }'`})}),`\n`]})})}),`\n`,_jsx(_components.p,{children:`Scope and rate-limit headers arrive with the response head, before the first\nchunk.`}),`\n`,_jsx(Card,{title:`Errors`,icon:`triangle-exclamation`,href:`/api-reference/errors`,children:_jsx(_components.p,{children:`Status codes, error shapes, and which are worth retrying.`})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"Create chat completion","description":"POST /v1/chat/completions. The OpenAI chat completions body, plus task.","api":"POST https://api.protege.sh/v1/chat/completions","href":"/api-reference/chat-completions"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Protégé parameters","slug":"protégé-parameters","depth":2,"children":[]},{"title":"Standard parameters","slug":"standard-parameters","depth":2,"children":[]},{"title":"Request","slug":"request","depth":2,"children":[]},{"title":"Response","slug":"response","depth":2,"children":[{"title":"Response headers","slug":"response-headers","depth":3,"children":[]}]},{"title":"Streaming","slug":"streaming","depth":2,"children":[]}],"codeExamples":{},"endpoint":{"title":"Create chat completion","path":"/v1/chat/completions","servers":[{"url":"https://api.protege.sh"}],"method":"post","request":{"security":[{"title":"Bearer Auth","parameters":{"header":{"Authorization":{"type":"http","scheme":"bearer","description":"Bearer authentication header of the form `Bearer \u003ctoken>`, where `\u003ctoken>` is your auth token."}},"query":{},"cookie":{}}}],"parameters":{"query":{},"header":{"x-protege-project":{"schema":[{"type":"string","description":"Project slug, `^[a-z0-9-]{1,63}$` . Provisioned on first use."}]},"x-protege-workload":{"schema":[{"type":"string","description":"Workload name, `^[a-z0-9_-]{1,63}$` . Provisioned on first use."}]}},"cookie":{},"path":{}},"body":{"application/json":{"schemaArray":[{"type":"object","properties":{"task":[{"type":"string","description":"Alias for the workload name, for clients where a body field is easier than a header. Must match `^[a-z0-9_-]{1,63}$` . `x-protege-workload` wins when both are present. Omitting both attributes the call to the `main` workload of the `default` project. See Projects and workloads ."}],"model":[{"type":"string","description":"A model id from the catalog, for example `deepseek-v4-flash` . The provider-pinned form ( `alibaba/qwen-flash` ) is accepted and normalises to the same canonical id, which is what comes back in the response.","required":true}],"messages":[{"type":"array","items":[{"type":"object","properties":{}}],"description":"The conversation so far. Each message has a `role` of `system` , `user` , `assistant` or `tool` , and `content` .","required":true}],"stream":[{"type":"boolean","description":"Stream partial deltas as server-sent events. See Streaming ."}],"max_tokens":[{"type":"integer","description":"Upper bound on generated tokens. Output bills at several times input on most models, so this is the highest-leverage cost control you have before any routing decision."}],"temperature":[{"type":"number","description":"Sampling temperature between 0 and 2. Lower is more deterministic."}],"top_p":[{"type":"number","description":"Nucleus sampling. Set this or `temperature` , not both."}],"stop":[{"type":"object","properties":{},"description":"Up to four sequences that halt generation."}],"response_format":[{"type":"object","properties":{},"description":"Set `{\"type\": \"json_object\"}` to constrain output to valid JSON. Schema-shaped output is usually cheaper and more reliably scored than free text, which is why it often clears an eval on a smaller model."}],"tools":[{"type":"array","items":[{"type":"object","properties":{}}],"description":"Tool definitions the model may call, in OpenAI function-calling format."}],"tool_choice":[{"type":"object","properties":{},"description":"`auto` , `none` , `required` , or a specific tool."}],"seed":[{"type":"integer","description":"Best-effort determinism for repeated identical requests."}],"user":[{"type":"string","description":"Stable end-user or tenant identifier. Use this to separate tenants within one task rather than encoding the tenant into the task name."}],"metadata":[{"type":"object","properties":{},"description":"Up to 16 string key-value pairs echoed back on the response. Useful for carrying your own request or trace IDs."}]}}],"examples":{"example":{"value":{"task":"\u003cstring>","model":"\u003cstring>","messages":[{}],"stream":true,"max_tokens":123,"temperature":123,"top_p":123,"stop":{},"response_format":{},"tools":[{}],"tool_choice":{},"seed":123,"user":"\u003cstring>","metadata":{}}}}}}},"response":{"200":{"application/json":{"schemaArray":[{"type":"object","properties":{"id":[{"type":"string","description":"Unique identifier for the completion."}],"object":[{"type":"string","description":"Always `chat.completion` ."}],"model":[{"type":"string","description":"The model that actually served the call. With `model: \"deepseek-v4-flash\"` this is the resolved route, not the string you sent."}],"choices":[{"type":"array","items":[{"type":"object","properties":{"index":[{"type":"integer"}],"message":[{"type":"object","properties":{},"description":"`role` and `content` , plus `tool_calls` when tools were used."}],"finish_reason":[{"type":"string","description":"`stop` , `length` , `tool_calls` or `content_filter` ."}]}}]}],"usage":[{"type":"object","properties":{},"description":"`prompt_tokens` , `completion_tokens` and `total_tokens` ."}]}}],"examples":{"example":{"value":{"id":"\u003cstring>","object":"\u003cstring>","model":"\u003cstring>","choices":[{"index":123,"message":{},"finish_reason":"\u003cstring>"}],"usage":{}}}}}}},"deprecated":false}},"jsLinks":[],"subdomain":"protege","siteName":"Protégé","title":"Create chat completion - Protégé","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-08-17T10:07:10.736Z","originalFileLocation":"api-reference/chat-completions.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=\"POST /v1/chat/completions. The OpenAI chat completions body, plus task.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Protégé\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/protege/HzEeMN_o-TJp0wVK/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/protege/HzEeMN_o-TJp0wVK/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/protege/HzEeMN_o-TJp0wVK/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/protege/HzEeMN_o-TJp0wVK/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/protege/HzEeMN_o-TJp0wVK/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/protege/HzEeMN_o-TJp0wVK/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/protege/HzEeMN_o-TJp0wVK/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/protege/HzEeMN_o-TJp0wVK/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/protege/HzEeMN_o-TJp0wVK/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Create chat completion - Protégé\">\u003cmeta data-mint-head property=\"og:description\" content=\"POST /v1/chat/completions. The OpenAI chat completions body, plus task.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Protégé\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.protege.sh/api-reference/chat-completions\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://protege.mintlify.site/_mintlify/api/og/v2?division=Reference\u0026amp;title=Create+chat+completion\u0026amp;description=POST+%2Fv1%2Fchat%2Fcompletions.+The+OpenAI+chat+completions+body%2C+plus+task.\u0026amp;theme=8d9c6c4f331b54511c9f032f\u0026amp;signature=ec28ff0da4ad53bc20ad581c59e50cd942bb12c62f43170e79eddb07401ac18b\">\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=\"Create chat completion - Protégé\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"POST /v1/chat/completions. The OpenAI chat completions body, plus task.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://protege.mintlify.site/_mintlify/api/og/v2?division=Reference\u0026amp;title=Create+chat+completion\u0026amp;description=POST+%2Fv1%2Fchat%2Fcompletions.+The+OpenAI+chat+completions+body%2C+plus+task.\u0026amp;theme=8d9c6c4f331b54511c9f032f\u0026amp;signature=ec28ff0da4ad53bc20ad581c59e50cd942bb12c62f43170e79eddb07401ac18b\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/protege/HzEeMN_o-TJp0wVK/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Protégé\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#cc4a0e\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.protege.sh/api-reference/chat-completions\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/api-reference/chat-completions.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.protege.sh/#organization\",\"name\":\"Protégé\",\"url\":\"https://docs.protege.sh\"},{\"@type\":\"WebSite\",\"@id\":\"https://docs.protege.sh#website\",\"name\":\"Protégé\",\"url\":\"https://docs.protege.sh\",\"publisher\":{\"@id\":\"https://docs.protege.sh/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.protege.sh/api-reference/chat-completions#webpage\",\"url\":\"https://docs.protege.sh/api-reference/chat-completions\",\"name\":\"Create chat completion\",\"description\":\"POST /v1/chat/completions. The OpenAI chat completions body, plus task.\",\"dateModified\":\"2026-08-17T10:07:10.736Z\",\"isPartOf\":{\"@id\":\"https://docs.protege.sh#website\"},\"breadcrumb\":{\"@id\":\"https://docs.protege.sh/api-reference/chat-completions#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.protege.sh/api-reference/chat-completions#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Reference\",\"item\":\"https://docs.protege.sh/api-reference/introduction\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Create chat completion\",\"item\":\"https://docs.protege.sh/api-reference/chat-completions\"}]},{\"@type\":[\"TechArticle\",\"APIReference\"],\"@id\":\"https://docs.protege.sh/api-reference/chat-completions#apireference\",\"headline\":\"Create chat completion\",\"name\":\"Create chat completion\",\"description\":\"POST /v1/chat/completions. The OpenAI chat completions body, plus task.\",\"url\":\"https://docs.protege.sh/api-reference/chat-completions\",\"mainEntityOfPage\":{\"@id\":\"https://docs.protege.sh/api-reference/chat-completions#webpage\"},\"dateModified\":\"2026-08-17T10:07:10.736Z\",\"publisher\":{\"@id\":\"https://docs.protege.sh/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.protege.sh#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Protégé\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Protégé\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/api-reference/chat-completions.md","siteName":"Protégé","nav":{"global":null,"tabs":[{"tab":"Documentation","pages":[{"title":"Documentation","href":""}]},{"tab":"API reference","groups":[{"group":"Reference","pages":[{"title":"Overview","description":"Base URL, authentication, and the conventions every endpoint shares.","href":"/api-reference/introduction"},{"title":"Create chat completion","api":"POST https://api.protege.sh/v1/chat/completions","href":"/api-reference/chat-completions"},{"title":"Errors","description":"Status codes, the error body, and which failures are worth retrying.","href":"/api-reference/errors"}]}]}]},"basePath":"","title":"Create chat completion - Protégé","deploymentId":"dpl_XLevHnGPjzxq9mbREha5Faad63Sp","buildId":"dpl_XLevHnGPjzxq9mbREha5Faad63Sp","dynamics":["c2aa737661","2b790eda92","b0f84f53ff"],"chunks":["OpenApiReferenceProvider-BD9G1WMi.js","snippetPresets-Bcqr8I2u.js","utils-BrYn4XiY.js","style-to-object-BY3JEAdk.js","utils-CYrCnchl.js","v4-DIgz8zy6.js","addTypeLabelsToSchema-CNFO66BS.js","conditional-requirements-CFM0id0Q.js","cloneDeep-BneVo7uA.js","_Uint8Array-n4RvRzp3.js","isObject-FP1Yky1u.js","ApiExamples-C1YMsTjy.js","usePlaygroundInputsStore-DayW4kZ9.js","shallow-DDCzdKmR.js","isEqual-CBVoazy8.js","CodeSnippets-CWandYY5.js","CodeSnippet-grFP6YU_.js","use-playground-group-access-BBqHUxQK.js","Page-DBPN_x5x.js","api-description-markdown-1J-AA_Kv.js","DynamicMarkdown-Dgh_e4rL.js","SectionHeading-BP6Np9Uh.js","MethodPill-4k_Ty_Xv.js","getPastedJson-CWUNKLcr.js","Check2Icon-Cs4FQb2J.js","axios-CsQoIw0U.js"]}