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
| Field | Type | Description |
|---|---|---|
model | string | Code model ID, e.g. nirman-v1. |
prompt | string | Text before the cursor (prefix). |
suffix | string | Optional text after the cursor for fill-in-the-middle. |
max_tokens | integer | Maximum 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.