Completions API
Inline code completion and OpenAI-compatible chat completion endpoints for drop-in integration with editors and tooling.
This is the MisarCoder gateway
These endpoints are served by the MisarCoder MoE gateway at https://api.misar.io/coder, not by the MisarDev product API at https://api.misar.io/dev. See the MisarCoder docs for the full gateway reference.
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 — misar-flash (fast), misar-pro (quality), or online (web-grounded synthesis via misar-flash). See Models.
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-flash",
"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-flash",
"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.io/coder/v1"
)
response = client.chat.completions.create(
model="misar-flash",
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.io/coder/v1",
});
const stream = await client.chat.completions.create({
model: "misar-flash",
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.io/coder/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "misar-flash",
"messages": [{"role": "user", "content": "Write a binary search in Python"}],
"stream": true
}'Use base_url="https://api.misar.io/coder/v1" with any OpenAI-compatible SDK. The endpoint accepts the same request shape and returns the same response format.
Models
misar-flash and misar-pro are Misar's own self-hosted models. The same two models are also published in the public assisters.dev catalogue.
| Model | Speed | Best for |
|---|---|---|
misar-flash | Fastest | Everyday chat, inline assistance, and low-latency tasks. |
misar-pro | Higher quality | Reasoning, longer answers, and quality-sensitive generation. |
online | — | Web-grounded synthesis: retrieves live web results, then answers with misar-flash. For structured answers with source citations, use the dedicated Search API instead. |
Text embeddings are produced by a local 768-dimension embedding model. It powers workspace RAG and is selected automatically — you do not pass it as a model.
Status codes
| Status | Meaning |
|---|---|
200 OK | Completion returned (or the SSE stream opened when stream: true). |
400 Bad Request | Malformed body, unknown model, or missing messages. |
401 Unauthorized | Missing, malformed, revoked, or wrong-product API key. |
429 Too Many Requests | Rate limit exceeded — retry after the Retry-After header. |
See Authentication for the product-binding rules that make a non-MisarDev key return 401.
WebSocket Chat API
Real-time streaming chat endpoint that powers the Misar Code agent loop — send messages, receive streamed content blocks, and handle tool invocations.
Search API
Web-grounded search-and-answer endpoint — returns a synthesized answer with inline url_citation source annotations, powered by live web retrieval and misar-pro.