Given a list of messages, returns a model-generated response. Supports
streaming (SSE), tool use, and (on some models) vision input.
Streaming: set stream: true and stream_options: { include_usage: true }
to receive token-by-token deltas. The final chunk (the one with finish_reason
set) carries the usage block; you need it for accurate cost tracking.
Newer name for max_tokens; either is honored as-is. Non-streaming requests that set neither default to 2048 output tokens on non-reasoning models (the response then carries x-flexai-max-tokens-defaulted: 2048); reasoning models get no default and are bounded by the non-streaming time budget instead.
Accepted values differ by model. Models with a depth dial take the five gateway levels minimal, low, medium, high, max and return 400 for any other value, including none and xhigh: gpt-oss-120b/gpt-oss-20b accept low, medium, high only; DeepSeek-V4-Flash-0731 accepts all five (only minimal keeps it off; low, medium and high select the model's high effort level, with low and medium reported as x-flexai-adjusted-params: reasoning_effort=high; max selects its maximum). A word that is no effort level at all is a 400 on every reasoning model; a model with no reasoning at all drops the parameter and reports x-flexai-dropped-params. Models with a reasoning on/off switch but no depth dial (gemma-4-31b-it, gemma-4-26B-A4B-it, Qwen3.5-9B, Qwen3.6-27B-FP8, Qwen3.6-35B-A3B-FP8, GLM-4.5-Air-FP8, Qwen3-8B-FP8, NVIDIA-Nemotron-3.5-Lightning-30B-A3B) take all seven values: low, medium, high, xhigh and max turn reasoning on at the model's own depth and the response carries x-flexai-adjusted-params: reasoning_effort=on; none and minimal leave it off. An explicit thinking or chat_template_kwargs.enable_thinking switch wins over a contradicting effort, which is then reported in x-flexai-dropped-params. Reasoning is off by default on every model with an on/off switch; thinking {type: enabled} (or OpenRouter reasoning) turns it on everywhere.
On/off switch for reasoning on reasoning-capable models; takes precedence over reasoning_effort. disabled turns reasoning off even if reasoning_effort is sent; enabled alone turns it on at the model's default depth. Omitting both reasoning_effort and thinking leaves reasoning off on every switchable model. On a model that cannot stop reasoning (gpt-oss-120b, gpt-oss-20b and the always-thinking models) disabled is a 400 naming thinking, never a silent 200.
Show child attributes
Response
Successful response. When stream: true, body is an SSE stream of text/event-stream chunks.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"FlexAI Docs","colors":{"primary":"#002A9E","light":"#002A9E","dark":"#002A9E"},"logo":{"light":"https://mintcdn.com/flexai-51114f49/dNvzWOTcJQw0Ozyk/assets/images/flexai-light.svg?fit=max\u0026auto=format\u0026n=dNvzWOTcJQw0Ozyk\u0026q=85\u0026s=a324cec5ede5a3b89a69ed3a1e9f5f41","dark":"https://mintcdn.com/flexai-51114f49/dNvzWOTcJQw0Ozyk/assets/images/flexai-dark.svg?fit=max\u0026auto=format\u0026n=dNvzWOTcJQw0Ozyk\u0026q=85\u0026s=7d789e07f2962b8abda93cd143943cdb","href":"https://www.flex.ai"},"favicon":"https://mintcdn.com/flexai-51114f49/cHEM-4Sd-_gg6cip/favicon.ico?fit=max\u0026auto=format\u0026n=cHEM-4Sd-_gg6cip\u0026q=85\u0026s=05149d8deb9878767c2dec01b2ea7dfd","navbar":{"links":[{"href":"https://flex.ai/contact","label":"Talk to us"}],"primary":{"type":"button","label":"Get an API key","href":"https://platform.flex.ai/signup"}},"footer":{"socials":{"linkedin":"https://www.linkedin.com/company/flexaihq","github":"https://github.com/FlexAIHQ","slack":"https://join.slack.com/t/flexaicommunity/shared_invite/zt-3fqfcq9hj-Bv_Ehtyip0Y6fjS7gG5hHg"}},"seo":{"metatags":{"og:url":"https://docs.flex.ai","og:image":"/og-image.jpg","twitter:card":"summary_large_image","twitter:title":"FlexAI Documentation Website","twitter:description":"FlexAI Developer Documentation","twitter:creator":"@FlexAI__","twitter:site":"@FlexAI__","twitter:image":"/og-image.jpg","twitter:image:alt":"FlexAI Logo"},"indexing":"all"},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"flexai-51114f49","hasAudioNarration":false,"actualSubdomain":"flexai-51114f49","customDomains":["docs.flex.ai"],"gitSource":{"type":"github","owner":"flexaihq","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6ae4b663ab76b29675b25f84","collectionId":"19eadd31-e8e9-4de9-b48d-317422b94813","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6ae4b663ab76b29675b25f84"},"feedback":{"thumbs":true,"agentFeedback":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6ae4b663ab76b29675b25f84","clientVersion":"0.0.4044","searchFilterCounts":[{"language":"default","tag":"Platform","count":174},{"language":"default","tag":"CLI","count":98},{"language":"default","tag":"Reference","count":70},{"language":"default","tag":"Changelog","count":31},{"language":"default","tag":"Token Factory","count":29},{"language":"default","tag":"Blueprints","count":24},{"language":"default","tag":"Quick Start","count":16},{"language":"default","tag":"Platform Services","count":16},{"language":"default","tag":"Training \u0026 Fine-tuning","count":12},{"language":"default","tag":"training","count":12}]},"assistantConfig":{"enableAskAiButton":false,"enableStarterQuestions":false,"enableAskAiSearchBar":true},"basePath":"","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":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":".blueprint-cta{margin:56px 0 32px;padding:28px 32px;background:linear-gradient(135deg,#eef2ff 0,#e0e7ff 100%);border:1px solid #c7d2fe;border-radius:12px;font-size:15px;color:#1f2937}.blueprint-cta h3{margin:0 0 10px;font-size:18px;font-weight:600;color:#001b66}.blueprint-cta p{margin:0 0 20px;line-height:1.55;color:#4b5563}.blueprint-cta a.cta-primary{display:inline-block;background:#002a9e;color:#fff!important;font-weight:600;padding:10px 22px;border-radius:8px;margin-right:10px;text-decoration:none;box-shadow:0 4px 14px rgba(0,42,158,.25);transition:background .15s ease,box-shadow .15s ease,transform .15s ease}.blueprint-cta a.cta-primary:hover{background:#001b66;box-shadow:0 6px 20px rgba(0,42,158,.35);transform:translateY(-1px)}.blueprint-cta a.cta-secondary{display:inline-block;color:#002a9e!important;font-weight:500;padding:10px 20px;border-radius:8px;text-decoration:none;transition:background .15s ease,color .15s ease}.blueprint-cta a.cta-secondary:hover{background:#e0e7ff;color:#001b66!important;text-decoration:none}html.dark .blueprint-cta{background:linear-gradient(135deg,#001b66 0,#002a9e 100%);border-color:#3269ff;color:#e0e7ff}html.dark .blueprint-cta h3,html.dark .tf-hero .tf-tagline{color:#fff}html.dark .blueprint-cta p,html.dark .tf-hero .tf-sub{color:#c7d2fe}html.dark .blueprint-cta a.cta-primary{background:#3269ff;color:#fff!important;box-shadow:0 4px 14px rgba(50,105,255,.35)}html.dark .blueprint-cta a.cta-primary:hover{background:#5985ff;box-shadow:0 6px 20px rgba(50,105,255,.5)}html.dark .blueprint-cta a.cta-secondary{color:#c7d2fe!important}html.dark .blueprint-cta a.cta-secondary:hover{background:rgba(199,210,254,.1);color:#fff!important}header a[href=\"https://flex.ai/contact\"],nav a[href=\"https://flex.ai/contact\"]{padding:6px 14px;border-radius:8px;transition:background-color .15s ease,color .15s ease}header a[href=\"https://flex.ai/contact\"]:hover,nav a[href=\"https://flex.ai/contact\"]:hover{background-color:#e0e7ff;color:#001b66!important}html.dark header a[href=\"https://flex.ai/contact\"]:hover,html.dark nav a[href=\"https://flex.ai/contact\"]:hover{background-color:rgba(199,210,254,.12);color:#fff!important}.tf-hero{text-align:center;margin:8px 0 28px}.tf-hero .tf-tagline{font-size:1.8rem;line-height:1.25;font-weight:700;color:#001b66;margin:0 0 12px}.tf-hero .tf-sub{font-size:1.075rem;line-height:1.6;color:#4b5563;max-width:720px;margin:0 auto}.blueprint-cta.tf-cta-center{text-align:center;margin-top:0}"}],"page":{"pagePath":"api-reference/chat/create-a-chat-completion","slug":"/api-reference/chat/create-a-chat-completion","pageMetadata":{"title":"Create a chat completion","description":"Given a list of messages, returns a model-generated response. Supports\nstreaming (SSE), tool use, and (on some models) vision input.\n\n**Streaming:** set `stream: true` and `stream_options: { include_usage: true }`\nto receive token-by-token deltas. The final chunk (the one with `finish_reason`\nset) carries the `usage` block; you need it for accurate cost tracking.\n","deprecated":null,"version":null,"openapi":"/inference-api/openapi.yaml post /v1/chat/completions","href":"/api-reference/chat/create-a-chat-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 p: \"p\",\n strong: \"strong\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsxs(_Fragment, {\n children: [_jsx(_components.p, {\n children: \"Given a list of messages, returns a model-generated response. Supports\\nstreaming (SSE), tool use, and (on some models) vision input.\"\n }), \"\\n\", _jsxs(_components.p, {\n children: [_jsx(_components.strong, {\n children: \"Streaming:\"\n }), \" set \", _jsx(_components.code, {\n children: \"stream: true\"\n }), \" and \", _jsx(_components.code, {\n children: \"stream_options: { include_usage: true }\"\n }), \"\\nto receive token-by-token deltas. The final chunk (the one with \", _jsx(_components.code, {\n children: \"finish_reason\"\n }), \"\\nset) carries the \", _jsx(_components.code, {\n children: \"usage\"\n }), \" block; you need it for accurate cost tracking.\"]\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":"Create a chat completion","description":"Given a list of messages, returns a model-generated response. Supports\nstreaming (SSE), tool use, and (on some models) vision input.\n\n**Streaming:** set `stream: true` and `stream_options: { include_usage: true }`\nto receive token-by-token deltas. The final chunk (the one with `finish_reason`\nset) carries the `usage` block; you need it for accurate cost tracking.\n","deprecated":null,"version":null,"openapi":"/inference-api/openapi.yaml post /v1/chat/completions","href":"/api-reference/chat/create-a-chat-completion","autogeneratedByOpenApi":true}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[],"codeExamples":{}},"jsLinks":[],"openApiReferenceData":{"operation":{"tags":["Chat"],"summary":"Create a chat completion","description":"Given a list of messages, returns a model-generated response. Supports\nstreaming (SSE), tool use, and (on some models) vision input.\n\n**Streaming:** set `stream: true` and `stream_options: { include_usage: true }`\nto receive token-by-token deltas. The final chunk (the one with `finish_reason`\nset) carries the `usage` block; you need it for accurate cost tracking.\n","operationId":"createChatCompletion","requestBody":"4aa4c988-944c-4adc-b04c-9fdfb8624380","responses":{"200":"958c0c92-7552-4a1a-929c-dd43debe0b9d","400":"786e579a-3a5b-49b1-815f-61473eeff85e","401":"260f72a4-e876-4778-8afc-2e7c528f8217","402":"49cf2265-4087-4bf1-a4e3-9607a85cbe77","404":"c1e0076f-129d-403b-9af7-07f80111f011","429":"561593a0-5f20-4224-acdc-d083b75b4109","500":"e49f1405-34a7-4854-b0a2-b31d2c615684"},"method":"post","type":"path","servers":["191aecf8-6e70-46e3-b658-35a0f17988a1","17fe57b9-6458-4830-adeb-126d5d8bef0b"],"security":["26a4ba72-da88-48b8-bda8-195dc3ce6c9a"],"path":"/v1/chat/completions","baseUrlOptions":["https://api.flex.ai","https://eu.api.flex.ai"],"title":"Create a chat completion","codeSamples":[],"requiredOnlyExamples":false,"requestExampleType":"generated","responseExampleType":"generated"},"dependencies":{"parameters":{},"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model","messages"],"properties":{"model":{"type":"string","description":"Model id. See `GET /v1/models` for available models.","example":"Meta-Llama-3.1-8B-Instruct-FP8","isRequired":true,"uniqueKey":"model","typeLabel":"string"},"messages":{"type":"array","items":{"type":"object","required":["role"],"properties":{"role":{"type":"string","enum":["system","user","assistant","tool"],"isRequired":true,"uniqueKey":"messages.items.[INDEX].role","typeLabel":"enum\u003cstring>"},"content":{"oneOf":[{"type":"string","uniqueKey":"messages.items.[INDEX].content.oneOf.0","typeLabel":"string"},{"type":"array","items":{"type":"object","uniqueKey":"messages.items.[INDEX].content.oneOf.1.items.[INDEX]","typeLabel":"object"},"uniqueKey":"messages.items.[INDEX].content.oneOf.1","typeLabel":"object[]"}],"uniqueKey":"messages.items.[INDEX].content","typeLabel":"string | object[]"},"name":{"type":"string","uniqueKey":"messages.items.[INDEX].name","typeLabel":"string"},"tool_calls":{"type":"array","items":{"type":"object","uniqueKey":"messages.items.[INDEX].tool_calls.items.[INDEX]","typeLabel":"object"},"uniqueKey":"messages.items.[INDEX].tool_calls","typeLabel":"object[]"},"tool_call_id":{"type":"string","uniqueKey":"messages.items.[INDEX].tool_call_id","typeLabel":"string"}},"uniqueKey":"messages.items.[INDEX]","typeLabel":"object"},"isRequired":true,"uniqueKey":"messages","typeLabel":"object[]"},"stream":{"type":"boolean","default":false,"uniqueKey":"stream","typeLabel":"boolean"},"stream_options":{"type":"object","properties":{"include_usage":{"type":"boolean","description":"Required for per-request spend tracking when streaming.","uniqueKey":"stream_options.include_usage","typeLabel":"boolean"}},"uniqueKey":"stream_options","typeLabel":"object"},"temperature":{"type":"number","minimum":0,"maximum":2,"default":1,"uniqueKey":"temperature","typeLabel":"number"},"top_p":{"type":"number","minimum":0,"maximum":1,"uniqueKey":"top_p","typeLabel":"number"},"max_tokens":{"type":"integer","minimum":1,"uniqueKey":"max_tokens","typeLabel":"integer"},"tools":{"type":"array","items":{"type":"object","required":["type","function"],"properties":{"type":{"type":"string","enum":["function"],"isRequired":true,"uniqueKey":"tools.items.[INDEX].type","typeLabel":"enum\u003cstring>"},"function":{"type":"object","required":["name"],"properties":{"name":{"type":"string","isRequired":true,"uniqueKey":"tools.items.[INDEX].function.name","typeLabel":"string"},"description":{"type":"string","uniqueKey":"tools.items.[INDEX].function.description","typeLabel":"string"},"parameters":{"type":"object","uniqueKey":"tools.items.[INDEX].function.parameters","typeLabel":"object"}},"isRequired":true,"uniqueKey":"tools.items.[INDEX].function","typeLabel":"object"}},"uniqueKey":"tools.items.[INDEX]","typeLabel":"object"},"uniqueKey":"tools","typeLabel":"object[]"},"tool_choice":{"oneOf":[{"type":"string","enum":["none","auto","required"],"uniqueKey":"tool_choice.oneOf.0","typeLabel":"enum\u003cstring>"},{"type":"object","uniqueKey":"tool_choice.oneOf.1","typeLabel":"object"}],"uniqueKey":"tool_choice","typeLabel":"enum\u003cstring> | object"},"response_format":{"type":"object","properties":{"type":{"type":"string","enum":["text","json_object"],"uniqueKey":"response_format.type","typeLabel":"enum\u003cstring>"}},"uniqueKey":"response_format","typeLabel":"object"},"seed":{"type":"integer","uniqueKey":"seed","typeLabel":"integer"},"stop":{"oneOf":[{"type":"string","uniqueKey":"stop.oneOf.0","typeLabel":"string"},{"type":"array","items":{"type":"string","uniqueKey":"stop.oneOf.1.items.[INDEX]","typeLabel":"string"},"uniqueKey":"stop.oneOf.1","typeLabel":"string[]"}],"uniqueKey":"stop","typeLabel":"string | string[]"},"user":{"type":"string","uniqueKey":"user","typeLabel":"string"},"max_completion_tokens":{"type":"integer","minimum":1,"description":"Newer name for max_tokens; either is honored as-is. Non-streaming requests that set neither default to 2048 output tokens on non-reasoning models (the response then carries `x-flexai-max-tokens-defaulted: 2048`); reasoning models get no default and are bounded by the non-streaming time budget instead.","uniqueKey":"max_completion_tokens","typeLabel":"integer"},"reasoning_effort":{"type":"string","enum":["none","minimal","low","medium","high","xhigh","max"],"description":"Accepted values differ by model. Models with a depth dial take the five gateway levels minimal, low, medium, high, max and return 400 for any other value, including none and xhigh: gpt-oss-120b/gpt-oss-20b accept low, medium, high only; DeepSeek-V4-Flash-0731 accepts all five (only minimal keeps it off; low, medium and high select the model's high effort level, with low and medium reported as x-flexai-adjusted-params: reasoning_effort=high; max selects its maximum). A word that is no effort level at all is a 400 on every reasoning model; a model with no reasoning at all drops the parameter and reports x-flexai-dropped-params. Models with a reasoning on/off switch but no depth dial (gemma-4-31b-it, gemma-4-26B-A4B-it, Qwen3.5-9B, Qwen3.6-27B-FP8, Qwen3.6-35B-A3B-FP8, GLM-4.5-Air-FP8, Qwen3-8B-FP8, NVIDIA-Nemotron-3.5-Lightning-30B-A3B) take all seven values: low, medium, high, xhigh and max turn reasoning on at the model's own depth and the response carries x-flexai-adjusted-params: reasoning_effort=on; none and minimal leave it off. An explicit thinking or chat_template_kwargs.enable_thinking switch wins over a contradicting effort, which is then reported in x-flexai-dropped-params. Reasoning is off by default on every model with an on/off switch; thinking {type: enabled} (or OpenRouter reasoning) turns it on everywhere.","uniqueKey":"reasoning_effort","typeLabel":"enum\u003cstring>"},"thinking":{"type":"object","description":"On/off switch for reasoning on reasoning-capable models; takes precedence over reasoning_effort. disabled turns reasoning off even if reasoning_effort is sent; enabled alone turns it on at the model's default depth. Omitting both reasoning_effort and thinking leaves reasoning off on every switchable model. On a model that cannot stop reasoning (gpt-oss-120b, gpt-oss-20b and the always-thinking models) disabled is a 400 naming thinking, never a silent 200.","required":["type"],"properties":{"type":{"type":"string","enum":["enabled","disabled"],"isRequired":true,"uniqueKey":"thinking.type","typeLabel":"enum\u003cstring>"},"budget_tokens":{"type":"integer","minimum":1,"uniqueKey":"thinking.budget_tokens","typeLabel":"integer"}},"uniqueKey":"thinking","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"model":"Meta-Llama-3.1-8B-Instruct-FP8","messages":[{"content":"\u003cstring>","name":"\u003cstring>","tool_calls":[{}],"tool_call_id":"\u003cstring>"}],"stream":false,"stream_options":{"include_usage":true},"temperature":1,"top_p":0.5,"max_tokens":2,"tools":[{"type":"function","function":{"name":"\u003cstring>","description":"\u003cstring>","parameters":{}}}],"response_format":{},"seed":123,"stop":"\u003cstring>","user":"\u003cstring>","max_completion_tokens":2}}},"exampleType":"generated"}},"exampleType":"generated"},"responses":{"958c0c92-7552-4a1a-929c-dd43debe0b9d":{"description":"Successful response. When `stream: true`, body is an SSE stream of `text/event-stream` chunks.","headers":{"x-flexai-max-tokens-defaulted":{"schema":{"type":"integer"},"description":"Present only when the request set neither `max_tokens` nor\n`max_completion_tokens` and the gateway injected its default\noutput ceiling; the value is the ceiling applied. Only\nnon-streaming requests on non-reasoning models get the default,\nso a reasoning model never carries this header.\n"},"x-flexai-max-tokens-clamped":{"schema":{"type":"integer"},"description":"Present only when the gateway lowered the request's output\nceiling; the value is the ceiling applied. Reserved: no request\nis clamped today. A STREAMED response the gateway ended early\n(the model was repeating itself, or it reached the token\nceiling while repeating) is marked on its terminal chunks\ninstead, since its headers are already on the wire:\n`finish_reason: \"length\"` plus `flexai_stopped: \"degeneration\"`\nor `\"ceiling\"` (on `/v1/responses`, a `response.incomplete`\nevent with `incomplete_details.reason: \"max_output_tokens\"` and\nthe same field on the response object).\n"},"x-flexai-empty-at-length":{"schema":{"type":"string","enum":["true"]},"description":"Present only on a non-streaming response whose first choice\nended with `finish_reason: \"length\"` and no visible content, no\n`tool_calls` and no `function_call` — the model was cut off,\nnot incapable. Retry with a larger `max_tokens` or stream.\nNever set on a streamed response: its headers are sent before\nthe terminal chunk exists.\n"},"x-flexai-dropped-params":{"schema":{"type":"string"},"description":"Present only when the gateway removed a request parameter the\nmodel cannot use rather than rejecting the request; a\ncomma-separated list of the parameter names: `reasoning_effort`\non a model with no reasoning at all (or with an on/off switch\nthat the request also turned off), and `thinking` (or\n`reasoning`, the OpenRouter dialect) on a model with no reasoning\nswitch, and `parallel_tool_calls` when a `tool_choice: \"required\"`\nrequest sent `true` to a model the gateway bounds to one tool\ncall (`GLM-5.2`, `MiniMax-M2.7`,\n`NVIDIA-Nemotron-3.5-Lightning-30B-A3B`), where it is forced to\n`false`. A malformed value is a `400` on every model; only a\nwell-formed one the model cannot honour is dropped.\n"},"x-flexai-adjusted-params":{"schema":{"type":"string"},"description":"Present only when the gateway honoured a request parameter at\nthe nearest level the model supports rather than exactly; a\ncomma-separated list of `name=value`. Two cases today.\n`reasoning_effort=on` (`reasoning=on` when sent as OpenRouter's\n`reasoning.effort` or on `/v1/responses`): the model has a\nreasoning on/off switch but no depth setting, so any effort from\n`low` to `max` turns reasoning on at the model's own depth.\n`none` and `minimal` turn it off and carry no header.\n`reasoning_effort=high` (`reasoning=high` in the same spellings):\nthe model has two depths (`DeepSeek-V4-Flash-0731`), so a `low`\nor `medium` was rounded up to its high level rather than\nturning reasoning off, or a `minimal` was floored to it because\n`thinking: {\"type\": \"enabled\"}` was also sent. `high`, `max` and\na bare `minimal` carry no header.\n"},"x-flexai-sampling-defaulted":{"schema":{"type":"string"},"description":"Present only when the gateway filled one or more sampling fields\nfrom the model's catalog `sampling_defaults` because the request\nleft them unset (absent or `null`); a comma-separated list of the\nfield names, e.g. `top_p`. A value the caller sent, including\n`temperature: 0`, is never replaced. No header means nothing was\nfilled.\n"}},"content":{"application/json":{"schema":{"type":"object","required":["id","object","created","model","choices"],"properties":{"id":{"type":"string","isRequired":true,"uniqueKey":"id","typeLabel":"string"},"object":{"type":"string","enum":["chat.completion"],"isRequired":true,"uniqueKey":"object","typeLabel":"enum\u003cstring>"},"created":{"type":"integer","isRequired":true,"uniqueKey":"created","typeLabel":"integer"},"model":{"type":"string","isRequired":true,"uniqueKey":"model","typeLabel":"string"},"choices":{"type":"array","items":{"type":"object","required":["index","message","finish_reason"],"properties":{"index":{"type":"integer","isRequired":true,"uniqueKey":"choices.items.[INDEX].index","typeLabel":"integer"},"message":{"type":"object","properties":{"role":{"type":"string","uniqueKey":"choices.items.[INDEX].message.role","typeLabel":"string"},"content":{"oneOf":[{"type":"string","uniqueKey":"choices.items.[INDEX].message.content.oneOf.0","typeLabel":"string"},{"type":"null","uniqueKey":"choices.items.[INDEX].message.content.oneOf.1","typeLabel":"null"}],"uniqueKey":"choices.items.[INDEX].message.content","typeLabel":"string | null"},"reasoning_content":{"oneOf":[{"type":"string","description":"Reasoning text when reasoning is enabled on a reasoning-capable model; absent or null otherwise.","uniqueKey":"choices.items.[INDEX].message.reasoning_content.oneOf.0","typeLabel":"string"},{"type":"null","description":"Reasoning text when reasoning is enabled on a reasoning-capable model; absent or null otherwise.","uniqueKey":"choices.items.[INDEX].message.reasoning_content.oneOf.1","typeLabel":"null"}],"uniqueKey":"choices.items.[INDEX].message.reasoning_content","typeLabel":"string | null"},"tool_calls":{"type":"array","items":{"type":"object","uniqueKey":"choices.items.[INDEX].message.tool_calls.items.[INDEX]","typeLabel":"object"},"uniqueKey":"choices.items.[INDEX].message.tool_calls","typeLabel":"object[]"}},"isRequired":true,"uniqueKey":"choices.items.[INDEX].message","typeLabel":"object"},"finish_reason":{"type":"string","enum":["stop","length","tool_calls","content_filter"],"isRequired":true,"uniqueKey":"choices.items.[INDEX].finish_reason","typeLabel":"enum\u003cstring>"}},"uniqueKey":"choices.items.[INDEX]","typeLabel":"object"},"isRequired":true,"uniqueKey":"choices","typeLabel":"object[]"},"usage":{"type":"object","properties":{"prompt_tokens":{"type":"integer","uniqueKey":"usage.prompt_tokens","typeLabel":"integer"},"completion_tokens":{"type":"integer","uniqueKey":"usage.completion_tokens","typeLabel":"integer"},"total_tokens":{"type":"integer","uniqueKey":"usage.total_tokens","typeLabel":"integer"},"completion_tokens_details":{"type":"object","description":"Present when the model reasoned. reasoning_tokens are part of completion_tokens and billed as output; text_tokens is the visible-content remainder (live example: reasoning_tokens 78, text_tokens 2).","properties":{"reasoning_tokens":{"type":"integer","uniqueKey":"usage.completion_tokens_details.reasoning_tokens","typeLabel":"integer"},"text_tokens":{"type":"integer","uniqueKey":"usage.completion_tokens_details.text_tokens","typeLabel":"integer"}},"uniqueKey":"usage.completion_tokens_details","typeLabel":"object"},"cache_read_input_tokens":{"type":"integer","uniqueKey":"usage.cache_read_input_tokens","typeLabel":"integer"},"cache_creation_input_tokens":{"type":"integer","uniqueKey":"usage.cache_creation_input_tokens","typeLabel":"integer"},"cost":{"type":"number","description":"FlexAI extension. Our charge for this request in USD, rounded\nto 8 decimal places: what we bill you, not an upstream\nprovider's cost. Equals\n`cost_details.upstream_inference_prompt_cost` +\n`cost_details.upstream_inference_completions_cost`. Present on\nnon-streaming responses and on the final streamed chunk's\n`usage` (with `stream_options.include_usage`). Absent when the\nresponse cannot state the charge; the request is still billed,\nand `/v1/flex/usage/request/{request_id}` returns the recorded\nfigure. Rates are published at `GET /v1/pricing`.\n","uniqueKey":"usage.cost","typeLabel":"number"},"cost_details":{"type":"object","description":"FlexAI extension. The parts of `cost`. Field names follow\nOpenRouter's usage-accounting fields for compatibility; the\nvalues are still our charge to you, not a provider's cost.\n","additionalProperties":false,"properties":{"upstream_inference_prompt_cost":{"type":"number","description":"The input-token part of `cost`, in USD (cached-input rate for tokens served from the prompt cache).","uniqueKey":"usage.cost_details.upstream_inference_prompt_cost","typeLabel":"number"},"upstream_inference_completions_cost":{"type":"number","description":"The output-token part of `cost`, in USD, reasoning tokens included.","uniqueKey":"usage.cost_details.upstream_inference_completions_cost","typeLabel":"number"}},"uniqueKey":"usage.cost_details","typeLabel":"object"}},"uniqueKey":"usage","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"id":"\u003cstring>","object":"chat.completion","created":123,"model":"\u003cstring>","choices":[{"index":123,"message":{"role":"\u003cstring>","content":"\u003cstring>","reasoning_content":"\u003cstring>","tool_calls":[{}]},"finish_reason":"stop"}],"usage":{"prompt_tokens":123,"completion_tokens":123,"total_tokens":123,"completion_tokens_details":{"reasoning_tokens":123,"text_tokens":123},"cache_read_input_tokens":123,"cache_creation_input_tokens":123,"cost":123,"cost_details":{"upstream_inference_prompt_cost":123,"upstream_inference_completions_cost":123}}}}},"exampleType":"generated"},"text/event-stream":{"schema":{"type":"string","description":"SSE stream. Each event is `data: \u003cjson>`. Terminates with `data: [DONE]`.","uniqueKey":"","typeLabel":"string"},"examples":{"Example":{"title":"Example","value":"\u003cstring>"}},"exampleType":"generated"}},"exampleType":"generated"},"786e579a-3a5b-49b1-815f-61473eeff85e":{"description":"Invalid request — malformed body, unknown model, or schema violation.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["message","type"],"properties":{"message":{"type":"string","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","example":"invalid_request_error","isRequired":true,"uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","description":"Stable machine-readable code for the failure. Present on\nmost error paths; OMITTED on FastAPI default-validation\nbodies. Do not assume always present.\n","uniqueKey":"error.code","typeLabel":"string"},"doc_url":{"type":"string","format":"uri","description":"FlexAI extension. Link to the relevant dashboard / docs\npage for the failure mode (e.g. invalid key → /dashboard/keys).\nPresent on auth and quota errors.\n","uniqueKey":"error.doc_url","typeLabel":"string\u003curi>"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"invalid_request_error","code":"\u003cstring>","doc_url":"\u003cstring>"}}}},"exampleType":"generated"}},"exampleType":"generated"},"260f72a4-e876-4778-8afc-2e7c528f8217":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["message","type"],"properties":{"message":{"type":"string","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","example":"invalid_request_error","isRequired":true,"uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","description":"Stable machine-readable code for the failure. Present on\nmost error paths; OMITTED on FastAPI default-validation\nbodies. Do not assume always present.\n","uniqueKey":"error.code","typeLabel":"string"},"doc_url":{"type":"string","format":"uri","description":"FlexAI extension. Link to the relevant dashboard / docs\npage for the failure mode (e.g. invalid key → /dashboard/keys).\nPresent on auth and quota errors.\n","uniqueKey":"error.doc_url","typeLabel":"string\u003curi>"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"invalid_request_error","code":"\u003cstring>","doc_url":"\u003cstring>"}}}},"exampleType":"generated"}},"exampleType":"generated"},"49cf2265-4087-4bf1-a4e3-9607a85cbe77":{"description":"Key budget exhausted — add credit in the dashboard to continue.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["message","type"],"properties":{"message":{"type":"string","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","example":"invalid_request_error","isRequired":true,"uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","description":"Stable machine-readable code for the failure. Present on\nmost error paths; OMITTED on FastAPI default-validation\nbodies. Do not assume always present.\n","uniqueKey":"error.code","typeLabel":"string"},"doc_url":{"type":"string","format":"uri","description":"FlexAI extension. Link to the relevant dashboard / docs\npage for the failure mode (e.g. invalid key → /dashboard/keys).\nPresent on auth and quota errors.\n","uniqueKey":"error.doc_url","typeLabel":"string\u003curi>"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"invalid_request_error","code":"\u003cstring>","doc_url":"\u003cstring>"}}}},"exampleType":"generated"}},"exampleType":"generated"},"c1e0076f-129d-403b-9af7-07f80111f011":{"description":"Resource not found (e.g., unknown model or job id).","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["message","type"],"properties":{"message":{"type":"string","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","example":"invalid_request_error","isRequired":true,"uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","description":"Stable machine-readable code for the failure. Present on\nmost error paths; OMITTED on FastAPI default-validation\nbodies. Do not assume always present.\n","uniqueKey":"error.code","typeLabel":"string"},"doc_url":{"type":"string","format":"uri","description":"FlexAI extension. Link to the relevant dashboard / docs\npage for the failure mode (e.g. invalid key → /dashboard/keys).\nPresent on auth and quota errors.\n","uniqueKey":"error.doc_url","typeLabel":"string\u003curi>"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"invalid_request_error","code":"\u003cstring>","doc_url":"\u003cstring>"}}}},"exampleType":"generated"}},"exampleType":"generated"},"561593a0-5f20-4224-acdc-d083b75b4109":{"description":"Per-key RPM exceeded. Response includes `Retry-After` and\n`x-ratelimit-*` headers.\n","headers":{"Retry-After":{"schema":{"type":"integer"},"description":"Seconds until the next window."},"x-ratelimit-limit-requests":{"schema":{"type":"integer"}},"x-ratelimit-remaining-requests":{"schema":{"type":"integer"}},"x-ratelimit-reset-requests":{"schema":{"type":"integer"}}},"content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["message","type"],"properties":{"message":{"type":"string","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","example":"invalid_request_error","isRequired":true,"uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","description":"Stable machine-readable code for the failure. Present on\nmost error paths; OMITTED on FastAPI default-validation\nbodies. Do not assume always present.\n","uniqueKey":"error.code","typeLabel":"string"},"doc_url":{"type":"string","format":"uri","description":"FlexAI extension. Link to the relevant dashboard / docs\npage for the failure mode (e.g. invalid key → /dashboard/keys).\nPresent on auth and quota errors.\n","uniqueKey":"error.doc_url","typeLabel":"string\u003curi>"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"invalid_request_error","code":"\u003cstring>","doc_url":"\u003cstring>"}}}},"exampleType":"generated"}},"exampleType":"generated"},"e49f1405-34a7-4854-b0a2-b31d2c615684":{"description":"Upstream or gateway error. Safe to surface `error.message` to users.","content":{"application/json":{"schema":{"type":"object","required":["error"],"properties":{"error":{"type":"object","required":["message","type"],"properties":{"message":{"type":"string","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"},"type":{"type":"string","example":"invalid_request_error","isRequired":true,"uniqueKey":"error.type","typeLabel":"string"},"code":{"type":"string","description":"Stable machine-readable code for the failure. Present on\nmost error paths; OMITTED on FastAPI default-validation\nbodies. Do not assume always present.\n","uniqueKey":"error.code","typeLabel":"string"},"doc_url":{"type":"string","format":"uri","description":"FlexAI extension. Link to the relevant dashboard / docs\npage for the failure mode (e.g. invalid key → /dashboard/keys).\nPresent on auth and quota errors.\n","uniqueKey":"error.doc_url","typeLabel":"string\u003curi>"}},"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":{"message":"\u003cstring>","type":"invalid_request_error","code":"\u003cstring>","doc_url":"\u003cstring>"}}}},"exampleType":"generated"}},"exampleType":"generated"}},"security":{"26a4ba72-da88-48b8-bda8-195dc3ce6c9a":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"sk-xxxx","description":"Virtual API key. Create one from the\n[FlexAI dashboard](https://platform.flex.ai/dashboard/keys). Pass as\n`Authorization: Bearer sk-xxxx`.\n","scopes":[],"schemeName":"bearerAuth"}}},"servers":{"191aecf8-6e70-46e3-b658-35a0f17988a1":{"url":"https://api.flex.ai","description":"Production (US)"},"17fe57b9-6458-4830-adeb-126d5d8bef0b":{"url":"https://eu.api.flex.ai","description":"Production (EU)"}},"processedSecurityOptions":[{"schemes":[{"scheme":{"type":"http","scheme":"bearer","bearerFormat":"sk-xxxx","description":"Virtual API key. Create one from the\n[FlexAI dashboard](https://platform.flex.ai/dashboard/keys). Pass as\n`Authorization: Bearer sk-xxxx`.\n","scopes":[],"schemeName":"bearerAuth"},"schema":{"title":"Bearer Auth","type":"string","isRequired":true,"description":"Virtual API key. Create one from the\n[FlexAI dashboard](https://platform.flex.ai/dashboard/keys). Pass as\n`Authorization: Bearer sk-xxxx`.\n","format":"bearer","typeLabel":"string\u003cbearer>","deprecated":false},"schemeName":"bearerAuth","name":"Authorization"}],"title":"bearerAuth"}]},"originalFileLocation":"inference-api/openapi.yaml"},"subdomain":"flexai-51114f49","siteName":"FlexAI Docs","title":"Create a chat completion - FlexAI Docs","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-25T06:53:16.710Z","originalFileLocation":"api-reference/chat/create-a-chat-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=\"Given a list of messages, returns a model-generated response. Supports streaming (SSE), tool use, and (on some models) vision input. Streaming: set stream: true and stream_options: { include_usage: true } to receive token-by-token deltas. The final chunk (the one with finish_reason set) carries the usage block; you need it for accurate cost tracking.\">\u003cmeta data-mint-head name=\"application-name\" content=\"FlexAI Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/flexai-51114f49/SZFMqMGqk-xY4rT3/_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/flexai-51114f49/SZFMqMGqk-xY4rT3/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/flexai-51114f49/SZFMqMGqk-xY4rT3/_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/flexai-51114f49/SZFMqMGqk-xY4rT3/_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/flexai-51114f49/SZFMqMGqk-xY4rT3/_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/flexai-51114f49/SZFMqMGqk-xY4rT3/_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/flexai-51114f49/SZFMqMGqk-xY4rT3/_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/flexai-51114f49/SZFMqMGqk-xY4rT3/_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/flexai-51114f49/SZFMqMGqk-xY4rT3/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Create a chat completion - FlexAI Docs\">\u003cmeta data-mint-head property=\"og:description\" content=\"Given a list of messages, returns a model-generated response. Supports streaming (SSE), tool use, and (on some models) vision input. Streaming: set stream: true and stream_options: { include_usage: true } to receive token-by-token deltas. The final chunk (the one with finish_reason set) carries the usage block; you need it for accurate cost tracking.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"FlexAI Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.flex.ai/api-reference/chat/create-a-chat-completion\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://flexai-51114f49.mintlify.app/og-image.jpg\">\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=\"FlexAI Documentation Website\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"FlexAI Developer Documentation\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://flexai-51114f49.mintlify.app/og-image.jpg\">\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/flexai-51114f49/SZFMqMGqk-xY4rT3/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"FlexAI Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#002A9E\">\u003cmeta data-mint-head name=\"twitter:creator\" content=\"@FlexAI__\">\u003cmeta data-mint-head name=\"twitter:image:alt\" content=\"FlexAI Logo\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.flex.ai/api-reference/chat/create-a-chat-completion\">\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/create-a-chat-completion.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.flex.ai/#organization\",\"name\":\"FlexAI Docs\",\"url\":\"https://docs.flex.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/flexai-51114f49/dNvzWOTcJQw0Ozyk/assets/images/flexai-light.svg?fit=max\u0026auto=format\u0026n=dNvzWOTcJQw0Ozyk\u0026q=85\u0026s=a324cec5ede5a3b89a69ed3a1e9f5f41\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.flex.ai#website\",\"name\":\"FlexAI Docs\",\"url\":\"https://docs.flex.ai\",\"publisher\":{\"@id\":\"https://docs.flex.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.flex.ai/api-reference/chat/create-a-chat-completion#webpage\",\"url\":\"https://docs.flex.ai/api-reference/chat/create-a-chat-completion\",\"name\":\"Create a chat completion\",\"description\":\"Given a list of messages, returns a model-generated response. Supports streaming (SSE), tool use, and (on some models) vision input. Streaming: set stream: true and stream_options: { include_usage: true } to receive token-by-token deltas. The final chunk (the one with finish_reason set) carries the usage block; you need it for accurate cost tracking.\",\"dateModified\":\"2026-10-25T06:53:16.710Z\",\"isPartOf\":{\"@id\":\"https://docs.flex.ai#website\"},\"breadcrumb\":{\"@id\":\"https://docs.flex.ai/api-reference/chat/create-a-chat-completion#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.flex.ai/api-reference/chat/create-a-chat-completion#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"FlexAI Docs\",\"item\":\"https://docs.flex.ai\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Create a chat completion\",\"item\":\"https://docs.flex.ai/api-reference/chat/create-a-chat-completion\"}]},{\"@type\":[\"TechArticle\",\"APIReference\"],\"@id\":\"https://docs.flex.ai/api-reference/chat/create-a-chat-completion#apireference\",\"headline\":\"Create a chat completion\",\"name\":\"Create a chat completion\",\"description\":\"Given a list of messages, returns a model-generated response. Supports streaming (SSE), tool use, and (on some models) vision input. Streaming: set stream: true and stream_options: { include_usage: true } to receive token-by-token deltas. The final chunk (the one with finish_reason set) carries the usage block; you need it for accurate cost tracking.\",\"url\":\"https://docs.flex.ai/api-reference/chat/create-a-chat-completion\",\"mainEntityOfPage\":{\"@id\":\"https://docs.flex.ai/api-reference/chat/create-a-chat-completion#webpage\"},\"image\":\"https://docs.flex.ai/og-image.jpg\",\"dateModified\":\"2026-10-25T06:53:16.710Z\",\"publisher\":{\"@id\":\"https://docs.flex.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.flex.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"FlexAI Docs\",\"creator\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","siteName":"FlexAI Docs","nav":{"global":null,"tabs":[{"tab":"Token Factory","groups":[{"group":"Get Started","icon":"rocket","pages":[{"title":"Quickstart","href":"/inference-api/quickstart"}]},{"group":"Guides","icon":"book-open","pages":[{"title":"Streaming","href":"/inference-api/guides/streaming"},{"title":"Vision","href":"/inference-api/guides/vision"},{"title":"Tool Use","href":"/inference-api/guides/tool-use"},{"title":"Embeddings","href":"/inference-api/guides/embeddings"},{"title":"Image generation","href":"/inference-api/guides/images"},{"title":"Audio (TTS \u0026 transcription)","href":"/inference-api/guides/audio"},{"title":"Video generation","href":"/inference-api/guides/video"},{"title":"Rerank","href":"/inference-api/guides/rerank"},{"title":"Moderation","href":"/inference-api/guides/moderation"},{"title":"Model discovery","href":"/inference-api/guides/model-discovery"},{"title":"Batching","href":"/inference-api/guides/batch"},{"title":"Concurrency","href":"/inference-api/guides/concurrency"}]},{"group":"Agents","icon":"robot","pages":[{"title":"LangChain \u0026 LangGraph","href":"/inference-api/agents/langchain"}]},{"group":"Reference","icon":"book","pages":[{"title":"Errors","href":"/inference-api/reference/errors"},{"title":"Billing \u0026 Quotas","href":"/inference-api/reference/billing"},{"title":"Regions \u0026 Data Residency","href":"/inference-api/reference/regions"},{"title":"OpenAI Compatibility","href":"/inference-api/reference/openai-compatibility"},{"title":"Usage Policy","href":"/inference-api/reference/usage-policy"}]},{"group":"Changelog","pages":[{"title":"Changelog","description":"Model availability, pricing, and API changes for the FlexAI Token Factory.","href":"/changelog"}]},{"group":"Chat","pages":[{"title":"Create a chat completion","deprecated":null,"version":null,"openapi":"/inference-api/openapi.yaml post /v1/chat/completions","href":"/api-reference/chat/create-a-chat-completion"}]},{"group":"Completions","pages":[{"title":"Create a (legacy) text completion","description":"Prefer `/v1/chat/completions` for new integrations. `/v1/completions` is\nkept for compatibility with older OpenAI SDK callers.\n","deprecated":null,"version":null,"openapi":"/inference-api/openapi.yaml post /v1/completions","href":"/api-reference/completions/create-a-legacy-text-completion"}]},{"group":"Embeddings","pages":[{"title":"Create an embedding","deprecated":null,"version":null,"openapi":"/inference-api/openapi.yaml post /v1/embeddings","href":"/api-reference/embeddings/create-an-embedding"}]},{"group":"Models","pages":[{"title":"List available models","deprecated":null,"version":null,"openapi":"/inference-api/openapi.yaml get /v1/models","href":"/api-reference/models/list-available-models"},{"title":"Retrieve a model","deprecated":null,"version":null,"openapi":"/inference-api/openapi.yaml get /v1/models/{model}","href":"/api-reference/models/retrieve-a-model"},{"title":"List currently-effective per-model pricing","deprecated":null,"version":null,"openapi":"/inference-api/openapi.yaml get /v1/pricing","href":"/api-reference/models/list-currently-effective-per-model-pricing"}]},{"group":"Usage","pages":[{"title":"Programmatic spend for the calling key","deprecated":null,"version":null,"openapi":"/inference-api/openapi.yaml get /v1/flex/usage","href":"/api-reference/usage/programmatic-spend-for-the-calling-key"},{"title":"Usage and cost for a single request","deprecated":null,"version":null,"openapi":"/inference-api/openapi.yaml get /v1/flex/usage/request/{request_id}","href":"/api-reference/usage/usage-and-cost-for-a-single-request"},{"title":"Limits and remaining credit for the calling key","deprecated":null,"version":null,"openapi":"/inference-api/openapi.yaml get /v1/flex/key","href":"/api-reference/usage/limits-and-remaining-credit-for-the-calling-key"}]}]},{"tab":"Platform","pages":[{"title":"Platform","href":"/getting-started"}]}]},"basePath":"","title":"Create a chat completion - FlexAI Docs","buildId":"dpl_DeHjVRGfFnhYQwHnfC2pjeXXv8h9","deploymentId":"dpl_DeHjVRGfFnhYQwHnfC2pjeXXv8h9","dynamics":["c2aa737661","2b790eda92","b0f84f53ff","a9bb46feb3"],"chunks":["OpenApiReferenceProvider-CS552b7R.js","utils-DDTCYAF2.js","cloneDeep-izs3Hzxb.js","_Uint8Array-BVIqJ90l.js","isObjectLike-C8vmzPEN.js","isArray-Dcu1dQ5t.js","utils-De8ttokP.js","toString-BX-iyh8G.js","isSymbol-CSH9U2Gm.js","addUniqueKeysToSchema-DrwRDvAh.js","snippetPresets-DtAN0nWx.js","style-to-object-BY3JEAdk.js","v4-DIgz8zy6.js","ApiExamples-D5rWArI6.js","isEqual-BfaiBbcl.js","usePlaygroundInputsStore-O2i12wsz.js","shallow-DV8xABTt.js","getApiPlaygroundDisplay-DBZ0B5Jx.js","CodeSnippet-BVi0tPUX.js","CodeSnippets-CqASbIwY.js","Page-m07pfKpT.js","getPastedJson-DG9vsMS8.js","icon-CXzRSCr8.js","MethodPill-BdKVtEuX.js","DuplicateIcon-CZlmBrJI.js","createIcon-biFEUKPL.js","DynamicMarkdown-B54_zNBF.js","SectionHeading-DwwHK3Pt.js","axios-vUo_bRtp.js","Markdown-DfhCTwyA.js","clsx-xpJZXxdP.js","lib-DuNMoZ05.js","lib-B8HbPgcC.js","html-void-elements-mCSPHezU.js","dist-BTZUMDnx.js","katex-YMM-FMeD.js","marked.esm-CZWythHk.js","AssistantPageLink-DqdKa2R4.js"]}