Introduction
Jan provides a built-in, OpenAI-compatible API server that runs entirely on your computer, powered byllama.cpp. Use it as a drop-in replacement for cloud APIs to build private, offline-capable AI applications.
The API server is accessible at http://127.0.0.1:1337 by default and follows OpenAI’s API conventions.
Base URL
Authentication
All API requests require authentication using a Bearer token in theAuthorization header.
Setting up Authentication
- Navigate to Settings > Local API Server in Jan
- Enter a custom API Key (e.g.,
secret-key-123) - Click Start Server
Using the API Key
Include the API key in all requests:Example Request
Server Configuration
Network Settings
The network address the server listens on.
127.0.0.1: Accessible only from your computer (most secure)0.0.0.0: Accessible from other devices on your network
The port number for the API server. You can change this to any available port (e.g.,
8000).The base path for all API endpoints. Follows OpenAI’s convention.
Security Settings
A mandatory secret key to authenticate requests. Must be included in the
Authorization: Bearer YOUR_API_KEY header for all requests.A comma-separated list of hostnames allowed to access the server. Provides an additional layer of security when the server is exposed on your network.
Advanced Settings
Enables Cross-Origin Resource Sharing (CORS) to allow web applications running on different domains to make requests to the API server. Disable for non-browser-based applications.
Provides detailed, real-time logs of all incoming requests, responses, and server activity. Useful for debugging.
Available Endpoints
Chat Completions
Generate chat completions with streaming support
Models
List and retrieve available models
Embeddings
Generate embeddings for text inputs
Error Handling
The API uses standard HTTP status codes:200- Success400- Bad Request (invalid parameters)401- Unauthorized (missing or invalid API key)404- Not Found (model not available)500- Internal Server Error
Error Response Format
Troubleshooting
Connection Refused
The server is not running, or your application is pointing to the wrong host or port.401 Unauthorized
Your API Key is missing from theAuthorization header or is incorrect.
404 Not Found
- The
modelID in your request body does not match an available model in Jan - Your request URL is incorrect (check the API Prefix)
CORS Error (in web browser)
Ensure the CORS toggle is enabled in Jan’s settings.Out of Context
The conversation has exceeded the model’s context window. The API will return afinish_reason of length.