OpenAI-compatible endpoint
Call https://local.napcar.ai/v1 with OpenAI-style requests, synthesized in the browser and served locally.
Napcar synthesizes an OpenAI-compatible endpoint inside the browser. No DNS lookup or network request happens — the request is intercepted and served by the local model backend.
const response = await fetch("https://local.napcar.ai/v1/chat/completions", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-Napcar-LLM-Handoff": "required",
},
body: JSON.stringify({
model: "napcar-default",
messages: [{ role: "user", content: "Summarize this text locally." }],
stream: false,
}),
});
const completion = await response.json();
console.log(completion.choices[0].message.content);Endpoints
GET /v1/modelsPOST /v1/chat/completions(streaming + non-streaming)POST /v1/embeddingsPOST /v1/responses(best-effort subset)
Streaming
With stream: true, the response is Server-Sent Events compatible with standard
Chat Completions clients, terminated by data: [DONE].
data: {"id":"chatcmpl_napcar_…","object":"chat.completion.chunk","choices":[{"index":0,"delta":{"content":"Napcar"},"finish_reason":null}]}
data: {"id":"chatcmpl_napcar_…","object":"chat.completion.chunk","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]Behavior
- The endpoint requires the origin's local-AI permission, like the native API.
Authorizationheaders are ignored and never logged.- Model names are generic aliases by default; the exact model is hidden.
- Errors use the OpenAI error shape with a
napcar_local_ai_errortype and a Napcar errorcode, mapped to the appropriate HTTP status.