Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

docs: local api servers

Louisddfa7477ddc5
diff --git a/docs/src/pages/docs/desktop/_meta.json b/docs/src/pages/docs/desktop/_meta.json
index a538501c0..8eaa19ed0 100644
--- a/docs/src/pages/docs/desktop/_meta.json
+++ b/docs/src/pages/docs/desktop/_meta.json
@@ -19,6 +19,7 @@
"file-upload": "File Upload",
"manage-models": "Hub",
"mcp-examples": "Connectors (MCP)",
+ "api-server": "Local API Server",
"settings": "App Settings",
"local-engine": "Local AI Engine",
"model-parameters": "Model Parameters",
@@ -27,12 +28,13 @@
"display": "hidden",
"title": "Privacy Policy"
},
- "localserver": {
- "title": "Local Server",
+ "janservers": {
+ "title": "Jan Servers",
"type": "separator"
},
- "api-server": "Server Setup",
+ "api-preference": "API Preference",
"llama-cpp-server": "LlamaCpp Server",
+ "mlx-server": "MLX Server",
"server-troubleshooting": "Server Troubleshooting",
"server-examples": "Clients",
"reference-separator": {
diff --git a/docs/src/pages/docs/desktop/api-preference.mdx b/docs/src/pages/docs/desktop/api-preference.mdx
new file mode 100644
index 000000000..679ed601e
--- /dev/null
+++ b/docs/src/pages/docs/desktop/api-preference.mdx
@@ -0,0 +1,118 @@
+---
+title: API Preference
+description: API endpoints supported by Jan's local API server
+keywords:
+ [
+ Jan,
+ local API,
+ OpenAI,
+ chat completions,
+ API endpoints,
+ v1,
+ local AI,
+ ]
+---
+
+import { Callout } from 'nextra/components'
+import { DocCard, DocCards } from '@/components/DocCard'
+import { Bot, Code2 } from 'lucide-react'
+
+# API Preference
+
+Jan's local API server exposes an OpenAI-compatible REST API at `http://127.0.0.1:1337`. Use it as a drop-in replacement for cloud APIs in any application that supports OpenAI-compatible endpoints.
+
+## Supported Endpoints
+
+### `GET /v1/models`
+
+Returns a list of all models currently loaded or available in Jan.
+
+```bash
+curl http://127.0.0.1:1337/v1/models \
+ -H "Authorization: Bearer YOUR_API_KEY"
+```
+
+```json
+{
+ "object": "list",
+ "data": [
+ { "id": "jan-v3-4b-base-instruct", "object": "model" }
+ ]
+}
+```
+
+---
+
+### `POST /v1/chat/completions`
+
+OpenAI-compatible chat completions endpoint. Supports streaming, tool calling, and multi-turn conversations.
+
+```bash
+curl http://127.0.0.1:1337/v1/chat/completions \
+ -H "Content-Type: application/json" \
+ -H "Authorization: Bearer YOUR_API_KEY" \
+ -d '{
+ "model": "jan-v3-4b-base-instruct",
+ "messages": [{"role": "user", "content": "Hello!"}],
+ "stream": false
+ }'
+```
+
+---
+
+### `POST /v1/messages`
+
+Anthropic-compatible messages endpoint. Jan automatically translates requests to the internal format, so you can use Anthropic SDK clients pointed at your local server.
+
+```bash
+curl http://127.0.0.1:1337/v1/messages \
+ -H "Content-Type: application/json" \
+ -H "x-api-key: YOUR_API_KEY" \
+ -d '{
+ "model": "jan-v3-4b-base-instruct",
+ "max_tokens": 1024,
+ "messages": [{"role": "user", "content": "Hello!"}]
+ }'
+```
+
+---
+
+<Callout type="info">
+**OpenAI Responses API** (`/v1/responses`) support is coming soon.
+</Callout>
+
+## Use With Agents & Integrations
+
+Jan's local API is designed to wire directly into AI agents and coding tools — no cloud account needed.
+
+<DocCards cols={2}>
+ <DocCard title="Claude Code" href="/docs/desktop/integrations/claude-code" icon={<Code2 size={20} />}>Point Claude Code at Jan's local server to run Opus, Sonnet, and Haiku tiers on your own hardware.</DocCard>
+ <DocCard title="OpenClaw" href="/docs/desktop/integrations/openclaw" icon={<Bot size={20} />}>Wire OpenClaw to Jan's local API for a fully private autonomous agent — no cloud, no usage fees.</DocCard>
+</DocCards>
+
+## Using with OpenAI SDK
+
+Point the OpenAI SDK at your local server by setting the base URL and API key:
+
+```python
+from openai import OpenAI
+
+client = OpenAI(
+ base_url="http://127.0.0.1:1337/v1",
+ api_key="YOUR_API_KEY"
+)
+
+response = client.chat.completions.create(
+ model="jan-v3-4b-base-instruct",
+ messages=[{"role": "user", "content": "Hello!"}]
+)
+```
+
+```typescript
+import OpenAI from "openai";
+
+const client = new OpenAI({
+ baseURL: "http://127.0.0.1:1337/v1",
+ apiKey: "YOUR_API_KEY",
+});
+```
diff --git a/docs/src/pages/docs/desktop/mlx-server.mdx b/docs/src/pages/docs/desktop/mlx-server.mdx
new file mode 100644
index 000000000..da2ce6842
--- /dev/null
+++ b/docs/src/pages/docs/desktop/mlx-server.mdx
@@ -0,0 +1,57 @@
+---
+title: MLX Server
+description: Jan's MLX inference server for Apple Silicon
+keywords:
+ [
+ Jan,
+ MLX,
+ Apple Silicon,
+ local AI,
+ Metal,
+ inference server,
+ mlx-swift-lm,
+ ]
+---
+
+import { Callout } from 'nextra/components'
+
+# MLX Server
+
+Jan's MLX Server is a local inference server for Apple Silicon, powered by [mlx-swift-lm](https://github.com/ml-explore/mlx-swift-lm). It uses Metal GPU acceleration for fast, efficient model serving on macOS.
+
+<Callout type="warning">
+MLX support in Jan is currently in beta and will be improved significantly over time.
+</Callout>
+
+## Requirements
+
+- macOS 14 or higher
+- Apple Silicon (M1, M2, M3 or later)
+
+## Accessing MLX Settings
+
+Find MLX settings at **Settings** > **MLX** under Model Providers:
+
+![MLX Settings](./_assets/mlx-settings.png)
+
+## How It Works
+
+Jan integrates MLX via [mlx-swift-lm](https://github.com/ml-explore/mlx-swift-lm), running a local inference server on top of it. The server is spawned and managed by Jan's MLX plugin, which handles model loading, lifecycle, and communication with the rest of the app.
+
+The MLX server exposes an OpenAI-compatible API on a local port. Jan routes requests to it automatically when an MLX model is active — no manual configuration needed.
+
+## Model Management
+
+MLX supports models in MLX-Swift format. Jan ships with MLX-compatible versions of its foundation models.
+
+### Download from Hub
+
+Browse and download MLX-compatible models directly from the [Hub](/docs/desktop/manage-models) tab in the left sidebar.
+
+### Import Local Files
+
+Click **Import** to link an MLX model file already on your computer — useful for models downloaded via your browser from Hugging Face or shared with other apps.
+
+### Delete a Model
+
+Click the trash icon next to any model to remove it. Linked files leave the original intact.