{
"error": {
"code": "rate_limited",
"message": "Too many requests. Retry in 12 seconds."
}
}
{
"error": {
"code": "internal_error",
"message": "Something went wrong on our side."
}
}
Overview
The Apply API enables lightning-fast code editing at 10,500+ tokens/second with 98% accuracy. This OpenAI-compatible endpoint intelligently merges code changes while preserving structure and formatting.
Models
Choose the model that best fits your use case:
Message Format
The Apply API uses a structured XML format within the message content:
<instruction>Brief description of what you're changing</instruction><code>Original code content</code><update>Code snippet showing only the changes with // ... existing code ... markers</update>
Format Guidelines
<instruction>: Optional but recommended. Use first-person, clear descriptions
<code>: The complete original code that needs modification
<update>: Show only what changes, using // ... existing code ... for unchanged sections
Usage Examples
import OpenAI from "openai";const openai = new OpenAI({ apiKey: "YOUR_API_KEY", baseURL: "https://api.morphllm.com/v1",});const instruction = "I will add error handling to prevent division by zero";const originalCode = "function divide(a, b) {\n return a / b;\n}";const codeEdit = "function divide(a, b) {\n if (b === 0) {\n throw new Error('Cannot divide by zero');\n }\n return a / b;\n}";const response = await openai.chat.completions.create({ model: "morph-v3-fast", messages: [ { role: "user", content: `<instruction>${instruction}</instruction>\n<code>${originalCode}</code>\n<update>${codeEdit}</update>`, }, ],});const mergedCode = response.choices[0].message.content;
import osfrom openai import OpenAIclient = OpenAI( api_key="YOUR_API_KEY", base_url="https://api.morphllm.com/v1")instruction = "I will add error handling to prevent division by zero"original_code = "function divide(a, b) {\n return a / b;\n}"code_edit = "function divide(a, b) {\n if (b === 0) {\n throw new Error('Cannot divide by zero');\n }\n return a / b;\n}"response = client.chat.completions.create( model="morph-v3-fast", messages=[ { "role": "user", "content": f"<instruction>{instruction}</instruction>\n<code>{original_code}</code>\n<update>{code_edit}</update>" } ])merged_code = response.choices[0].message.content
curl -X POST "https://api.morphllm.com/v1/chat/completions" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "morph-v3-fast", "messages": [ { "role": "user", "content": "<instruction>I will add error handling to prevent division by zero</instruction>\n<code>function divide(a, b) {\n return a / b;\n}</code>\n<update>function divide(a, b) {\n if (b === 0) {\n throw new Error(\"Cannot divide by zero\");\n }\n return a / b;\n}</update>" } ] }'
Chat completion request for Apply or Warp Grep (OpenAI-compatible)
Morph Apply
Warp Grep
Either a Morph Apply request or a Warp Grep request, discriminated by model.
model
enum<string>
default:morph-v3-fast
required
ID of the Apply model to use, or auto to let the router choose
Available options:
morph-v3-fast,
morph-v3-large,
auto
Example:
"morph-v3-fast"
messages
object[]
required
Array containing a single user message with structured content using instruction-guided format
Show child attributes
Example:
[ { "role": "user", "content": "<instruction>I will add error handling</instruction>\n<code>function divide(a, b) {\n return a / b;\n}</code>\n<update>function divide(a, b) {\n if (b === 0) throw new Error('Division by zero');\n return a / b;\n}</update>" } ]
stream
boolean
default:false
Enable streaming response. When true the response is a text/event-stream of OpenAI-style chat.completion.chunk deltas terminated by data: [DONE].
Example:
false
max_tokens
integer
Maximum number of tokens the Apply model may generate
Example:
150
temperature
number
default:0
Sampling temperature for the Apply request (0.0 for deterministic output)
Example:
0
Response
Chat completion response
Completion returned by a Morph chat model.
id
string
required
Unique identifier for the completion
Example:
"chatcmpl-123"
object
string
required
Always chat.completion
Example:
"chat.completion"
created
integer
required
Unix timestamp of when the completion was created
Example:
1677652288
choices
object[]
required
List of completion choices
Show child attributes
Example:
[ { "index": 0, "message": { "role": "assistant", "content": "\ndef calculate_total(items):\n total = 0\n for item in items:\n total += item.price\n return total * 1.1 # Add 10% tax\n" }, "finish_reason": "stop" } ]
{
"error": {
"code": "rate_limited",
"message": "Too many requests. Retry in 12 seconds."
}
}
{
"error": {
"code": "internal_error",
"message": "Something went wrong on our side."
}
}
{"docsConfig":{"theme":"maple","$schema":"https://mintlify.com/docs.json","name":"Morph Documentation","colors":{"primary":"#16A34A","light":"#07C983","dark":"#15803D"},"logo":{"light":"https://mintcdn.com/morph-555d6c14/lwaqk6ujzMJV1czI/logo/light.svg?fit=max\u0026auto=format\u0026n=lwaqk6ujzMJV1czI\u0026q=85\u0026s=cd5a33b1dd765106a68d6f487a1e20f1","dark":"https://mintcdn.com/morph-555d6c14/lwaqk6ujzMJV1czI/logo/dark.svg?fit=max\u0026auto=format\u0026n=lwaqk6ujzMJV1czI\u0026q=85\u0026s=c1c314250fc34da822ffa325af1cc60e","href":"https://morphllm.com"},"favicon":"https://mintcdn.com/morph-555d6c14/81UoWpotGPzGjPQ0/favicon.ico?fit=max\u0026auto=format\u0026n=81UoWpotGPzGjPQ0\u0026q=85\u0026s=0f94266a609b76a75975d1377f33b7e0","api":{"playground":{}},"navbar":{"links":[{"href":"https://discord.gg/AdXta4yxEK","label":"Community"},{"href":"https://morphllm.com/blog","label":"Blog"}],"primary":{"type":"button","label":"Dashboard","href":"https://morphllm.com/dashboard"}},"seo":{"indexing":"all"},"styling":{"latex":true},"contextual":{"options":["copy","view","download-spec","chatgpt","claude"],"display":"header"},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"morph-555d6c14","hasAudioNarration":false,"actualSubdomain":"morph-555d6c14","customDomains":["docs.morphllm.com"],"gitSource":{"type":"github","owner":"morphllm","repo":"landing","deployBranch":"main","contentDirectory":"docs","isPrivate":true,"mountPath":"","label":""},"entitlements":{"AI_CHAT":{"status":"DISABLED"}},"buildId":"6b05dd260c6a5ff80e42d1ee","clientVersion":"0.0.4340","searchFilterCounts":[{"language":"default","tag":"API Reference","count":20},{"language":"default","tag":"Models","count":18},{"language":"default","tag":"Integrations","count":12},{"language":"default","tag":"Get Started","count":10},{"language":"default","tag":"Guides","count":7},{"language":"default","tag":"WarpGrep","count":7},{"language":"default","tag":"Frameworks","count":4},{"language":"default","tag":"Open Source Models","count":4},{"language":"default","tag":"Account","count":3},{"language":"default","tag":"Dedicated","count":3}]},"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":"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":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"googleFontsInlined":false,"authValue":{"userAuth":{"type":"shared-session","apiUrl":"https://www.morphllm.com/api/user/session","loginUrl":"https://www.morphllm.com/dashboard","invalidatedAt":1765493560614}}},"customCss":[]}
{"page":{"pagePath":"api-reference/endpoint/apply","slug":"/api-reference/endpoint/apply","pageMetadata":{"title":"Apply API","description":"Apply code edits at 10,500 tok/s with 98% accuracy via OpenAI-compatible API","openapi":"POST /v1/chat/completions","href":"/api-reference/endpoint/apply"},"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: \"Apply code edits at 10,500 tok/s with 98% accuracy via 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`,li:`li`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,ul:`ul`,..._provideComponents(),...props.components},{Card,CardGroup,CodeBlock,CodeGroup,Heading,Table}=_components;if(!Card)_missingMdxReference(`Card`,true);if(!CardGroup)_missingMdxReference(`CardGroup`,true);if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!CodeGroup)_missingMdxReference(`CodeGroup`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Table)_missingMdxReference(`Table`,true);return _jsxs(_Fragment,{children:[_jsx(Heading,{level:`2`,id:`overview`,children:`Overview`}),`\n`,_jsxs(_components.p,{children:[`The Apply API enables lightning-fast code editing at `,_jsx(_components.strong,{children:`10,500+ tokens/second`}),` with `,_jsx(_components.strong,{children:`98% accuracy`}),`. This OpenAI-compatible endpoint intelligently merges code changes while preserving structure and formatting.`]}),`\n`,_jsx(Heading,{level:`2`,id:`models`,children:`Models`}),`\n`,_jsx(_components.p,{children:`Choose the model that best fits your use case:`}),`\n`,_jsx(Table,{}),`\n`,_jsx(Heading,{level:`2`,id:`message-format`,children:`Message Format`}),`\n`,_jsx(_components.p,{children:`The Apply API uses a structured XML format within the message content:`}),`\n`,_jsx(CodeBlock,{numberOfLines:`4`,language:`text`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`text`,children:_jsxs(_components.code,{language:`text`,numberOfLines:`4`,children:[_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`\u003cinstruction>Brief description of what you're changing\u003c/instruction>`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`\u003ccode>Original code content\u003c/code>`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{children:`\u003cupdate>Code snippet showing only the changes with // ... existing code ... markers\u003c/update>`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{})})]})})}),`\n`,_jsx(Heading,{level:`3`,id:`format-guidelines`,children:`Format Guidelines`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:_jsx(_components.code,{children:`\u003cinstruction>`})}),`: Optional but recommended. Use first-person, clear descriptions`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:_jsx(_components.code,{children:`\u003ccode>`})}),`: The complete original code that needs modification`]}),`\n`,_jsxs(_components.li,{children:[_jsx(_components.strong,{children:_jsx(_components.code,{children:`\u003cupdate>`})}),`: Show only what changes, using `,_jsx(_components.code,{children:`// ... existing code ...`}),` for unchanged sections`]}),`\n`]}),`\n`,_jsx(Heading,{level:`2`,id:`usage-examples`,children:`Usage Examples`}),`\n`,_jsxs(CodeGroup,{children:[_jsx(CodeBlock,{filename:`TypeScript`,highlight:`[13]`,numberOfLines:`22`,language:`typescript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`typescript`,children:_jsxs(_components.code,{language:`typescript`,numberOfLines:`22`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` OpenAI`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"openai\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` openai`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:` new`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` OpenAI`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` apiKey:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"YOUR_API_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` baseURL:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"https://api.morphllm.com/v1\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` instruction`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"I will add error handling to prevent division by zero\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` originalCode`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"function divide(a, b) {`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` return a / b;`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` codeEdit`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"function divide(a, b) {`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` if (b === 0) {`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` throw new Error('Cannot divide by zero');`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` return a / b;`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` response`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` openai`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`chat`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`completions`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`create`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line line-highlight`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` model:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"morph-v3-fast\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` messages:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` role:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` content:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `\u003cinstruction>\"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`instruction`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\u003c/instruction>`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\u003ccode>`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`originalCode`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\u003c/code>`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\u003cupdate>`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`codeEdit`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"\u003c/update>`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` },`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ],`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` mergedCode`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` response`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`choices`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`message`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`content`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`Python`,highlight:`[14]`,numberOfLines:`23`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`23`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` os`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` openai `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OpenAI`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`client `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OpenAI(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` api_key`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"YOUR_API_KEY\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` base_url`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"https://api.morphllm.com/v1\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`instruction `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"I will add error handling to prevent division by zero\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`original_code `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"function divide(a, b) {`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` return a / b;`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}\"`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`code_edit `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"function divide(a, b) {`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` if (b === 0) {`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` throw new Error('Cannot divide by zero');`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` return a / b;`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`}\"`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`response `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` client.chat.completions.create(`})]}),`\n`,_jsxs(_components.span,{className:`line line-highlight`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"morph-v3-fast\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` messages`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"role\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"user\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"content\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`: `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`f`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"\u003cinstruction>`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`instruction`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\u003c/instruction>`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\u003ccode>`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`original_code`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\u003c/code>`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:`\\\\n`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\u003cupdate>`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`{`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`code_edit`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\u003c/update>\"`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`merged_code `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` response.choices[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].message.content`})]}),`\n`]})})}),_jsx(CodeBlock,{filename:`cURL`,highlight:`[9]`,numberOfLines:`12`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`12`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`curl`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -X`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` POST`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"https://api.morphllm.com/v1/chat/completions\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Authorization: Bearer YOUR_API_KEY\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -H`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"Content-Type: application/json\"`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D7BA7D`},children:` \\\\`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` -d`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '{`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"model\": \"morph-v3-fast\",`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"messages\": [`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` {`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"role\": \"user\",`})}),`\n`,_jsx(_components.span,{className:`line line-highlight`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` \"content\": \"\u003cinstruction>I will add error handling to prevent division by zero\u003c/instruction>\\\\n\u003ccode>function divide(a, b) {\\\\n return a / b;\\\\n}\u003c/code>\\\\n\u003cupdate>function divide(a, b) {\\\\n if (b === 0) {\\\\n throw new Error(\\\\\"Cannot divide by zero\\\\\");\\\\n }\\\\n return a / b;\\\\n}\u003c/update>\"`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` ]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` }'`})}),`\n`]})})})]}),`\n`,_jsx(Heading,{level:`2`,id:`error-codes`,children:`Error Codes`}),`\n`,_jsx(Table,{}),`\n`,_jsxs(CardGroup,{cols:2,children:[_jsx(Card,{title:`edit_file Tool Guide`,icon:`wrench`,href:`/guides/edit_file_tool`,children:_jsx(_components.p,{children:`Build AI agent tools with Morph Apply`})}),_jsx(Card,{title:`More Examples`,icon:`code`,href:`/guides/tools`,children:_jsx(_components.p,{children:`See more implementation patterns`})})]})]})}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":"Apply API","description":"Apply code edits at 10,500 tok/s with 98% accuracy via OpenAI-compatible API","openapi":"POST /v1/chat/completions","href":"/api-reference/endpoint/apply"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Overview","slug":"overview","depth":2,"children":[]},{"title":"Models","slug":"models","depth":2,"children":[]},{"title":"Message Format","slug":"message-format","depth":2,"children":[{"title":"Format Guidelines","slug":"format-guidelines","depth":3,"children":[]}]},{"title":"Usage Examples","slug":"usage-examples","depth":2,"children":[]},{"title":"Error Codes","slug":"error-codes","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"openApiReferenceData":{"operation":{"operationId":"createChatCompletion","summary":"Create a chat completion","description":"Apply code edits at 10,500 tok/s with 98% accuracy via OpenAI-compatible API","tags":["chat"],"security":["ebf75de3-7e2b-4ee9-af3c-8d6c09c1658d"],"requestBody":"c0219d2e-e128-4026-a34e-2d228c4baea8","responses":{"200":"1e39476f-d337-4943-8e62-4734c0b45385","400":"d5c5d624-62f4-4210-82d6-d1aec1c7589a","401":"66223226-ca0b-45d0-b76b-a95da68fd7c8","429":"0d3953fd-2a15-4def-848a-2f0dcb7cf6cb","500":"b6eb94a3-1903-4d84-bf87-2f5be3f16ebe"},"method":"post","type":"path","servers":["05b02330-989f-400f-923d-bb9048118f5a"],"path":"/v1/chat/completions","baseUrlOptions":["https://api.morphllm.com"],"title":"Create a chat completion","codeSamples":[],"requiredOnlyExamples":false,"requestExampleType":"generated","responseExampleType":"generated"},"dependencies":{"parameters":{},"requestBody":{"description":"Chat completion request for Apply or Warp Grep (OpenAI-compatible)","required":true,"content":{"application/json":{"example":{"model":"morph-v3-fast","messages":[{"role":"user","content":"\u003cinstruction>I will add error handling\u003c/instruction>\n\u003ccode>function divide(a, b) {\n return a / b;\n}\u003c/code>\n\u003cupdate>function divide(a, b) {\n if (b === 0) throw new Error('Division by zero');\n return a / b;\n}\u003c/update>"}],"stream":false,"max_tokens":150,"temperature":0},"schema":{"oneOf":[{"type":"object","title":"Morph Apply","description":"Either a Morph Apply request or a Warp Grep request, discriminated by `model`.","required":["model","messages"],"example":{"model":"morph-v3-fast","messages":[{"role":"user","content":"\u003cinstruction>I will add error handling\u003c/instruction>\n\u003ccode>function divide(a, b) {\n return a / b;\n}\u003c/code>\n\u003cupdate>function divide(a, b) {\n if (b === 0) throw new Error('Division by zero');\n return a / b;\n}\u003c/update>"}],"stream":false,"max_tokens":150,"temperature":0},"properties":{"model":{"type":"string","enum":["morph-v3-fast","morph-v3-large","auto"],"default":"morph-v3-fast","description":"ID of the Apply model to use, or `auto` to let the router choose","example":"morph-v3-fast","isRequired":true,"uniqueKey":"oneOf.0.model","typeLabel":"enum\u003cstring>"},"messages":{"type":"array","items":{"type":"object","properties":{"role":{"type":"string","enum":["system","user","assistant"],"description":"Which participant produced this chat message","example":"user","isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].role","typeLabel":"enum\u003cstring>"},"content":{"type":"string","description":"The content of the message, containing code and update snippets. An Apply message uses the format: \u003cinstruction>First-person description\u003c/instruction>\u003ccode>Complete original file content\u003c/code>\u003cupdate>Code snippet with // ... existing code ... markers\u003c/update>","example":"\u003cinstruction>I will add logic to add 10% tax\u003c/instruction>\n\u003ccode>def calculate_total(items):\n total = 0\n for item in items:\n total += item.price\n return total\u003c/code>\n\u003cupdate>def calculate_total(items):\n total = 0\n for item in items:\n total += item.price\n return total * 1.1 # Add 10% tax\u003c/update>","isRequired":true,"uniqueKey":"oneOf.0.messages.items.[INDEX].content","typeLabel":"string"}},"required":["role","content"],"description":"A single chat message.","example":{"role":"user","content":"\u003cinstruction>I will add logic to add 10% tax\u003c/instruction>\n\u003ccode>def calculate_total(items):\n total = 0\n for item in items:\n total += item.price\n return total\u003c/code>\n\u003cupdate>def calculate_total(items):\n total = 0\n for item in items:\n total += item.price\n return total * 1.1 # Add 10% tax\u003c/update>"},"uniqueKey":"oneOf.0.messages.items.[INDEX]","typeLabel":"object"},"default":[{"role":"user","content":"\u003cinstruction>I will add error handling\u003c/instruction>\n\u003ccode>function divide(a, b) {\n return a / b;\n}\u003c/code>\n\u003cupdate>function divide(a, b) {\n if (b === 0) throw new Error('Division by zero');\n return a / b;\n}\u003c/update>"}],"description":"Array containing a single user message with structured content using instruction-guided format","example":[{"role":"user","content":"\u003cinstruction>I will add error handling\u003c/instruction>\n\u003ccode>function divide(a, b) {\n return a / b;\n}\u003c/code>\n\u003cupdate>function divide(a, b) {\n if (b === 0) throw new Error('Division by zero');\n return a / b;\n}\u003c/update>"}],"isRequired":true,"uniqueKey":"oneOf.0.messages","typeLabel":"object[]"},"stream":{"type":"boolean","default":false,"description":"Enable streaming response. When true the response is a `text/event-stream` of OpenAI-style `chat.completion.chunk` deltas terminated by `data: [DONE]`.","example":false,"uniqueKey":"oneOf.0.stream","typeLabel":"boolean"},"max_tokens":{"type":"integer","description":"Maximum number of tokens the Apply model may generate","example":150,"uniqueKey":"oneOf.0.max_tokens","typeLabel":"integer"},"temperature":{"type":"number","default":0,"description":"Sampling temperature for the Apply request (0.0 for deterministic output)","example":0,"uniqueKey":"oneOf.0.temperature","typeLabel":"number"}},"uniqueKey":"oneOf.0","typeLabel":"Morph Apply · object"},{"type":"object","title":"Warp Grep","description":"Either a Morph Apply request or a Warp Grep request, discriminated by `model`.","required":["model","messages"],"example":{"model":"morph-v3-fast","messages":[{"role":"user","content":"\u003cinstruction>I will add error handling\u003c/instruction>\n\u003ccode>function divide(a, b) {\n return a / b;\n}\u003c/code>\n\u003cupdate>function divide(a, b) {\n if (b === 0) throw new Error('Division by zero');\n return a / b;\n}\u003c/update>"}],"temperature":0,"max_tokens":150},"properties":{"model":{"type":"string","enum":["morph-warp-grep-v1"],"default":"morph-warp-grep-v1","description":"ID of the Warp Grep model","example":"morph-warp-grep-v1","isRequired":true,"uniqueKey":"oneOf.1.model","typeLabel":"enum\u003cstring>"},"messages":{"type":"array","items":{"type":"object","properties":{"role":{"type":"string","enum":["system","user","assistant"],"description":"Which participant produced this Warp Grep turn","example":"user","isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].role","typeLabel":"enum\u003cstring>"},"content":{"type":"string","description":"Message content. User messages use \u003crepo_structure> and \u003csearch_string> XML. Assistant messages contain \u003cthink> reasoning and XML tool calls (\u003cgrep>, \u003cread>, \u003clist_directory>, \u003cfinish>).","example":"\u003crepo_structure>\nmyapp/\n src/\n auth/\n\u003c/repo_structure>\n\n\u003csearch_string>\nFind where JWT tokens are validated\n\u003c/search_string>","isRequired":true,"uniqueKey":"oneOf.1.messages.items.[INDEX].content","typeLabel":"string"}},"required":["role","content"],"description":"A single turn in a Warp Grep search conversation.","example":{"role":"user","content":"\u003crepo_structure>\nmyapp/\n src/\n auth/\n\u003c/repo_structure>\n\n\u003csearch_string>\nFind where JWT tokens are validated\n\u003c/search_string>"},"uniqueKey":"oneOf.1.messages.items.[INDEX]","typeLabel":"object"},"description":"Multi-turn conversation with system prompt, user queries, assistant tool calls, and tool results","example":[{"role":"system","content":"You are a code search agent..."},{"role":"user","content":"\u003crepo_structure>\nmyapp/\n src/\n auth/\n\u003c/repo_structure>\n\n\u003csearch_string>\nFind JWT validation\n\u003c/search_string>"}],"isRequired":true,"uniqueKey":"oneOf.1.messages","typeLabel":"object[]"},"temperature":{"type":"number","default":0,"description":"Sampling temperature (0.0 recommended for deterministic search)","example":0,"uniqueKey":"oneOf.1.temperature","typeLabel":"number"},"max_tokens":{"type":"integer","description":"Maximum tokens per response","default":2048,"example":2048,"uniqueKey":"oneOf.1.max_tokens","typeLabel":"integer"}},"uniqueKey":"oneOf.1","typeLabel":"Warp Grep · object"}],"uniqueKey":"","typeLabel":"Morph Apply · object | Warp Grep · object"},"examples":{"Example":{"title":"Example","value":{"model":"morph-v3-fast","messages":[{"role":"user","content":"\u003cinstruction>I will add error handling\u003c/instruction>\n\u003ccode>function divide(a, b) {\n return a / b;\n}\u003c/code>\n\u003cupdate>function divide(a, b) {\n if (b === 0) throw new Error('Division by zero');\n return a / b;\n}\u003c/update>"}],"stream":false,"max_tokens":150,"temperature":0}}},"exampleType":"examples"}},"exampleType":"examples"},"responses":{"1e39476f-d337-4943-8e62-4734c0b45385":{"description":"Chat completion response","content":{"application/json":{"example":{"id":"chatcmpl-123","object":"chat.completion","created":1677652288,"choices":[{"index":0,"message":{"role":"assistant","content":"\ndef calculate_total(items):\n total = 0\n for item in items:\n total += item.price\n return total * 1.1 # Add 10% tax\n"},"finish_reason":"stop"}],"usage":{"prompt_tokens":25,"completion_tokens":32,"total_tokens":57}},"schema":{"type":"object","properties":{"id":{"type":"string","description":"Unique identifier for the completion","example":"chatcmpl-123","isRequired":true,"uniqueKey":"id","typeLabel":"string"},"object":{"type":"string","description":"Always `chat.completion`","example":"chat.completion","isRequired":true,"uniqueKey":"object","typeLabel":"string"},"created":{"type":"integer","description":"Unix timestamp of when the completion was created","example":1677652288,"isRequired":true,"uniqueKey":"created","typeLabel":"integer"},"choices":{"type":"array","items":{"type":"object","properties":{"index":{"type":"integer","description":"Index of the choice in the list","example":0,"isRequired":true,"uniqueKey":"choices.items.[INDEX].index","typeLabel":"integer"},"message":{"type":"object","properties":{"role":{"type":"string","description":"Author of the generated message, always `assistant`","example":"assistant","uniqueKey":"choices.items.[INDEX].message.role","typeLabel":"string"},"content":{"type":"string","description":"Text generated by the model for this choice","example":"\ndef calculate_total(items):\n total = 0\n for item in items:\n total += item.price\n return total * 1.1 # Add 10% tax\n","uniqueKey":"choices.items.[INDEX].message.content","typeLabel":"string"}},"description":"The message generated by the model","example":{"role":"assistant","content":"\ndef calculate_total(items):\n total = 0\n for item in items:\n total += item.price\n return total * 1.1 # Add 10% tax\n"},"isRequired":true,"uniqueKey":"choices.items.[INDEX].message","typeLabel":"object"},"finish_reason":{"type":"string","description":"The reason the model stopped generating tokens","example":"stop","isRequired":true,"uniqueKey":"choices.items.[INDEX].finish_reason","typeLabel":"string"}},"required":["index","message","finish_reason"],"description":"A single completion choice returned by the model.","example":{"index":0,"message":{"role":"assistant","content":"\ndef calculate_total(items):\n total = 0\n for item in items:\n total += item.price\n return total * 1.1 # Add 10% tax\n"},"finish_reason":"stop"},"uniqueKey":"choices.items.[INDEX]","typeLabel":"object"},"description":"List of completion choices","example":[{"index":0,"message":{"role":"assistant","content":"\ndef calculate_total(items):\n total = 0\n for item in items:\n total += item.price\n return total * 1.1 # Add 10% tax\n"},"finish_reason":"stop"}],"isRequired":true,"uniqueKey":"choices","typeLabel":"object[]"},"usage":{"type":"object","properties":{"prompt_tokens":{"type":"integer","description":"Number of tokens in the prompt","example":25,"uniqueKey":"usage.prompt_tokens","typeLabel":"integer"},"completion_tokens":{"type":"integer","description":"Number of tokens in the completion","example":32,"uniqueKey":"usage.completion_tokens","typeLabel":"integer"},"total_tokens":{"type":"integer","description":"Total number of tokens used","example":57,"uniqueKey":"usage.total_tokens","typeLabel":"integer"}},"description":"Usage statistics for the completion request","example":{"prompt_tokens":25,"completion_tokens":32,"total_tokens":57},"isRequired":true,"uniqueKey":"usage","typeLabel":"object"}},"required":["id","object","created","choices","usage"],"description":"Completion returned by a Morph chat model.","example":{"id":"chatcmpl-123","object":"chat.completion","created":1677652288,"choices":[{"index":0,"message":{"role":"assistant","content":"\ndef calculate_total(items):\n total = 0\n for item in items:\n total += item.price\n return total * 1.1 # Add 10% tax\n"},"finish_reason":"stop"}],"usage":{"prompt_tokens":25,"completion_tokens":32,"total_tokens":57}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"id":"chatcmpl-123","object":"chat.completion","created":1677652288,"choices":[{"index":0,"message":{"role":"assistant","content":"\ndef calculate_total(items):\n total = 0\n for item in items:\n total += item.price\n return total * 1.1 # Add 10% tax\n"},"finish_reason":"stop"}],"usage":{"prompt_tokens":25,"completion_tokens":32,"total_tokens":57}}}},"exampleType":"examples"}},"exampleType":"examples"},"d5c5d624-62f4-4210-82d6-d1aec1c7589a":{"description":"Malformed request — missing or invalid fields.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string","example":"invalid_request_error","description":"Machine-readable error code.","isRequired":true,"uniqueKey":"error.code","typeLabel":"string"},"message":{"type":"string","example":"The request body is missing the `model` field.","description":"Human-readable explanation of the failure.","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"}},"required":["code","message"],"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"required":["error"],"description":"Standard error envelope returned by every non-2xx response.","example":{"error":{"code":"invalid_request_error","message":"The request body is missing the `model` field."}},"uniqueKey":"","typeLabel":"object"},"example":{"error":{"code":"invalid_request_error","message":"The request body is missing the `model` field."}},"examples":{"Example":{"title":"Example","value":{"error":{"code":"invalid_request_error","message":"The request body is missing the `model` field."}}}},"exampleType":"examples"}},"exampleType":"examples"},"66223226-ca0b-45d0-b76b-a95da68fd7c8":{"description":"Missing or invalid API key.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string","example":"invalid_request_error","description":"Machine-readable error code.","isRequired":true,"uniqueKey":"error.code","typeLabel":"string"},"message":{"type":"string","example":"The request body is missing the `model` field.","description":"Human-readable explanation of the failure.","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"}},"required":["code","message"],"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"required":["error"],"description":"Standard error envelope returned by every non-2xx response.","example":{"error":{"code":"invalid_request_error","message":"The request body is missing the `model` field."}},"uniqueKey":"","typeLabel":"object"},"example":{"error":{"code":"unauthorized","message":"Invalid API key provided."}},"examples":{"Example":{"title":"Example","value":{"error":{"code":"unauthorized","message":"Invalid API key provided."}}}},"exampleType":"examples"}},"exampleType":"examples"},"0d3953fd-2a15-4def-848a-2f0dcb7cf6cb":{"description":"Rate limited — retry after the interval in the Retry-After header.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string","example":"invalid_request_error","description":"Machine-readable error code.","isRequired":true,"uniqueKey":"error.code","typeLabel":"string"},"message":{"type":"string","example":"The request body is missing the `model` field.","description":"Human-readable explanation of the failure.","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"}},"required":["code","message"],"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"required":["error"],"description":"Standard error envelope returned by every non-2xx response.","example":{"error":{"code":"invalid_request_error","message":"The request body is missing the `model` field."}},"uniqueKey":"","typeLabel":"object"},"example":{"error":{"code":"rate_limited","message":"Too many requests. Retry in 12 seconds."}},"examples":{"Example":{"title":"Example","value":{"error":{"code":"rate_limited","message":"Too many requests. Retry in 12 seconds."}}}},"exampleType":"examples"}},"exampleType":"examples"},"b6eb94a3-1903-4d84-bf87-2f5be3f16ebe":{"description":"Internal error — safe to retry with backoff.","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"object","properties":{"code":{"type":"string","example":"invalid_request_error","description":"Machine-readable error code.","isRequired":true,"uniqueKey":"error.code","typeLabel":"string"},"message":{"type":"string","example":"The request body is missing the `model` field.","description":"Human-readable explanation of the failure.","isRequired":true,"uniqueKey":"error.message","typeLabel":"string"}},"required":["code","message"],"isRequired":true,"uniqueKey":"error","typeLabel":"object"}},"required":["error"],"description":"Standard error envelope returned by every non-2xx response.","example":{"error":{"code":"invalid_request_error","message":"The request body is missing the `model` field."}},"uniqueKey":"","typeLabel":"object"},"example":{"error":{"code":"internal_error","message":"Something went wrong on our side."}},"examples":{"Example":{"title":"Example","value":{"error":{"code":"internal_error","message":"Something went wrong on our side."}}}},"exampleType":"examples"}},"exampleType":"examples"}},"security":{"ebf75de3-7e2b-4ee9-af3c-8d6c09c1658d":{"bearerAuth":{"type":"http","scheme":"bearer","bearerFormat":"opaque","description":"Morph API key, passed as `Authorization: Bearer sk-...`. Create keys at https://www.morphllm.com/dashboard/api-keys.","scopes":[],"schemeName":"bearerAuth"}}},"servers":{"05b02330-989f-400f-923d-bb9048118f5a":{"url":"https://api.morphllm.com","description":"Production"}},"processedSecurityOptions":[{"schemes":[{"scheme":{"type":"http","scheme":"bearer","bearerFormat":"opaque","description":"Morph API key, passed as `Authorization: Bearer sk-...`. Create keys at https://www.morphllm.com/dashboard/api-keys.","scopes":[],"schemeName":"bearerAuth"},"schema":{"title":"Bearer Auth","type":"string","isRequired":true,"description":"Morph API key, passed as `Authorization: Bearer sk-...`. Create keys at https://www.morphllm.com/dashboard/api-keys.","format":"bearer","typeLabel":"string\u003cbearer>","deprecated":false},"schemeName":"bearerAuth","name":"Authorization"}],"title":"bearerAuth"}]},"originalFileLocation":"api-reference/openapi.json"},"subdomain":"morph-555d6c14","siteName":"Morph Documentation","title":"Apply API - Morph Documentation","contextualStarterQuestions":[],"lastModified":"2026-06-15T01:47:01.821Z","originalFileLocation":"api-reference/endpoint/apply.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=\"Apply code edits at 10,500 tok/s with 98% accuracy via OpenAI-compatible API\">\u003cmeta data-mint-head name=\"application-name\" content=\"Morph Documentation\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/morph-555d6c14/lHIMsY-nrY1C9Ig1/_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/morph-555d6c14/lHIMsY-nrY1C9Ig1/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/morph-555d6c14/lHIMsY-nrY1C9Ig1/_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/morph-555d6c14/lHIMsY-nrY1C9Ig1/_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/morph-555d6c14/lHIMsY-nrY1C9Ig1/_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/morph-555d6c14/lHIMsY-nrY1C9Ig1/_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/morph-555d6c14/lHIMsY-nrY1C9Ig1/_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/morph-555d6c14/lHIMsY-nrY1C9Ig1/_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/morph-555d6c14/lHIMsY-nrY1C9Ig1/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Apply API - Morph Documentation\">\u003cmeta data-mint-head property=\"og:description\" content=\"Apply code edits at 10,500 tok/s with 98% accuracy via OpenAI-compatible API\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Morph Documentation\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.morphllm.com/api-reference/endpoint/apply\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://morph-555d6c14.mintlify.site/_mintlify/api/og/v2?division=API+Reference\u0026amp;title=Apply+API\u0026amp;description=Apply+code+edits+at+10%2C500+tok%2Fs+with+98%25+accuracy+via+OpenAI-compatible+API\u0026amp;theme=2a78a8709f2d6f723112079e\u0026amp;signature=3ef6dfc317bb7974ca0d4e478ffcf49dc0ad2dc27a7ad0183e5e541e00ad96fe\">\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=\"Apply API - Morph Documentation\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Apply code edits at 10,500 tok/s with 98% accuracy via OpenAI-compatible API\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://morph-555d6c14.mintlify.site/_mintlify/api/og/v2?division=API+Reference\u0026amp;title=Apply+API\u0026amp;description=Apply+code+edits+at+10%2C500+tok%2Fs+with+98%25+accuracy+via+OpenAI-compatible+API\u0026amp;theme=2a78a8709f2d6f723112079e\u0026amp;signature=3ef6dfc317bb7974ca0d4e478ffcf49dc0ad2dc27a7ad0183e5e541e00ad96fe\">\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/morph-555d6c14/lHIMsY-nrY1C9Ig1/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Morph Documentation\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#16A34A\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.morphllm.com/api-reference/endpoint/apply\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/api-reference/endpoint/apply.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.morphllm.com/#organization\",\"name\":\"Morph Documentation\",\"url\":\"https://docs.morphllm.com\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/morph-555d6c14/lwaqk6ujzMJV1czI/logo/light.svg?fit=max\u0026auto=format\u0026n=lwaqk6ujzMJV1czI\u0026q=85\u0026s=cd5a33b1dd765106a68d6f487a1e20f1\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.morphllm.com#website\",\"name\":\"Morph Documentation\",\"url\":\"https://docs.morphllm.com\",\"publisher\":{\"@id\":\"https://docs.morphllm.com/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.morphllm.com/api-reference/endpoint/apply#webpage\",\"url\":\"https://docs.morphllm.com/api-reference/endpoint/apply\",\"name\":\"Apply API\",\"description\":\"Apply code edits at 10,500 tok/s with 98% accuracy via OpenAI-compatible API\",\"dateModified\":\"2026-06-15T01:47:01.821Z\",\"isPartOf\":{\"@id\":\"https://docs.morphllm.com#website\"},\"breadcrumb\":{\"@id\":\"https://docs.morphllm.com/api-reference/endpoint/apply#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.morphllm.com/api-reference/endpoint/apply#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Morph Documentation\",\"item\":\"https://docs.morphllm.com\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Apply API\",\"item\":\"https://docs.morphllm.com/api-reference/endpoint/apply\"}]},{\"@type\":[\"TechArticle\",\"APIReference\"],\"@id\":\"https://docs.morphllm.com/api-reference/endpoint/apply#apireference\",\"headline\":\"Apply API\",\"name\":\"Apply API\",\"description\":\"Apply code edits at 10,500 tok/s with 98% accuracy via OpenAI-compatible API\",\"url\":\"https://docs.morphllm.com/api-reference/endpoint/apply\",\"mainEntityOfPage\":{\"@id\":\"https://docs.morphllm.com/api-reference/endpoint/apply#webpage\"},\"dateModified\":\"2026-06-15T01:47:01.821Z\",\"publisher\":{\"@id\":\"https://docs.morphllm.com/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.morphllm.com#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Morph Documentation\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Morph Documentation\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/api-reference/endpoint/apply.md","siteName":"Morph Documentation","nav":{"global":null,"groups":[{"group":"Get Started","public":true,"pages":[{"title":"Introduction","description":"Open-weight coding models on an OpenAI-compatible API","icon":"book-open","href":"/introduction"},{"title":"Quickstart","description":"Run a model, apply edits at 10,500 tok/s, and search code — one OpenAI-compatible API","icon":"rocket","href":"/quickstart"},{"title":"Endpoints","description":"Choose general inference or reserve capacity for a dedicated model endpoint","icon":"plug","href":"/endpoints"},{"title":"General inference","description":"Send requests to Morph models without provisioning an endpoint","icon":"bolt","href":"/general-inference"},{"title":"Dedicated endpoints","description":"Reserve model capacity, send requests, monitor usage, and cancel service","icon":"server","href":"/dedicated-endpoints"},{"title":"Ultra plan","description":"Unlimited Kimi K3.1 and DeepSeek V4.1 Flash for $200 a month, subject to rate limits","icon":"infinity","href":"/ultra-plan"},{"title":"Rate Limits","description":"Per-minute account request and token limits, no concurrency cap, and serving capacity on DeepSeek V4.1 Flash Abliterated and Kimi K3.1 Pro Abliterated","icon":"gauge","href":"/rate-limits"},{"title":"morph CLI","description":"One binary for WarpGrep search, Fast Apply edits, Compact, and chat. Agents call it through their shell.","icon":"terminal","href":"/cli"},{"title":"Agent skills","description":"SKILL.md files that teach Claude Code, Codex, Cursor and OpenCode when to call morph.","icon":"graduation-cap","href":"/skills"},{"title":"Agent Context (llms.txt)","description":"Give your coding agent full Morph context in ~5k tokens","icon":"file-lines","href":"/llm-quickstart"}]},{"group":"Models","public":true,"pages":[{"group":"Open Source Models","icon":"rocket","root":{"title":"Open Source Models","description":"Open-weight models with automatic prefix caching","icon":"rocket","href":"/sdk/components/fast-models"},"pages":[{"title":"Dynamic Tool Loading","description":"Load Kimi K3.1 tool schemas only when an agent needs them","icon":"wrench","href":"/sdk/components/dynamic-tool-loading"},{"title":"Prompt Caching","description":"Automatic prefix caching on every open source model. Cached input at $0.1955/1M on GLM-5.3, with per-request TTL control.","icon":"database","href":"/sdk/components/caching"},{"title":"Standby Requests","description":"50% off Kimi K3.1, GLM-5.3, GLM-5.3-Flash, and DeepSeek V4 Flash for latency-tolerant workloads. Set service_tier: standby and pay half.","icon":"clock","href":"/sdk/components/standby"}]},{"title":"Reflex","description":"Get a decision from text, JSON, or an image. Send a state and a question; read the probabilities.","icon":"bolt","href":"/models/reflex"},{"title":"Fast Apply","description":"AI file editing at 10,500 tokens/s - 1.8x faster, 40% fewer tokens","icon":"bolt","href":"/sdk/components/fast-apply"},{"title":"Compact","description":"Drop filler from chat history at 33,000 tok/s. No rewriting, no paraphrasing.","icon":"compress","og:image":"images/compact.webp","twitter:image":"images/compact.webp","href":"/sdk/components/compact"},{"group":"WarpGrep","icon":"search","root":{"title":"WarpGrep","description":"A code search subagent that finds relevant code in a separate context window. No embeddings, no indexing.","icon":"search","href":"/sdk/components/warp-grep/index"},"pages":[{"group":"Subagent as a Tool","pages":[{"title":"Codebase Search","description":"Search local repositories with WarpGrep","icon":"magnifying-glass","href":"/sdk/components/warp-grep/codebase-search"},{"title":"GitHub Search","description":"Search public GitHub repositories without cloning","icon":"github","href":"/sdk/components/warp-grep/github-search"},{"title":"Streaming","description":"Stream WarpGrep search steps","icon":"bars-staggered","href":"/sdk/components/warp-grep/streaming"}]},{"title":"Examples","description":"Production-ready WarpGrep agent patterns","icon":"code","href":"/sdk/components/warp-grep/examples"},{"title":"Direct API Access","description":"Build your own agent harness around WarpGrep","icon":"code","href":"/sdk/components/warp-grep/direct"},{"title":"Sandbox Execution","description":"Run WarpGrep in remote sandboxes and custom environments","icon":"cloud","href":"/sdk/components/warp-grep/sandbox-execution"}]},{"title":"Model Router","description":"Classifies prompt difficulty, ambiguity, and domain for automatic model selection","icon":"route","og:image":"images/router.jpg","twitter:image":"images/router.jpg","href":"/sdk/components/router"}]},{"group":"API Reference","public":true,"pages":[{"title":"Apply API","description":"Apply code edits at 10,500 tok/s with 98% accuracy via OpenAI-compatible API","openapi":"POST /v1/chat/completions","href":"/api-reference/endpoint/apply"},{"title":"Compact API","description":"Compress chat history and code context at 33,000 tok/s with byte-identical output","openapi":"POST /v1/compact","href":"/api-reference/endpoint/compact"},{"title":"WarpGrep API","description":"Agentic code search subagent that explores repositories in ~6 seconds","openapi":"POST /v1/chat/completions","href":"/api-reference/endpoint/warpgrep"},{"title":"Messages API","description":"Anthropic-compatible /v1/messages endpoint — point an Anthropic SDK at Morph by changing the base URL","openapi":"POST /v1/messages","href":"/api-reference/endpoint/messages"},{"title":"Reflex API","description":"Typed decisions: send a state and named questions, get a probability per answer back. No text generation, no parsing.","openapi":"POST /v1/systemone","href":"/api-reference/endpoint/systemone"},{"group":"Models","pages":[{"title":"List Models","description":"OpenAI-compatible model listing at /v1/models","openapi":"GET /v1/models","href":"/api-reference/endpoint/models"},{"title":"Retrieve Model","description":"Fetch a single model by id at /v1/models/{model}","openapi":"GET /v1/models/{model}","href":"/api-reference/endpoint/retrieve-model"},{"title":"Delete Model","description":"Remove a fine-tuned model at /v1/models/{model}","openapi":"DELETE /v1/models/{model}","href":"/api-reference/endpoint/delete-model"}]},{"group":"Dedicated","pages":[{"title":"List Dedicated Endpoints","description":"Discover your dedicated endpoints at /api/v1/dedicated/endpoints","openapi":"GET /api/v1/dedicated/endpoints","href":"/api-reference/endpoint/dedicated-list"},{"title":"Get Dedicated Endpoint","description":"Fetch one endpoint's lifecycle at /api/v1/dedicated/endpoints/{id}","openapi":"GET /api/v1/dedicated/endpoints/{id}","href":"/api-reference/endpoint/dedicated-get"},{"title":"Cancel Dedicated Endpoint","description":"Cancel service at /api/v1/dedicated/endpoints/{id}/cancel","openapi":"POST /api/v1/dedicated/endpoints/{id}/cancel","href":"/api-reference/endpoint/dedicated-cancel"}]},{"group":"Credits","pages":[{"title":"Create Credit Top-up","description":"Buy credits with USDC from an agent at /api/v1/credits/topups","openapi":"POST /api/v1/credits/topups","href":"/api-reference/endpoint/credits-topup-create"},{"title":"Get Credit Top-up","description":"Check whether a top-up has been paid and credited at /api/v1/credits/topups/{checkoutId}","openapi":"GET /api/v1/credits/topups/{checkoutId}","href":"/api-reference/endpoint/credits-topup-get"}]},{"group":"Account","pages":[{"title":"Get Account Usage","description":"Read your daily usage and spend at /api/v1/account/usage","openapi":"GET /api/v1/account/usage","href":"/api-reference/endpoint/account-usage-get"},{"title":"Get Account Settings","description":"Read your billing settings at /api/v1/account/settings","openapi":"GET /api/v1/account/settings","href":"/api-reference/endpoint/account-settings-get"},{"title":"Update Account Settings","description":"Change extra usage, spend limits and auto-reload at /api/v1/account/settings","openapi":"PATCH /api/v1/account/settings","href":"/api-reference/endpoint/account-settings-update"}]},{"group":"Organization","pages":[{"title":"List Member Budgets","description":"Read every organization member's monthly budget and spend at /api/v1/org/members/budgets","openapi":"GET /api/v1/org/members/budgets","href":"/api-reference/endpoint/org-member-budgets-list"},{"title":"Set Member Budget","description":"Cap a member's monthly spend on your organization's keys at /api/v1/org/members/{userId}/budget","openapi":"PUT /api/v1/org/members/{userId}/budget","href":"/api-reference/endpoint/org-member-budget-set"},{"title":"Remove Member Budget","description":"Remove a member's monthly budget at /api/v1/org/members/{userId}/budget","openapi":"DELETE /api/v1/org/members/{userId}/budget","href":"/api-reference/endpoint/org-member-budget-delete"}]},{"title":"Report API","description":"Report failed or problematic completions to improve Morph model quality","openapi":"POST /api/report","href":"/api-reference/endpoint/report"}]},{"group":"Integrations","public":true,"pages":[{"group":"Guides","icon":"book","pages":[{"title":"Claude Code \u0026 Codex","description":"Run Morph's open models inside Claude Code and Codex","icon":"terminal","href":"/guides/coding-agents"},{"title":"Enterprise Model Routing","description":"Route every Claude Code turn to the right Claude model with an org-wide policy. Configure it in Administration, install it per developer, uninstall in one command.","href":"/guides/enterprise-model-routing"},{"title":"General Prompting","description":"Learn how to use prompt models like Claude, GPT-4o, and Gemini optimized for agentic workflows","icon":"message","href":"/guides/prompting"},{"title":"Agent Tools (edit_file)","description":"Build precise AI agents that edit code fast without full file rewrites using Morph's edit_file tool","icon":"wrench","href":"/guides/agent-tools"},{"title":"XML Tool Calls","description":"Learn why XML tool calls outperform JSON for code editing and how to implement them with Claude and other LLMs","icon":"code","href":"/guides/xml-tool-calls"},{"title":"WarpGrep in Python","description":"Build a complete WarpGrep agent harness in Python","icon":"python","href":"/guides/warp-grep-python"},{"title":"API Reference","description":"Complete MorphClient API and types","icon":"book","href":"/sdk/reference"}]},{"group":"Frameworks","icon":"code","pages":[{"title":"Vercel AI SDK","description":"Stream fast code edits with Morph using the Vercel AI SDK","icon":"triangle","href":"/guides/ai-sdk"},{"title":"Blaxel Sandboxes","description":"Apply edits and execute AI code via tool calls inside a secure sandboxed environment on Blaxel.","icon":"b","href":"/guides/blaxel"},{"title":"Freestyle","description":"How to integrate Morph Fast Apply with Freestyle Dev Servers for lightning-fast AI code editing.","href":"/guides/freestyle"},{"title":"Claude Code","description":"Run Claude Code on Morph models, and add Morph's fast edits and repo search as tools.","href":"/guides/claude-code"}]},{"group":"Legacy","icon":"archive","pages":[{"title":"MCP server (legacy)","description":"The Morph MCP server for hosts that cannot run commands. New installs should use the morph CLI + skills.","icon":"plug","href":"/mcpquickstart"}]}]}]},"basePath":"","title":"Apply API - Morph Documentation","deploymentId":"dpl_EtLmMeZHkKGqAjV1DiX4ZXCriDj3","buildId":"dpl_EtLmMeZHkKGqAjV1DiX4ZXCriDj3","dynamics":["c2aa737661","b0f84f53ff","a9bb46feb3","2b790eda92"],"chunks":["OpenApiReferenceProvider-CWRF67qg.js","snippetPresets-BR8BoZAC.js","utils-D5WEoDBM.js","style-to-object-BY3JEAdk.js","utils-B79vXYXV.js","v4-DIgz8zy6.js","addUniqueKeysToSchema-C59iNs-S.js","conditional-requirements-CFM0id0Q.js","cloneDeep-455jK_K_.js","_Uint8Array-BEecbuUl.js","isObject-FP1Yky1u.js","Page-UFatEFaf.js","api-description-markdown-Cny85OC3.js","DynamicMarkdown-Czhs88Hc.js","CodeSnippet-Bkkti1IB.js","use-playground-group-access-BLvLSz8w.js","SectionHeading-B08KBUKT.js","ApiExamples-CFRHL52q.js","usePlaygroundInputsStore-Caip2xMX.js","shallow-BS-qcxmX.js","isEqual-CEpbaqh9.js","CodeSnippets-B-R0FAqw.js","MethodPill-D8OvWg5y.js","getPastedJson-tB5m0_yh.js","Check2Icon-CeP__a4S.js","axios-CsQoIw0U.js","Markdown-LI7DSqeK.js","AssistantPageLink-bYxdsqKl.js","dist-DXTH2WLA.js","lib-DMeTj1gb.js","lib-B8HbPgcC.js","katex-Dbtb6Wk7.js","html-void-elements-mCSPHezU.js","marked.esm-CZWythHk.js"]}