DeepSeek FIM Completion
deepseek_fimProvide a prefix and optional suffix to generate missing text in between. Ideal for code completion and content infilling.
Instructions
Fill-in-the-Middle (FIM) completion with DeepSeek V4. Provide a prompt (prefix) and an optional suffix; the model completes the text in between. Ideal for code completion and content infilling. Runs in non-thinking mode on the Beta endpoint; output is capped at 4K tokens. Aliases deepseek-chat and deepseek-reasoner resolve to deepseek-v4-flash (FIM has no thinking mode). Includes automatic cost tracking and model fallback with circuit breaker resilience.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| stop | No | Optional stop sequence(s). Generation stops when any is produced. A single string or an array of up to 16 strings. | |
| model | No | Model to use. deepseek-v4-flash (default, fast/economical) or deepseek-v4-pro (most capable). Aliases deepseek-chat / deepseek-reasoner resolve to v4-flash. FIM is always non-thinking. | deepseek-v4-flash |
| prompt | Yes | The prefix text that comes before the content to generate. Required. For code completion, this is the code up to the cursor. | |
| suffix | No | Optional suffix text that comes after the content to generate. The model fills the gap between prompt and suffix. | |
| max_tokens | No | Maximum tokens to generate. FIM completions are capped at 4096 tokens by the API. | |
| temperature | No | Sampling temperature (0-2). Higher = more random. Default: 1.0. |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| text | Yes | ||
| model | Yes | ||
| usage | Yes | ||
| cost_usd | No | ||
| routed_from | No | ||
| finish_reason | Yes |