Create a chat completion with automatic session creation if enabled.Supports both streaming and non-streaming responses based on the stream parameter. Tool calling is supported but may work better with streaming enabled.
Headers
string
required
API key in format: Bearer sk-xxxxxx
Body
array
required
Array of message objects representing the conversation
Show Message Object
string
required
Role of the message author: system, user, assistant, or tool
string
Content of the message
string
Name of the author (optional)
array
Tool calls made by the assistant (for assistant messages)
string
ID of the tool call this message is responding to (for tool messages)
string
Model ID to use for completion (blockchain hex address or name)
number
default:1
Sampling temperature between 0 and 2. Higher values make output more random.
number
default:1
Nucleus sampling parameter. Alternative to temperature.
integer
default:1
Number of completions to generate
boolean
default:false
Whether to stream the response as server-sent events
string | array
Up to 4 sequences where the API will stop generating
integer
Maximum number of tokens to generate
number
default:0
Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far.
number
default:0
Number between -2.0 and 2.0. Positive values penalize new tokens based on their frequency in the text so far.
array
List of tools the model can call
string | object
Controls which tool is called by the model
string
Optional session ID to use. If not provided, uses the session associated with the API key.
Response
string
Unique completion ID
string
Always “chat.completion”
integer
Unix timestamp of completion creation
string
Model used for the completion
array
Array of completion choices
Show Choice Object
integer
Choice index
object
The generated message
string
Reason the generation stopped: stop, length, tool_calls, or content_filter
object
Token usage statistics
Show Usage Object
integer
Number of tokens in the prompt
integer
Number of tokens in the completion
integer
Total tokens used
The API is fully compatible with the OpenAI SDK. Simply change the base_url to point to the Morpheus Gateway.
Streaming responses return server-sent events. Set stream: true in your request to enable streaming.
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Morpheus Inference API","colors":{"primary":"#16A34A","light":"#07C983","dark":"#15803D"},"logo":{"light":"https://mintcdn.com/morpheus/B8wp8jG_KM5hucbL/logo/Morpheus-white-bg.png?fit=max\u0026auto=format\u0026n=B8wp8jG_KM5hucbL\u0026q=85\u0026s=31fb71bb6dbaeb1bc8c0b205bff83611","dark":"https://mintcdn.com/morpheus/B8wp8jG_KM5hucbL/logo/Morpheus-black-bg.png?fit=max\u0026auto=format\u0026n=B8wp8jG_KM5hucbL\u0026q=85\u0026s=5dabace81afbd3892078ad8d6a8f78e8"},"favicon":"https://mintcdn.com/morpheus/zkkoHtdILftrA39F/favicon.svg?fit=max\u0026auto=format\u0026n=zkkoHtdILftrA39F\u0026q=85\u0026s=527bbf46dec337b03d1521a2600ac73b","api":{"playground":{"proxy":false},"mdx":{"server":"https://api.mor.org"}},"navbar":{"links":[{"href":"mailto:devs@mor.org","label":"Support"}]},"footer":{"socials":{"x":"https://x.com/morpheusais","github":"https://github.com/morpheusais","linkedin":"https://linkedin.com/company/mintlify","discord":"https://discord.gg/kyVaxTHnvB"}},"integrations":{"ga4":{"measurementId":"G-D0TCTKQ051"}},"contextual":{"options":["copy","view","mcp","cursor","chatgpt","claude","perplexity","vscode"],"display":"header"},"metadata":{"timestamp":false},"styling":{"latex":false},"navigation":{"global":{"anchors":[{"anchor":"Blog","icon":"newspaper","href":"https://mor.org/blog"},{"anchor":"Community","icon":"discord","href":"https://discord.gg/kyVaxTHnvB"},{"anchor":"Announcements","icon":"x","href":"https://x.com/morpheusais"}]},"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"morpheus","hasAudioNarration":false,"actualSubdomain":"morpheus","customDomains":["apidocs.mor.org"],"gitSource":{"type":"github","owner":"morpheusais","repo":"api-gateway-docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"feedback":{"thumbs":false},"entitlements":{},"buildId":"6ae93ff280bb0649edf3a3b6:success","clientVersion":"0.0.4248","searchFilterCounts":[{"language":"default","tag":"Documentation","count":19},{"language":"default","tag":"API Reference","count":15},{"language":"default","tag":"Models","count":6},{"language":"default","tag":"Billing","count":5},{"language":"default","tag":"Getting Started","count":4},{"language":"default","tag":"Guides","count":4},{"language":"default","tag":"Utility","count":3},{"language":"default","tag":"Chat UIs","count":2},{"language":"default","tag":"AI Coding Tools","count":2},{"language":"default","tag":"Agent Frameworks","count":2}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","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":"workos-onboarding","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":"site-roles","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":"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":"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":"editor-metadata","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},{"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":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[]}
{"page":{"pagePath":"api-reference/chat/completions","slug":"/api-reference/chat/completions","pageMetadata":{"title":"Chat Completions","api":"POST /api/v1/chat/completions","description":"Create AI chat completions with OpenAI-compatible API","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: \"Create AI chat completions with OpenAI-compatible API\"\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={code:`code`,p:`p`,..._provideComponents(),...props.components},{Expandable,Heading,Note,ParamField,ResponseField,Tip}=_components;if(!Expandable)_missingMdxReference(`Expandable`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Note)_missingMdxReference(`Note`,true);if(!ParamField)_missingMdxReference(`ParamField`,true);if(!ResponseField)_missingMdxReference(`ResponseField`,true);if(!Tip)_missingMdxReference(`Tip`,true);return _jsxs(_Fragment,{children:[_jsx(_components.p,{children:`Create a chat completion with automatic session creation if enabled.`}),`\n`,_jsxs(_components.p,{children:[`Supports both streaming and non-streaming responses based on the `,_jsx(_components.code,{children:`stream`}),` parameter. Tool calling is supported but may work better with streaming enabled.`]}),`\n`,_jsx(Heading,{level:`3`,id:`headers`,children:`Headers`}),`\n`,_jsx(ParamField,{header:`Authorization`,type:`string`,required:true,id:`param-authorization`,children:_jsxs(_components.p,{children:[`API key in format: `,_jsx(_components.code,{children:`Bearer sk-xxxxxx`})]})}),`\n`,_jsx(Heading,{level:`3`,id:`body`,children:`Body`}),`\n`,_jsxs(ParamField,{body:`messages`,type:`array`,required:true,id:`param-messages`,children:[_jsx(_components.p,{children:`Array of message objects representing the conversation`}),_jsxs(Expandable,{title:`Message Object`,children:[_jsx(ParamField,{body:`role`,type:`string`,required:true,id:`param-role`,children:_jsxs(_components.p,{children:[`Role of the message author: `,_jsx(_components.code,{children:`system`}),`, `,_jsx(_components.code,{children:`user`}),`, `,_jsx(_components.code,{children:`assistant`}),`, or `,_jsx(_components.code,{children:`tool`})]})}),_jsx(ParamField,{body:`content`,type:`string`,id:`param-content`,children:_jsx(_components.p,{children:`Content of the message`})}),_jsx(ParamField,{body:`name`,type:`string`,id:`param-name`,children:_jsx(_components.p,{children:`Name of the author (optional)`})}),_jsx(ParamField,{body:`tool_calls`,type:`array`,id:`param-tool-calls`,children:_jsx(_components.p,{children:`Tool calls made by the assistant (for assistant messages)`})}),_jsx(ParamField,{body:`tool_call_id`,type:`string`,id:`param-tool-call-id`,children:_jsx(_components.p,{children:`ID of the tool call this message is responding to (for tool messages)`})})]})]}),`\n`,_jsx(ParamField,{body:`model`,type:`string`,id:`param-model`,children:_jsx(_components.p,{children:`Model ID to use for completion (blockchain hex address or name)`})}),`\n`,_jsx(ParamField,{body:`temperature`,type:`number`,default:1,id:`param-temperature`,children:_jsx(_components.p,{children:`Sampling temperature between 0 and 2. Higher values make output more random.`})}),`\n`,_jsx(ParamField,{body:`top_p`,type:`number`,default:1,id:`param-top-p`,children:_jsx(_components.p,{children:`Nucleus sampling parameter. Alternative to temperature.`})}),`\n`,_jsx(ParamField,{body:`n`,type:`integer`,default:1,id:`param-n`,children:_jsx(_components.p,{children:`Number of completions to generate`})}),`\n`,_jsx(ParamField,{body:`stream`,type:`boolean`,default:false,id:`param-stream`,children:_jsx(_components.p,{children:`Whether to stream the response as server-sent events`})}),`\n`,_jsx(ParamField,{body:`stop`,type:`string | array`,id:`param-stop`,children:_jsx(_components.p,{children:`Up to 4 sequences where the API will stop generating`})}),`\n`,_jsx(ParamField,{body:`max_tokens`,type:`integer`,id:`param-max-tokens`,children:_jsx(_components.p,{children:`Maximum number of tokens to generate`})}),`\n`,_jsx(ParamField,{body:`presence_penalty`,type:`number`,default:0,id:`param-presence-penalty`,children:_jsx(_components.p,{children:`Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far.`})}),`\n`,_jsx(ParamField,{body:`frequency_penalty`,type:`number`,default:0,id:`param-frequency-penalty`,children:_jsx(_components.p,{children:`Number between -2.0 and 2.0. Positive values penalize new tokens based on their frequency in the text so far.`})}),`\n`,_jsx(ParamField,{body:`tools`,type:`array`,id:`param-tools`,children:_jsx(_components.p,{children:`List of tools the model can call`})}),`\n`,_jsx(ParamField,{body:`tool_choice`,type:`string | object`,id:`param-tool-choice`,children:_jsx(_components.p,{children:`Controls which tool is called by the model`})}),`\n`,_jsx(ParamField,{body:`session_id`,type:`string`,id:`param-session-id`,children:_jsx(_components.p,{children:`Optional session ID to use. If not provided, uses the session associated with the API key.`})}),`\n`,_jsx(Heading,{level:`3`,id:`response`,children:`Response`}),`\n`,_jsx(ResponseField,{name:`id`,type:`string`,id:`param-id`,children:_jsx(_components.p,{children:`Unique completion ID`})}),`\n`,_jsx(ResponseField,{name:`object`,type:`string`,id:`param-object`,children:_jsx(_components.p,{children:`Always “chat.completion”`})}),`\n`,_jsx(ResponseField,{name:`created`,type:`integer`,id:`param-created`,children:_jsx(_components.p,{children:`Unix timestamp of completion creation`})}),`\n`,_jsx(ResponseField,{name:`model`,type:`string`,id:`param-model-1`,children:_jsx(_components.p,{children:`Model used for the completion`})}),`\n`,_jsxs(ResponseField,{name:`choices`,type:`array`,id:`param-choices`,children:[_jsx(_components.p,{children:`Array of completion choices`}),_jsxs(Expandable,{title:`Choice Object`,children:[_jsx(ResponseField,{name:`index`,type:`integer`,id:`param-index`,children:_jsx(_components.p,{children:`Choice index`})}),_jsx(ResponseField,{name:`message`,type:`object`,id:`param-message`,children:_jsx(_components.p,{children:`The generated message`})}),_jsx(ResponseField,{name:`finish_reason`,type:`string`,id:`param-finish-reason`,children:_jsxs(_components.p,{children:[`Reason the generation stopped: `,_jsx(_components.code,{children:`stop`}),`, `,_jsx(_components.code,{children:`length`}),`, `,_jsx(_components.code,{children:`tool_calls`}),`, or `,_jsx(_components.code,{children:`content_filter`})]})})]})]}),`\n`,_jsxs(ResponseField,{name:`usage`,type:`object`,id:`param-usage`,children:[_jsx(_components.p,{children:`Token usage statistics`}),_jsxs(Expandable,{title:`Usage Object`,children:[_jsx(ResponseField,{name:`prompt_tokens`,type:`integer`,id:`param-prompt-tokens`,children:_jsx(_components.p,{children:`Number of tokens in the prompt`})}),_jsx(ResponseField,{name:`completion_tokens`,type:`integer`,id:`param-completion-tokens`,children:_jsx(_components.p,{children:`Number of tokens in the completion`})}),_jsx(ResponseField,{name:`total_tokens`,type:`integer`,id:`param-total-tokens`,children:_jsx(_components.p,{children:`Total tokens used`})})]})]}),`\n`,_jsx(Tip,{children:_jsxs(_components.p,{children:[`The API is fully compatible with the OpenAI SDK. Simply change the `,_jsx(_components.code,{children:`base_url`}),` to point to the Morpheus Gateway.`]})}),`\n`,_jsx(Note,{children:_jsxs(_components.p,{children:[`Streaming responses return server-sent events. Set `,_jsx(_components.code,{children:`stream: true`}),` in your request to enable streaming.`]})})]})}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":"Chat Completions","api":"POST /api/v1/chat/completions","description":"Create AI chat completions with OpenAI-compatible API","href":"/api-reference/chat/completions"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Headers","slug":"headers","depth":3,"children":[]},{"title":"Body","slug":"body","depth":3,"children":[]},{"title":"Response","slug":"response","depth":3,"children":[]}],"codeExamples":{},"endpoint":{"title":"Chat Completions","path":"/api/v1/chat/completions","servers":[{"url":"https://api.mor.org"}],"method":"post","request":{"security":[],"parameters":{"query":{},"header":{"Authorization":{"schema":[{"type":"string","description":"API key in format: `Bearer sk-xxxxxx`","required":true}]}},"cookie":{},"path":{}},"body":{"application/json":{"schemaArray":[{"type":"object","properties":{"messages":[{"type":"array","items":[{"type":"object","properties":{"role":[{"type":"string","description":"Role of the message author: `system` , `user` , `assistant` , or `tool`","required":true}],"content":[{"type":"string","description":"Content of the message"}],"name":[{"type":"string","description":"Name of the author (optional)"}],"tool_calls":[{"type":"array","items":[{"type":"object","properties":{}}],"description":"Tool calls made by the assistant (for assistant messages)"}],"tool_call_id":[{"type":"string","description":"ID of the tool call this message is responding to (for tool messages)"}]}}],"description":"Array of message objects representing the conversation","required":true}],"model":[{"type":"string","description":"Model ID to use for completion (blockchain hex address or name)"}],"temperature":[{"type":"number","description":"Sampling temperature between 0 and 2. Higher values make output more random."}],"top_p":[{"type":"number","description":"Nucleus sampling parameter. Alternative to temperature."}],"n":[{"type":"integer","description":"Number of completions to generate"}],"stream":[{"type":"boolean","description":"Whether to stream the response as server-sent events"}],"stop":[{"type":"object","properties":{},"description":"Up to 4 sequences where the API will stop generating"}],"max_tokens":[{"type":"integer","description":"Maximum number of tokens to generate"}],"presence_penalty":[{"type":"number","description":"Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far."}],"frequency_penalty":[{"type":"number","description":"Number between -2.0 and 2.0. Positive values penalize new tokens based on their frequency in the text so far."}],"tools":[{"type":"array","items":[{"type":"object","properties":{}}],"description":"List of tools the model can call"}],"tool_choice":[{"type":"object","properties":{},"description":"Controls which tool is called by the model"}],"session_id":[{"type":"string","description":"Optional session ID to use. If not provided, uses the session associated with the API key."}]}}],"examples":{"example":{"value":{"messages":[{"role":"\u003cstring>","content":"\u003cstring>","name":"\u003cstring>","tool_calls":[{}],"tool_call_id":"\u003cstring>"}],"model":"\u003cstring>","temperature":123,"top_p":123,"n":123,"stream":true,"stop":{},"max_tokens":123,"presence_penalty":123,"frequency_penalty":123,"tools":[{}],"tool_choice":{},"session_id":"\u003cstring>"}}}}}},"response":{"200":{"application/json":{"schemaArray":[{"type":"object","properties":{"id":[{"type":"string","description":"Unique completion ID"}],"object":[{"type":"string","description":"Always “chat.completion”"}],"created":[{"type":"integer","description":"Unix timestamp of completion creation"}],"model":[{"type":"string","description":"Model used for the completion"}],"choices":[{"type":"array","items":[{"type":"object","properties":{"index":[{"type":"integer","description":"Choice index"}],"message":[{"type":"object","properties":{},"description":"The generated message"}],"finish_reason":[{"type":"string","description":"Reason the generation stopped: `stop` , `length` , `tool_calls` , or `content_filter`"}]}}],"description":"Array of completion choices"}],"usage":[{"type":"object","properties":{"prompt_tokens":[{"type":"integer","description":"Number of tokens in the prompt"}],"completion_tokens":[{"type":"integer","description":"Number of tokens in the completion"}],"total_tokens":[{"type":"integer","description":"Total tokens used"}]},"description":"Token usage statistics"}]}}],"examples":{"example":{"value":{"id":"\u003cstring>","object":"\u003cstring>","created":123,"model":"\u003cstring>","choices":[{"index":123,"message":{},"finish_reason":"\u003cstring>"}],"usage":{"prompt_tokens":123,"completion_tokens":123,"total_tokens":123}}}}}}},"deprecated":false}},"jsLinks":[],"subdomain":"morpheus","siteName":"Morpheus Inference API","title":"Chat Completions - Morpheus Inference API","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2025-10-25T17:21:09.841Z","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=\"Create AI chat completions with OpenAI-compatible API\">\u003cmeta data-mint-head name=\"application-name\" content=\"Morpheus Inference API\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/morpheus/kh1rgJ-Pt9Jw2R06/_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/morpheus/kh1rgJ-Pt9Jw2R06/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/morpheus/kh1rgJ-Pt9Jw2R06/_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/morpheus/kh1rgJ-Pt9Jw2R06/_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/morpheus/kh1rgJ-Pt9Jw2R06/_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/morpheus/kh1rgJ-Pt9Jw2R06/_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/morpheus/kh1rgJ-Pt9Jw2R06/_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/morpheus/kh1rgJ-Pt9Jw2R06/_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/morpheus/kh1rgJ-Pt9Jw2R06/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Chat Completions - Morpheus Inference API\">\u003cmeta data-mint-head property=\"og:description\" content=\"Create AI chat completions with OpenAI-compatible API\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Morpheus Inference API\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://apidocs.mor.org/api-reference/chat/completions\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://morpheus.mintlify.site/_mintlify/api/og/v2?division=Chat\u0026amp;title=Chat+Completions\u0026amp;description=Create+AI+chat+completions+with+OpenAI-compatible+API\u0026amp;theme=86ed7a09bc1f3cc3ab3407c9\u0026amp;signature=bdc9d554b3ec7d82bde57c20e91805ad4edd514c3743fe7b009ccabc5c8d6923\">\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=\"Chat Completions - Morpheus Inference API\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Create AI chat completions with OpenAI-compatible API\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://morpheus.mintlify.site/_mintlify/api/og/v2?division=Chat\u0026amp;title=Chat+Completions\u0026amp;description=Create+AI+chat+completions+with+OpenAI-compatible+API\u0026amp;theme=86ed7a09bc1f3cc3ab3407c9\u0026amp;signature=bdc9d554b3ec7d82bde57c20e91805ad4edd514c3743fe7b009ccabc5c8d6923\">\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/morpheus/kh1rgJ-Pt9Jw2R06/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Morpheus Inference API\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#16A34A\">\u003clink data-mint-head rel=\"canonical\" href=\"https://apidocs.mor.org/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://apidocs.mor.org/#organization\",\"name\":\"Morpheus Inference API\",\"url\":\"https://apidocs.mor.org\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/morpheus/B8wp8jG_KM5hucbL/logo/Morpheus-white-bg.png?fit=max\u0026auto=format\u0026n=B8wp8jG_KM5hucbL\u0026q=85\u0026s=31fb71bb6dbaeb1bc8c0b205bff83611\"}},{\"@type\":\"WebSite\",\"@id\":\"https://apidocs.mor.org#website\",\"name\":\"Morpheus Inference API\",\"url\":\"https://apidocs.mor.org\",\"publisher\":{\"@id\":\"https://apidocs.mor.org/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://apidocs.mor.org/api-reference/chat/completions#webpage\",\"url\":\"https://apidocs.mor.org/api-reference/chat/completions\",\"name\":\"Chat Completions\",\"description\":\"Create AI chat completions with OpenAI-compatible API\",\"dateModified\":\"2025-10-25T17:21:09.841Z\",\"isPartOf\":{\"@id\":\"https://apidocs.mor.org#website\"},\"breadcrumb\":{\"@id\":\"https://apidocs.mor.org/api-reference/chat/completions#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://apidocs.mor.org/api-reference/chat/completions#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Morpheus Inference API\",\"item\":\"https://apidocs.mor.org\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Chat Completions\",\"item\":\"https://apidocs.mor.org/api-reference/chat/completions\"}]},{\"@type\":[\"TechArticle\",\"APIReference\"],\"@id\":\"https://apidocs.mor.org/api-reference/chat/completions#apireference\",\"headline\":\"Chat Completions\",\"name\":\"Chat Completions\",\"description\":\"Create AI chat completions with OpenAI-compatible API\",\"url\":\"https://apidocs.mor.org/api-reference/chat/completions\",\"mainEntityOfPage\":{\"@id\":\"https://apidocs.mor.org/api-reference/chat/completions#webpage\"},\"dateModified\":\"2025-10-25T17:21:09.841Z\",\"publisher\":{\"@id\":\"https://apidocs.mor.org/#organization\"},\"isPartOf\":{\"@id\":\"https://apidocs.mor.org#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Morpheus Inference API\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Morpheus Inference API\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/api-reference/chat/completions.md","siteName":"Morpheus Inference API","nav":{"global":{"anchors":[{"anchor":"Blog","icon":"newspaper","href":"https://mor.org/blog"},{"anchor":"Community","icon":"discord","href":"https://discord.gg/kyVaxTHnvB"},{"anchor":"Announcements","icon":"x","href":"https://x.com/morpheusais"}]},"tabs":[{"tab":"Documentation","pages":[{"title":"Documentation","href":"/documentation/getting-started/what-is-api-gateway"}]},{"tab":"API Reference","groups":[{"group":"Getting Started","pages":[{"title":"API Reference","href":"/api-reference/introduction"}]},{"group":"Models","pages":[{"title":"List Models","api":"GET /api/v1/models","href":"/api-reference/models/list"},{"title":"List All Models","api":"GET /api/v1/models/allmodels","href":"/api-reference/models/all-models"},{"title":"Get Rated Bids","api":"GET /api/v1/models/ratedbids","description":"Get rated bids for a specific model","href":"/api-reference/models/rated-bids"}]},{"group":"Chat","pages":[{"title":"Chat Completions","api":"POST /api/v1/chat/completions","href":"/api-reference/chat/completions"}]},{"group":"Embeddings","pages":[{"title":"Create Embeddings","api":"POST /api/v1/embeddings","description":"Generate vector embeddings for input text using AI models","href":"/api-reference/embeddings/create-embeddings"}]},{"group":"Audio","pages":[{"title":"Create Audio Speech","api":"POST /api/v1/audio/speech","href":"/api-reference/audio/speech"}]},{"group":"Billing","pages":[{"title":"Get Balance","api":"GET /api/v1/billing/balance","href":"/api-reference/billing/balance"},{"title":"List Usage","api":"GET /api/v1/billing/usage","href":"/api-reference/billing/usage"},{"title":"List Usage for Month","api":"GET /api/v1/billing/usage/month","href":"/api-reference/billing/usage-month"},{"title":"Get Monthly Spending","api":"GET /api/v1/billing/spending","href":"/api-reference/billing/spending"},{"title":"List Transactions","api":"GET /api/v1/billing/transactions","href":"/api-reference/billing/transactions"}]},{"group":"Utility","pages":[{"title":"Root","api":"GET /","href":"/api-reference/utility/root"},{"title":"Health Check","api":"GET /health","href":"/api-reference/utility/health"},{"title":"Model Health Check","api":"GET /health/models","href":"/api-reference/utility/health-models"}]}]}]},"basePath":"","title":"Chat Completions - Morpheus Inference API","deploymentId":"dpl_2pTxFtyBudBMYZiCw1MyvoA1wxpd","buildId":"dpl_2pTxFtyBudBMYZiCw1MyvoA1wxpd","dynamics":["c2aa737661","2b790eda92","b0f84f53ff"],"chunks":["OpenApiReferenceProvider-BtG4DSkw.js","snippetPresets-C1k1xDhp.js","utils-PMJoEt4Y.js","style-to-object-BY3JEAdk.js","utils-DW3Pr7Jq.js","v4-DIgz8zy6.js","addUniqueKeysToSchema-DIISLO2w.js","conditional-requirements-CFM0id0Q.js","cloneDeep-BErNCZCm.js","_Uint8Array-f0PCu9f_.js","isObject-FP1Yky1u.js","ApiExamples-OjY-8mqu.js","usePlaygroundInputsStore-B2HS2hUb.js","shallow-DVFuuIDQ.js","isEqual-DG0UKiQC.js","CodeSnippets-Cy6FBgwN.js","CodeSnippet-D1PtG8ed.js","getApiPlaygroundDisplay-Dkx2eNtL.js","Page-C8Cg25if.js","DynamicMarkdown-BvJIe00T.js","SectionHeading-B0rKYV8d.js","icon-yclzBff4.js","MethodPill-DxA11cCF.js","getPastedJson-CpkIDpMk.js","DuplicateIcon-CFCQNJ-D.js","axios-CsQoIw0U.js"]}