Capabilities

Code completion

Code completion generates the text that belongs at the cursor, given the code before it and the code after it. This is called fill-in-the-middle (FIM), and it's what powers inline autocomplete in an editor: the model sees both sides of where you're typing and predicts the bit in between.

Send the text before the cursor as prompt and the text after it as suffix to /v1/completions. The completion comes back on choices[0].text.

Fill in the middle

import requests

resp = requests.post(
    "https://api.pendra.ai/v1/completions",
    headers={"Authorization": "Bearer pdr_sk_..."},
    json={
        "model": "qwen3-coder",
        # text before the cursor
        "prompt": "def add(a, b):\n    return ",
        # text after the cursor
        "suffix": "\n\nprint(add(2, 3))",
        "max_tokens": 32,
    },
)
print(resp.json()["choices"][0]["text"])
Response
a + b

The model returns just the missing middle — here, the body of add — so it slots cleanly between your prefix and suffix.

Prefix-only completion

Omit suffix to continue from the prompt alone — plain text completion with no cursor context. This works with any model; fill-in-the-middle additionally needs a model trained for it (see below).

Choosing a model

Fill-in-the-middle needs a code model that was trained with FIM support, such as qwen3-coder. If you send a suffix to a model that has no fill-in-the-middle support, the request is rejected with 422 — drop the suffix to fall back to prefix-only completion, or pick a code model. Browse the catalogue at /models.

Use it in your editor

Because /v1/completions is OpenAI-compatible, editor autocomplete extensions that speak the OpenAI API can point straight at Pendra. For example, in Continue (VS Code / JetBrains), set the tab-autocomplete model to your Pendra worker:

{
  "tabAutocompleteModel": {
    "title": "Pendra (Qwen Coder)",
    "provider": "openai",
    "model": "qwen3-coder",
    "apiBase": "https://api.pendra.ai/v1",
    "apiKey": "pdr_sk_..."
  }
}

Any tool that lets you set a custom OpenAI base URL and a completions model works the same way — give it https://api.pendra.ai/v1 and a pdr_sk_ API key.

Streaming

Set "stream": true to receive the completion as it's generated, as Server-Sent Events. Each event carries the next piece of text on choices[0].text, and the stream ends with a data: [DONE] line — the same streaming shape as chat.