Features
Prefix Completion
Continue generation from prefilled assistant content to control templates, formats, and fixed openings.
Prefix completion lets the model continue after an application-provided assistant prefix. Use it for fixed openings, code scaffolding, or a specific output format.
Not a universal OpenAI Chat Completions field.
prefixis an extension supported by some platforms or models. APIQIK support, model coverage, and the exact request structure must be confirmed before publishing an integration.
Request template
{
"model": "<prefix-capable-model-id>",
"messages": [
{
"role": "user",
"content": "Write a Python function that checks whether an integer is prime."
},
{
"role": "assistant",
"content": "def is_prime(n: int) -> bool:\n ",
"prefix": true
}
],
"max_tokens": 300
}Typical use cases
| Scenario | Prefix example | Goal |
|---|---|---|
| Code generation | Function signature or class definition | Continue an existing interface without unrelated explanation. |
| Format control | Fixed beginning of JSON, Markdown, or SQL | Improve format consistency. |
| Brand copy | Fixed title or disclaimer | Keep required content at the beginning. |
| Conversation guidance | Opening that establishes the assistant's tone | Reduce style drift. |
Limitations
- Long prefixes consume context and increase costs.
- Prefixes must match the task to avoid semantic or syntax conflicts.
- Code prefixes should include required indentation and line breaks; validate the result with compilation or tests.
- If the model does not support this extension, use clear instructions or a supported FIM capability.