SetuDocs

Completions (Fill-in-the-Middle)

Legacy-style text completions for editor autocomplete. Provide a prompt (the text before the cursor) and an optional suffix (the text after the cursor); the model returns the text to insert in between. Powered by the Nirman code model.

POST https://api.setu.dwet.ai/v1/completions

Request body

FieldTypeDescription
modelstringCode model ID, e.g. nirman-v1.
promptstringText before the cursor (prefix).
suffixstringOptional text after the cursor for fill-in-the-middle.
max_tokensintegerMaximum tokens to insert.

Example request

bash
curl https://api.setu.dwet.ai/v1/completions \
  -H "Authorization: Bearer $SETU_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "nirman-v1",
    "prompt": "function add(a, b) {\n  return ",
    "suffix": "\n}"
  }'

Example response

json
{
  "id": "cmpl-abc123",
  "object": "text_completion",
  "created": 1782033025,
  "model": "nirman-v1",
  "choices": [
    { "text": "a + b;", "index": 0, "logprobs": null, "finish_reason": "stop" }
  ],
  "usage": { "prompt_tokens": 12, "completion_tokens": 4, "total_tokens": 16 }
}

For chat-style coding (explain, refactor, debug) use Chat Completions with a code model. Billing is per token against the project that owns the key.