Completions API
Inline code completion and OpenAI-compatible chat completion endpoints for drop-in integration with editors and tooling.
Inline Completions
/completeGenerate a code completion given a cursor position represented by a prefix and suffix. Requires Authorization: Bearer YOUR_API_KEY.
Request body
prefixstringbodyrequiredAll text before the cursor.
suffixstringbodyrequiredAll text after the cursor.
languagestringbodyrequiredLanguage identifier (e.g. typescript, python, go).
file_pathstringbodyRelative path of the file — used for additional context.
Response fields
completionstringThe text to insert at the cursor position.
finish_reasonstring"stop" — model finished naturally; "length" — truncated at token limit.
{
"prefix": "def calculate_total(items):\n total = 0\n for item in items:\n total += ",
"suffix": "\n return total",
"language": "python",
"file_path": "src/utils.py"
}{
"completion": "item.price * item.quantity",
"finish_reason": "stop"
}Inline completions are optimised for low latency. The model uses a fill-in-the-middle (FIM) prompt format internally — you only need to supply the raw prefix and suffix.
OpenAI-Compatible Chat Completions
/v1/chat/completionsA drop-in compatible endpoint for tools and libraries that target the OpenAI Chat Completions API. Requires Authorization: Bearer YOUR_API_KEY.
Request body
modelstringbodyrequiredModel identifier, e.g. misar-default.
messagesArray<{role, content}>bodyrequiredConversation messages with role (system, user, assistant) and content.
max_tokensnumberbodyMaximum tokens in the model response.
temperaturenumberbodySampling temperature.
streambooleanbodyWhen true, returns Server-Sent Events in the OpenAI delta format.
Response fields
idstringCompletion identifier, e.g. chatcmpl-abc123.
objectstringchat.completion for non-streaming, chat.completion.chunk for streamed deltas.
creatednumberUnix timestamp of creation.
modelstringThe model that produced the response.
choicesArray<object>Completion choices. Each contains index, message (or delta when streaming), and finish_reason.
usageobjectToken counts: prompt_tokens, completion_tokens, total_tokens.
{
"model": "misar-default",
"messages": [
{ "role": "system", "content": "You are a helpful coding assistant." },
{ "role": "user", "content": "Explain what a closure is in JavaScript." }
],
"max_tokens": 1024,
"temperature": 0.2,
"stream": true
}{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"created": 1740000000,
"model": "misar-default",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "A closure is a function that retains access to..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 42,
"completion_tokens": 198,
"total_tokens": 240
}
}Streaming
Set "stream": true to receive Server-Sent Events in the standard OpenAI delta format:
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"delta":{"content":"A closure"},"index":0}]}
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","choices":[{"delta":{"content":" is a"},"index":0}]}
data: [DONE]
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.misar.dev/v1"
)
response = client.chat.completions.create(
model="misar-default",
messages=[{"role": "user", "content": "Write a binary search in Python"}],
stream=True
)
for chunk in response:
print(chunk.choices[0].delta.content or "", end="")import OpenAI from "openai";
const client = new OpenAI({
apiKey: "YOUR_API_KEY",
baseURL: "https://api.misar.dev/v1",
});
const stream = await client.chat.completions.create({
model: "misar-default",
messages: [{ role: "user", content: "Write a binary search in TypeScript" }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}curl https://api.misar.dev/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "misar-default",
"messages": [{"role": "user", "content": "Write a binary search in Python"}],
"stream": true
}'Use base_url="https://api.misar.dev/v1" with any OpenAI-compatible SDK. The endpoint accepts the same request shape and returns the same response format.