{"uid":"cap_-Ax5pH9rmslXxZb28wO0G","slug":"deepseek-fim-4f33c19d","name":"DeepSeek FIM (Fill-In-the-Middle)","description":"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.","url":"https://deepseek.mpp.paywithlocus.com/deepseek/fim?utm_source=zero.xyz","method":"POST","headers":{},"bodySchema":{"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},"responseSchema":null,"example":{"request":{"model":"deepseek-chat","prompt":"def greet(name):\n    ","suffix":"\n    return greeting","max_tokens":128,"temperature":0.7},"response":{"data":{"id":"70da2686-2ed0-4cae-ba54-ce9ab626e56e","model":"deepseek-v4-flash","usage":{"total_tokens":24,"prompt_tokens":13,"completion_tokens":11,"prompt_tokens_details":{"cached_tokens":0},"prompt_cache_hit_tokens":0,"prompt_cache_miss_tokens":13},"object":"text_completion","choices":[{"text":"greeting = f\"Hello, {name}!\"","index":0,"logprobs":null,"finish_reason":"stop"}],"created":1781064045,"system_fingerprint":"fp_8b330d02d0_prod0820_fp8_kvcache_20260402"},"success":true}},"exampleRequest":{"model":"deepseek-chat","prompt":"def greet(name):\n    ","suffix":"\n    return greeting","max_tokens":128,"temperature":0.7},"tags":["llm","reasoning","code","chat","chain-of-thought","ai"],"displayCostAmount":"0.004","displayCostAsset":"USDC","priceDynamic":true,"priceHint":"Token dependent (~$0.003–$0.005)","priceStatus":"priced","priceSource":"settled","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"dynamic","summary":"Token dependent (~$0.003–$0.005) (dynamic)","primary":{"kind":"dynamic","protocol":"mpp","network":"tempo","amountUsd":"0.003","per":"call","confidence":"exact"},"accepted":[{"kind":"dynamic","protocol":"mpp","network":"tempo","amountUsd":"0.003","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_GAuISrN6GfDuDYtGuBpQh","protocol":"mpp","methodType":"crypto","chain":"tempo","mode":"charge","costAmount":"0.003","costPer":"request","priority":0,"asset":"0x20c000000000000000000000b9537d11c60e8b50","unit":"request","depositMicros":null,"planRef":null}],"brandName":"DeepSeek","brandSlug":"deepseek","brandBaseUrl":"https://deepseek.com","brandDocsUrl":"https://api-docs.deepseek.com","whatItDoes":"Completes code at a cursor position by filling text between a given prefix (prompt) and suffix using DeepSeek's deepseek-chat model.","exampleAgentPrompt":"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.","exampleUseCases":null,"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-12T06:39:16.042Z","isFirstParty":false,"canonicalSlug":"deepseek-fim-4f33c19d"}