# DeepSeek FIM (Fill-In-the-Middle)

> DeepSeek FIM (Fill-In-the-Middle) is a paid API for AI agents from DeepSeek at deepseek.mpp.paywithlocus.com, paid per call via MPP, Token dependent (~$0.003–$0.005) (dynamic), status unknown (last checked 2026-10-12).

Completes code at a cursor position by filling text between a given prefix (prompt) and suffix using DeepSeek's deepseek-chat model.

## Facts

- Endpoint: POST https://deepseek.mpp.paywithlocus.com/deepseek/fim?utm_source=zero.xyz
- Price: Token dependent (~$0.003–$0.005) (dynamic)
- Payment: MPP
- Status: unknown
- Last checked: 2026-10-12
- Activations on Zero: 0
- Provider: DeepSeek
- Docs: https://api-docs.deepseek.com
- Website: https://deepseek.com
- Tags: llm, reasoning, code, chat, chain-of-thought, ai
- Canonical page: https://www.zero.xyz/c/deepseek-fim-4f33c19d
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_-Ax5pH9rmslXxZb28wO0G

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability deepseek-fim-4f33c19d -d '<json body>'
```

Example prompt: Use DeepSeek FIM to fill in the missing code between this prefix 'def calculate_sum(a, b):\n    ' and this suffix '\n    return result' — generate up to 128 tokens with temperature 0.7.

## When to prefer this

Use this endpoint when you need to insert or complete code at a specific cursor location with known surrounding context (both prefix and suffix). Ideal for IDE-like code completion workflows, auto-fill tasks, or generating a function body when you already have the signature and closing structure. Prefer this over standard chat completions when the fill-in-the-middle pattern is required rather than open-ended generation.

## Known failure modes

- Model not supported: only deepseek-chat supports FIM; passing other model names returns an error
- Missing required 'prompt' field causes a 400 validation error
- Token limit exceeded if max_tokens is set too high for the plan
- Rate limiting or quota errors if too many requests are sent
- Empty or ambiguous prefix/suffix may produce irrelevant completions
- Temperature out of valid range may cause parameter validation failure

## How this service works

Code completion with fill-in-the-middle — provide a code prefix and optional suffix, and DeepSeek fills in the middle. Ideal for copilot-style code generation. Metered x402 supports deepseek-v4-pro.

## Output

Returns a generated code string that fills the gap between the provided prompt (prefix) and suffix, completing the code at the cursor position as if writing the middle of a code block.

## Example request

```json
{
 "model": "deepseek-chat",
 "prompt": "def greet(name):\n    ",
 "suffix": "\n    return greeting",
 "max_tokens": 128,
 "temperature": 0.7
}
```

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "required": [
  "model",
  "prompt",
  "max_tokens"
 ],
 "properties": {
  "model": {
   "type": "string",
   "description": "Must be deepseek-v4-pro for metered x402 FIM"
  },
  "prompt": {
   "type": "string",
   "description": "The code prefix to complete"
  },
  "suffix": {
   "type": "string",
   "description": "The code suffix (text after the cursor). DeepSeek fills between prompt and suffix."
  },
  "max_tokens": {
   "type": "number",
   "description": "Maximum tokens to generate (up to 384000). Required to bound metered x402 authorization."
  },
  "temperature": {
   "type": "number",
   "description": "Sampling temperature. Default: 1."
  }
 },
 "additionalProperties": true
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/deepseek-fim-4f33c19d/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from deepseek.mpp.paywithlocus.com](https://www.zero.xyz/host/deepseek.mpp.paywithlocus.com/llms.txt)
