{ "mergedCode": "function calculateTotal(items) {\n let total = 0;\n \n for (const item of items) {\n total += item.price * item.quantity;\n }\n \n return total;\n}\n\nfunction applyDiscount(total, discountRules) {\n let discountedTotal = total;\n \n if (discountRules.percentOff) {\n discountedTotal -= (total * discountRules.percentOff / 100);\n }\n \n if (discountRules.fixedAmount && discountRules.fixedAmount < discountedTotal) {\n discountedTotal -= discountRules.fixedAmount;\n }\n \n return Math.max(0, discountedTotal);\n}", "usage": { "prompt_tokens": 245, "completion_tokens": 187, "total_tokens": 432 }}
{
"error": "Invalid JSON in the request body."
}
{
"error": "Invalid API key. Check the key, or create one at https://app.relace.ai."
}
{
"error": "Out of credits. Add credits at https://app.relace.ai to continue."
}
{
"error": "Route not found: POST /v1/code/edit"
}
{
"error": "Rate limit exceeded. Retry after the Retry-After interval, or contact support to raise your limits."
}
{
"error": "Internal server error."
}
{
"error": "Model server error; retry shortly."
}
{
"error": "Model 'relace-apply-3' is temporarily unavailable; retry shortly."
}
{
"error": "Request to the model timed out after 60s."
}
Relace Apply runs at over 10,000 tok/s, making complicated code merges feel instantaneous.
Models
We have deprecated all previous versions of the apply models in favor of relace-apply-3, which is more performant on accuracy, speed, and long context requests.
Model
Speed
Max Input
Max Output
relace-apply-3
~10k tokens/s
128k tokens
128k tokens
OpenAI Compatible Endpoint
If the Relace REST API is inconvenient, we also support an OpenAI compatible endpoint for our apply models.
The user message must include <code> and <update> tags following the format above. The <instruction> tag is optional.
OpenRouter
Relace Apply is also available via OpenRouter’s OpenAI-compatible endpoint. See the model page for current availability and details.The performance section of the model page shows our real-time throughput and latency numbers from customer requests.
Fallbacks
We recommend using GPT-4.1-mini with predictive edits as a fallback. This option is 10-20x slower than Relace’s apply models, but it’s useful for redundancy.Relace apply models also return a 400 error code when input exceeds context limits (see table above). For these cases, GPT-4o-mini’s 1M token context window is a reliable fallback option.However, even frontier LLMs struggle with long context. We recommend proactive refactoring of files >32k tokens to improve output quality.
Authorizations
Authorization
string
header
required
Relace API key Authorization header using the Bearer scheme.
Body
application/json
Initial code and edits to apply
initial_code
string
required
The original code that needs to be modified
edit_snippet
string
required
The code changes to be applied to the initial code
model
enum<string>
default:relace-apply-3
Choice of apply model to use
Available options:
relace-apply-3
instruction
string
Optional single line instruction for to disambiguate the edit snippet. e.g.Remove the captcha from the login page
stream
boolean
default:false
Whether to stream the response back
relace_metadata
object
Optional metadata for logging and tracking purposes.
Response
Code successfully applied
mergedCode
string
The merged code with the changes applied
usage
object
Token usage information for the request
Show child attributes
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Relace","colors":{"primary":"#0066FF","light":"#4D94FF","dark":"#0047B3"},"logo":{"light":"https://mintcdn.com/relace/db9WpuNCcZDHVmZO/logo/light.svg?fit=max\u0026auto=format\u0026n=db9WpuNCcZDHVmZO\u0026q=85\u0026s=8fb6212c3f7e36d063d878a98d7cff90","dark":"https://mintcdn.com/relace/db9WpuNCcZDHVmZO/logo/dark.svg?fit=max\u0026auto=format\u0026n=db9WpuNCcZDHVmZO\u0026q=85\u0026s=978d07312f6ac13f58c22aaa151579ea","href":"https://relace.ai"},"favicon":"https://mintcdn.com/relace/s7F5Z9LGe0g03FCB/favicon.svg?fit=max\u0026auto=format\u0026n=s7F5Z9LGe0g03FCB\u0026q=85\u0026s=b1aef1a2a6e6df815b78fc4d767560ef","navbar":{"links":[{"href":"mailto:info@relace.ai","label":"Support"}],"primary":{"type":"button","label":"Playground","href":"https://app.relace.ai"}},"footer":{"socials":{"linkedin":"https://www.linkedin.com/company/relace-ai"}},"integrations":{"posthog":{"apiKey":"phc_guqCHgvq8r5z5YETZZ5q6394qFrzl7M7W516jUCklUq","sessionRecording":true}},"contextual":{"options":["copy"],"display":"header"},"styling":{"latex":false},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"relace","hasAudioNarration":false,"actualSubdomain":"relace","customDomains":["docs.relace.ai"],"gitSource":{"type":"github","owner":"squack-io","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"feedback":{"edits":true,"issues":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6af36054be16eed08391ff47","clientVersion":"0.0.4143","searchFilterCounts":[{"language":"default","tag":"API Reference","count":8},{"language":"default","tag":"Documentation","count":8},{"language":"default","tag":"Model Guides","count":5},{"language":"default","tag":"Open Models","count":4},{"language":"default","tag":"Relace Models","count":3},{"language":"default","tag":"Instant Apply","count":3},{"language":"default","tag":"General","count":2},{"language":"default","tag":"Agents","count":2},{"language":"default","tag":"Fast Agentic Search","count":2},{"language":"default","tag":"Guides","count":2}]},"assistantConfig":{},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"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":"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":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[],"page":{"pagePath":"api-reference/instant-apply/apply","slug":"/api-reference/instant-apply/apply","pageMetadata":{"title":"Apply Code","openapi":"POST /v1/code/apply","description":"Merge code snippets from an LLM into your existing codebase.","href":"/api-reference/instant-apply/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: \"Merge code snippets from an LLM into your existing codebase.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,p:`p`,pre:`pre`,span:`span`,strong:`strong`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,..._provideComponents(),...props.components},{CodeBlock,Heading,Table,Warning}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Table)_missingMdxReference(`Table`,true);if(!Warning)_missingMdxReference(`Warning`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`Relace Apply runs at over `,_jsx(_components.strong,{children:`10,000 tok/s`}),`, making complicated code merges feel instantaneous.`]}),`\n`,_jsx(Heading,{level:`2`,id:`models`,children:`Models`}),`\n`,_jsxs(_components.p,{children:[`We have deprecated all previous versions of the apply models in favor of `,_jsx(_components.code,{children:`relace-apply-3`}),`, which is more performant on accuracy, speed, and long context requests.`]}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{style:{textAlign:`left`},children:`Model`}),_jsx(_components.th,{style:{textAlign:`left`},children:`Speed`}),_jsx(_components.th,{style:{textAlign:`left`},children:`Max Input`}),_jsx(_components.th,{style:{textAlign:`left`},children:`Max Output`})]})}),_jsx(_components.tbody,{children:_jsxs(_components.tr,{children:[_jsx(_components.td,{style:{textAlign:`left`},children:_jsx(_components.code,{children:`relace-apply-3`})}),_jsx(_components.td,{style:{textAlign:`left`},children:`~10k tokens/s`}),_jsx(_components.td,{style:{textAlign:`left`},children:`128k tokens`}),_jsx(_components.td,{style:{textAlign:`left`},children:`128k tokens`})]})})]}),`\n`,_jsx(Heading,{level:`2`,id:`openai-compatible-endpoint`,children:`OpenAI Compatible Endpoint`}),`\n`,_jsx(_components.p,{children:`If the Relace REST API is inconvenient, we also support an OpenAI compatible endpoint for our apply models.`}),`\n`,_jsx(CodeBlock,{filename:``,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:` client`}),_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://models.relace.ai/v1/apply'`}),_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:` userMessage`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},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:`\u003cinstruction>{instruction}\u003c/instruction>`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\u003ccode>{initial_code}\u003c/code>`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\u003cupdate>{edit_snippet}\u003c/update>`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_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:` client`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`chat`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`completions`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`create`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` model:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'relace-apply-3'`}),_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:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` userMessage`}),_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`]})})}),`\n`,_jsx(Warning,{children:_jsxs(_components.p,{children:[`The user message must include `,_jsx(_components.code,{children:`\u003ccode>`}),` and `,_jsx(_components.code,{children:`\u003cupdate>`}),` tags following the format above. The `,_jsx(_components.code,{children:`\u003cinstruction>`}),` tag is optional.`]})}),`\n`,_jsx(Heading,{level:`3`,id:`openrouter`,children:`OpenRouter`}),`\n`,_jsxs(_components.p,{children:[`Relace Apply is also available via OpenRouter’s OpenAI-compatible endpoint. See the `,_jsx(_components.a,{href:`https://openrouter.ai/relace/relace-apply-3`,children:`model page`}),` for current availability and details.`]}),`\n`,_jsxs(_components.p,{children:[`The `,_jsx(_components.a,{href:`https://openrouter.ai/relace/relace-apply-3/performance`,children:`performance`}),` section of the model page shows our real-time throughput and latency numbers from customer requests.`]}),`\n`,_jsx(Heading,{level:`2`,id:`fallbacks`,children:`Fallbacks`}),`\n`,_jsxs(_components.p,{children:[`We recommend using GPT-4.1-mini with `,_jsx(_components.a,{href:`https://platform.openai.com/docs/guides/predicted-outputs`,children:`predictive edits`}),` as a fallback. This option is 10-20x slower than Relace’s apply models, but it’s useful for redundancy.`]}),`\n`,_jsxs(_components.p,{children:[`Relace apply models also return a `,_jsx(_components.code,{children:`400`}),` error code when input exceeds context limits (see table above). For these cases, GPT-4o-mini’s 1M token context window is a reliable fallback option.`]}),`\n`,_jsx(_components.p,{children:`However, even frontier LLMs struggle with long context. We recommend proactive refactoring of files >32k tokens to improve output quality.`})]})}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 Code","openapi":"POST /v1/code/apply","description":"Merge code snippets from an LLM into your existing codebase.","href":"/api-reference/instant-apply/apply"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Models","slug":"models","depth":2,"children":[]},{"title":"OpenAI Compatible Endpoint","slug":"openai-compatible-endpoint","depth":2,"children":[{"title":"OpenRouter","slug":"openrouter","depth":3,"children":[]}]},{"title":"Fallbacks","slug":"fallbacks","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"openApiReferenceData":{"operation":{"description":"Merge code snippets from an LLM into your existing codebase.","servers":["0009f461-8f78-451f-b398-f5947574de18"],"requestBody":"8bba330d-935f-4f53-b1a1-d2f0e83d0810","responses":{"200":"082110aa-fd7a-43df-b9a1-7a90c162da19","400":"e0523c9d-d825-4153-a9e7-d8a45a10f8dd","401":"3fa9b079-d940-4845-acc4-d98563597c9d","402":"68f22f58-b088-4137-b972-1a97630d57bc","404":"b89de290-5e92-45b7-afda-1f7773c97414","429":"e70228b8-c72c-4283-949e-bcee6570304a","500":"9a88c9d7-3aa4-4a42-8e6c-bc4599cdd5e7","502":"46aa5785-7c6f-47e1-ab41-98ac81b25582","503":"a9ca393a-ae2f-4cdb-9f4b-72218e055e7e","504":"1892c44a-8f7b-4bc3-a0f5-f4de6ba667c4"},"method":"post","type":"path","security":["48042cb2-e5de-4606-be75-11f4f8c4ac25"],"path":"/v1/code/apply","baseUrlOptions":["https://models.relace.ai"],"title":"","codeSamples":[],"requiredOnlyExamples":false,"requestExampleType":"generated","responseExampleType":"generated"},"dependencies":{"parameters":{},"requestBody":{"description":"Initial code and edits to apply","required":true,"content":{"application/json":{"schema":{"type":"object","required":["initial_code","edit_snippet"],"properties":{"initial_code":{"type":"string","description":"The original code that needs to be modified","isRequired":true,"uniqueKey":"initial_code","typeLabel":"string"},"edit_snippet":{"type":"string","description":"The code changes to be applied to the initial code","isRequired":true,"uniqueKey":"edit_snippet","typeLabel":"string"},"model":{"type":"string","description":"Choice of apply model to use","enum":["relace-apply-3"],"default":"relace-apply-3","uniqueKey":"model","typeLabel":"enum\u003cstring>"},"instruction":{"type":"string","description":"Optional single line instruction for to disambiguate the edit snippet. *e.g.* `Remove the captcha from the login page`","uniqueKey":"instruction","typeLabel":"string"},"stream":{"type":"boolean","description":"Whether to stream the response back","default":false,"uniqueKey":"stream","typeLabel":"boolean"},"relace_metadata":{"type":"object","description":"Optional metadata for logging and tracking purposes.","additionalProperties":true,"uniqueKey":"relace_metadata","typeLabel":"object"}},"uniqueKey":"","typeLabel":"object"},"example":{"initial_code":"function calculateTotal(items) {\n let total = 0;\n \n for (const item of items) {\n total += item.price * item.quantity;\n }\n \n return total;\n}","edit_snippet":"// ... keep existing code\n\nfunction applyDiscount(total, discountRules) {\n let discountedTotal = total;\n \n if (discountRules.percentOff) {\n discountedTotal -= (total * discountRules.percentOff / 100);\n }\n \n if (discountRules.fixedAmount \u0026\u0026 discountRules.fixedAmount \u003c discountedTotal) {\n discountedTotal -= discountRules.fixedAmount;\n }\n \n return Math.max(0, discountedTotal);\n}","stream":false},"examples":{"Example":{"title":"Example","value":{"initial_code":"function calculateTotal(items) {\n let total = 0;\n \n for (const item of items) {\n total += item.price * item.quantity;\n }\n \n return total;\n}","edit_snippet":"// ... keep existing code\n\nfunction applyDiscount(total, discountRules) {\n let discountedTotal = total;\n \n if (discountRules.percentOff) {\n discountedTotal -= (total * discountRules.percentOff / 100);\n }\n \n if (discountRules.fixedAmount \u0026\u0026 discountRules.fixedAmount \u003c discountedTotal) {\n discountedTotal -= discountRules.fixedAmount;\n }\n \n return Math.max(0, discountedTotal);\n}","stream":false}}},"exampleType":"examples"}},"exampleType":"examples"},"responses":{"082110aa-fd7a-43df-b9a1-7a90c162da19":{"description":"Code successfully applied","content":{"application/json":{"schema":{"type":"object","properties":{"mergedCode":{"type":"string","description":"The merged code with the changes applied","uniqueKey":"mergedCode","typeLabel":"string"},"usage":{"type":"object","properties":{"prompt_tokens":{"type":"integer","description":"Number of tokens in the prompt","uniqueKey":"usage.prompt_tokens","typeLabel":"integer"},"completion_tokens":{"type":"integer","description":"Number of tokens in the completion","uniqueKey":"usage.completion_tokens","typeLabel":"integer"},"total_tokens":{"type":"integer","description":"Total number of tokens used","uniqueKey":"usage.total_tokens","typeLabel":"integer"}},"description":"Token usage information for the request","uniqueKey":"usage","typeLabel":"object"}},"example":{"mergedCode":"function calculateTotal(items) {\n let total = 0;\n \n for (const item of items) {\n total += item.price * item.quantity;\n }\n \n return total;\n}\n\nfunction applyDiscount(total, discountRules) {\n let discountedTotal = total;\n \n if (discountRules.percentOff) {\n discountedTotal -= (total * discountRules.percentOff / 100);\n }\n \n if (discountRules.fixedAmount \u0026\u0026 discountRules.fixedAmount \u003c discountedTotal) {\n discountedTotal -= discountRules.fixedAmount;\n }\n \n return Math.max(0, discountedTotal);\n}","usage":{"prompt_tokens":245,"completion_tokens":187,"total_tokens":432}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"mergedCode":"function calculateTotal(items) {\n let total = 0;\n \n for (const item of items) {\n total += item.price * item.quantity;\n }\n \n return total;\n}\n\nfunction applyDiscount(total, discountRules) {\n let discountedTotal = total;\n \n if (discountRules.percentOff) {\n discountedTotal -= (total * discountRules.percentOff / 100);\n }\n \n if (discountRules.fixedAmount \u0026\u0026 discountRules.fixedAmount \u003c discountedTotal) {\n discountedTotal -= discountRules.fixedAmount;\n }\n \n return Math.max(0, discountedTotal);\n}","usage":{"prompt_tokens":245,"completion_tokens":187,"total_tokens":432}}}},"exampleType":"generated"},"text/event-stream":{"schema":{"type":"string","description":"Stream of results from the Instant Apply model (compatible with OpenAI streaming format)","uniqueKey":"","typeLabel":"string"},"examples":{"Example":{"title":"Example","value":"\u003cstring>"}},"exampleType":"generated"}},"exampleType":"generated"},"e0523c9d-d825-4153-a9e7-d8a45a10f8dd":{"description":"Bad request","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message","example":"Invalid JSON in the request body.","uniqueKey":"error","typeLabel":"string"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":"Invalid JSON in the request body."}}},"exampleType":"generated"}},"exampleType":"generated"},"3fa9b079-d940-4845-acc4-d98563597c9d":{"description":"Unauthorized","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message","example":"Invalid API key. Check the key, or create one at https://app.relace.ai.","uniqueKey":"error","typeLabel":"string"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":"Invalid API key. Check the key, or create one at https://app.relace.ai."}}},"exampleType":"generated"}},"exampleType":"generated"},"68f22f58-b088-4137-b972-1a97630d57bc":{"description":"Out of credits, or no payment method on the account","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message","example":"Out of credits. Add credits at https://app.relace.ai to continue.","uniqueKey":"error","typeLabel":"string"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":"Out of credits. Add credits at https://app.relace.ai to continue."}}},"exampleType":"generated"}},"exampleType":"generated"},"b89de290-5e92-45b7-afda-1f7773c97414":{"description":"Route not found","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message","example":"Route not found: POST /v1/code/edit","uniqueKey":"error","typeLabel":"string"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":"Route not found: POST /v1/code/edit"}}},"exampleType":"generated"}},"exampleType":"generated"},"e70228b8-c72c-4283-949e-bcee6570304a":{"description":"Rate limit exceeded, or the model is at capacity","headers":{"Retry-After":{"schema":{"type":"string"},"description":"Seconds to wait before retrying"}},"content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message","example":"Rate limit exceeded. Retry after the Retry-After interval, or contact support to raise your limits.","uniqueKey":"error","typeLabel":"string"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":"Rate limit exceeded. Retry after the Retry-After interval, or contact support to raise your limits."}}},"exampleType":"generated"}},"exampleType":"generated"},"9a88c9d7-3aa4-4a42-8e6c-bc4599cdd5e7":{"description":"Internal server error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message","example":"Internal server error.","uniqueKey":"error","typeLabel":"string"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":"Internal server error."}}},"exampleType":"generated"}},"exampleType":"generated"},"46aa5785-7c6f-47e1-ab41-98ac81b25582":{"description":"Model server error","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message","example":"Model server error; retry shortly.","uniqueKey":"error","typeLabel":"string"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":"Model server error; retry shortly."}}},"exampleType":"generated"}},"exampleType":"generated"},"a9ca393a-ae2f-4cdb-9f4b-72218e055e7e":{"description":"Model temporarily unavailable","headers":{"Retry-After":{"schema":{"type":"string"},"description":"Seconds to wait before retrying"}},"content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message","example":"Model 'relace-apply-3' is temporarily unavailable; retry shortly.","uniqueKey":"error","typeLabel":"string"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":"Model 'relace-apply-3' is temporarily unavailable; retry shortly."}}},"exampleType":"generated"}},"exampleType":"generated"},"1892c44a-8f7b-4bc3-a0f5-f4de6ba667c4":{"description":"Request to the model timed out","content":{"application/json":{"schema":{"type":"object","properties":{"error":{"type":"string","description":"Error message","example":"Request to the model timed out after 60s.","uniqueKey":"error","typeLabel":"string"}},"uniqueKey":"","typeLabel":"object"},"examples":{"Example":{"title":"Example","value":{"error":"Request to the model timed out after 60s."}}},"exampleType":"generated"}},"exampleType":"generated"}},"security":{"48042cb2-e5de-4606-be75-11f4f8c4ac25":{"bearerAuth":{"type":"http","scheme":"bearer","description":"Relace API key Authorization header using the Bearer scheme.","scopes":[],"schemeName":"bearerAuth"}}},"servers":{"0009f461-8f78-451f-b398-f5947574de18":{"url":"https://models.relace.ai"}},"processedSecurityOptions":[{"schemes":[{"scheme":{"type":"http","scheme":"bearer","description":"Relace API key Authorization header using the Bearer scheme.","scopes":[],"schemeName":"bearerAuth"},"schema":{"title":"Bearer Auth","type":"string","isRequired":true,"description":"Relace API key Authorization header using the Bearer scheme.","format":"bearer","typeLabel":"string\u003cbearer>","deprecated":false},"schemeName":"bearerAuth","name":"Authorization"}],"title":"bearerAuth"}]},"originalFileLocation":"api-reference/openapi.json"},"subdomain":"relace","siteName":"Relace","title":"Apply Code - Relace","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-08-06T16:33:29.654Z","originalFileLocation":"api-reference/instant-apply/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=\"Merge code snippets from an LLM into your existing codebase.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Relace\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/relace/NSKygUkcOPJ0dXD5/_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/relace/NSKygUkcOPJ0dXD5/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/relace/NSKygUkcOPJ0dXD5/_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/relace/NSKygUkcOPJ0dXD5/_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/relace/NSKygUkcOPJ0dXD5/_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/relace/NSKygUkcOPJ0dXD5/_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/relace/NSKygUkcOPJ0dXD5/_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/relace/NSKygUkcOPJ0dXD5/_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/relace/NSKygUkcOPJ0dXD5/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Apply Code - Relace\">\u003cmeta data-mint-head property=\"og:description\" content=\"Merge code snippets from an LLM into your existing codebase.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Relace\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.relace.ai/api-reference/instant-apply/apply\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://relace.mintlify.site/_mintlify/api/og/v2?division=Relace+Models\u0026amp;title=Apply+Code\u0026amp;description=Merge+code+snippets+from+an+LLM+into+your+existing+codebase.\u0026amp;theme=57c4eb56dcaa832310d126ad\u0026amp;signature=cbdec9cfd737cf48c9f4850fa70ebe58501252e9e3b492327722e21e0566d89e\">\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 Code - Relace\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Merge code snippets from an LLM into your existing codebase.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://relace.mintlify.site/_mintlify/api/og/v2?division=Relace+Models\u0026amp;title=Apply+Code\u0026amp;description=Merge+code+snippets+from+an+LLM+into+your+existing+codebase.\u0026amp;theme=57c4eb56dcaa832310d126ad\u0026amp;signature=cbdec9cfd737cf48c9f4850fa70ebe58501252e9e3b492327722e21e0566d89e\">\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/relace/NSKygUkcOPJ0dXD5/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Relace\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#0066FF\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.relace.ai/api-reference/instant-apply/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/instant-apply/apply.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://docs.relace.ai/#organization\",\"name\":\"Relace\",\"url\":\"https://docs.relace.ai\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/relace/db9WpuNCcZDHVmZO/logo/light.svg?fit=max\u0026auto=format\u0026n=db9WpuNCcZDHVmZO\u0026q=85\u0026s=8fb6212c3f7e36d063d878a98d7cff90\"}},{\"@type\":\"WebSite\",\"@id\":\"https://docs.relace.ai#website\",\"name\":\"Relace\",\"url\":\"https://docs.relace.ai\",\"publisher\":{\"@id\":\"https://docs.relace.ai/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.relace.ai/api-reference/instant-apply/apply#webpage\",\"url\":\"https://docs.relace.ai/api-reference/instant-apply/apply\",\"name\":\"Apply Code\",\"description\":\"Merge code snippets from an LLM into your existing codebase.\",\"dateModified\":\"2026-08-06T16:33:29.654Z\",\"isPartOf\":{\"@id\":\"https://docs.relace.ai#website\"},\"breadcrumb\":{\"@id\":\"https://docs.relace.ai/api-reference/instant-apply/apply#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.relace.ai/api-reference/instant-apply/apply#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Relace Models\",\"item\":\"https://docs.relace.ai/api-reference/compact/compact\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Apply Code\",\"item\":\"https://docs.relace.ai/api-reference/instant-apply/apply\"}]},{\"@type\":[\"TechArticle\",\"APIReference\"],\"@id\":\"https://docs.relace.ai/api-reference/instant-apply/apply#apireference\",\"headline\":\"Apply Code\",\"name\":\"Apply Code\",\"description\":\"Merge code snippets from an LLM into your existing codebase.\",\"url\":\"https://docs.relace.ai/api-reference/instant-apply/apply\",\"mainEntityOfPage\":{\"@id\":\"https://docs.relace.ai/api-reference/instant-apply/apply#webpage\"},\"dateModified\":\"2026-08-06T16:33:29.654Z\",\"publisher\":{\"@id\":\"https://docs.relace.ai/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.relace.ai#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Relace\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Relace\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/api-reference/instant-apply/apply.md","siteName":"Relace","nav":{"global":null,"anchors":[{"anchor":"Documentation","icon":"book-open","pages":[{"title":"Documentation","href":"/docs/introduction"}]},{"anchor":"API Reference","icon":"square-terminal","groups":[{"group":"General","pages":[{"title":"Introduction","href":"/api-reference/introduction"},{"title":"Errors","href":"/api-reference/errors"}]},{"group":"Relace Models","pages":[{"title":"Compact Trace","openapi":"POST /v1/code/compact","description":"Compress an agent trace to only the important details.","href":"/api-reference/compact/compact"},{"title":"Apply Code","openapi":"POST /v1/code/apply","href":"/api-reference/instant-apply/apply"},{"title":"Search Code","openapi":"POST /v1/search/chat/completions","description":"Run the Fast Agentic Search model (`relace-search`) one turn at a time through an OpenAI-compatible chat completions request. You supply the agent harness: the search tools and the code that executes them.","href":"/api-reference/fast-agentic-search/search"}]},{"group":"Open Models","pages":[{"title":"Chat Completions","openapi":"POST /v1/chat/completions","href":"/api-reference/open-models/chat-completions"},{"title":"Messages","openapi":"POST /v1/messages","href":"/api-reference/open-models/messages"},{"title":"List Models","openapi":"GET /v1/models","href":"/api-reference/open-models/list-models"}]}]}]},"basePath":"","title":"Apply Code - Relace","buildId":"dpl_Fyv1NbzwP68g2bEH2Roy98uY1zmE","deploymentId":"dpl_Fyv1NbzwP68g2bEH2Roy98uY1zmE","dynamics":["c2aa737661","2b790eda92","b0f84f53ff","a9bb46feb3"],"chunks":["OpenApiReferenceProvider-DdEMm2kG.js","utils-BMo572L7.js","cloneDeep-izs3Hzxb.js","_Uint8Array-BVIqJ90l.js","isObjectLike-C8vmzPEN.js","isArray-Dcu1dQ5t.js","utils-C-4m9KAx.js","toString-BX-iyh8G.js","isSymbol-CSH9U2Gm.js","addUniqueKeysToSchema-DPLK2Oq9.js","snippetPresets-BKjfJMC9.js","style-to-object-BY3JEAdk.js","v4-DIgz8zy6.js","conditional-requirements-CFM0id0Q.js","ApiExamples-DTsgtCEj.js","isEqual-BfaiBbcl.js","usePlaygroundInputsStore-C8vmhyQM.js","shallow-r9w8LQGS.js","getApiPlaygroundDisplay-DjPI64HQ.js","CodeSnippet-C8Bvhl16.js","CodeSnippets-BtWUwcMy.js","Page-BIYvYBgk.js","getPastedJson-Dcm_3Pgl.js","icon-BXwrTpjc.js","MethodPill-CcjfVmmy.js","DuplicateIcon-BuKIbXAQ.js","createIcon-DaL9yXsO.js","DynamicMarkdown-Co5nikxh.js","SectionHeading-P4UNTsMZ.js","axios-vUo_bRtp.js","Markdown-CEfymfIH.js","clsx-Dq9TQuNi.js","lib-DuNMoZ05.js","lib-B8HbPgcC.js","html-void-elements-mCSPHezU.js","dist-D2J8knkn.js","katex-YMM-FMeD.js","marked.esm-CZWythHk.js","AssistantPageLink-BgZ2ThuU.js"]}