FIM Completion (Beta)
DeepSeek releases FIM (Fill In the Middle) completion in beta, allowing developers to provide prefix and suffix context for code and content generation via the deepseek-v4-pro model.
In FIM (Fill In the Middle) completion, users can provide a prefix and suffix (optional), and the model completes the content in the middle. FIM is commonly used for content continuation, code completion, and other scenarios. Notes The model's maximum completion length is 4K. Users need to set base_url="https://api.deepseek.com/beta" to enable Beta features. Sample Code Below is a complete Python code example for FIM completion. In this example, we provide the beginning and end of a Fibonacci sequence function to let the model complete the middle content.
from openai import OpenAI client = OpenAI( api_key="", base_url="https://api.deepseek.com/beta", ) response = client.completions.create( model="deepseek-v4-pro", prompt="def fib(a):", suffix=" return fib(a-1) + fib(a-2)", max_tokens=128 ) print(response.choices[0].text) Configure Continue Code Completion Plugin Continue is a VSCode plugin that supports code completion. You can refer to this documentation to configure Continue to use code completion features.
- api-docs.deepseek.comFIM Completion (Beta)primary