KoboldAI API in KoboldCpp: generate, stream and extras
The KoboldAI API is the native API of KoboldCpp, served at http://localhost:5001/api/v1 with KoboldCpp's own additions under /api/extra. It is free and local: there is no account, and no key unless the server was started with --password. Apps that offer a KoboldAI or KoboldCpp connection want just http://localhost:5001. Text generation is a POST to /api/v1/generate; streaming uses /api/extra/generate/stream.
Checked against KoboldCpp 1.124.2 · updated 13 Nov 2026
- lab-lnx: Linux test VM · 4 vCPU · 15 GB · no GPU
On this page
KoboldAI API: the original and KoboldCpp
The original KoboldAI client is legacy, and its project points people to KoboldCpp (the difference). KoboldCpp serves the same /api/v1 routes and reports API version 1.2.5, which is the KoboldAI API version and not its own F24. The soft-prompt routes only exist for compatibility.
API tester
Send a request to your own KoboldCpp.
Requests go from your browser straight to the address you typed. Nothing is sent to koboldcpp.dev, and the password is never put in a share link.
All the native routes
| Main parameters | ||||||
|---|---|---|---|---|---|---|
| POST | /api/v1/generate | KoboldAI | Classic KoboldAI text generation: prompt plus sampler settings, returns the full result. | max_context_length max_length prompt rep_pen rep_pen_range sampler_order | yes | works F23 |
| GET | /api/v1/model | KoboldAI | Name of the loaded text model (masked when a password is set and not supplied). | yes | works F23 | |
| GET | /api/v1/config/max_length | KoboldAI | Default generation length the server advertises. | yes | works F23 | |
| GET | /api/v1/config/max_context_length | KoboldAI | Context length the server advertises to clients. | yes | works F23 | |
| GET | /api/v1/config/soft_prompt | KoboldAI | Stub kept for KoboldAI client compatibility (soft prompts not supported). | no | untested | |
| GET | /api/v1/config/soft_prompts_list | KoboldAI | Stub returning an empty soft-prompt list for compatibility. | no | untested | |
| GET | /api/v1/info/version | KoboldAI | KoboldAI United API version that KoboldCpp emulates. | yes | works F23 | |
| GET | /api/v1 | KoboldAI | Bare API root; redirects (302) to the /api docs page. | no | untested | |
| POST | /api/extra/generate/stream | Extra | Same as /api/v1/generate but streams tokens as Server-Sent Events. | max_context_length max_length prompt rep_pen rep_pen_range sampler_order | yes | works F23 |
| GET | /api/extra/generate/check | Extra | Returns the partial text of the generation in progress. | yes | untested | |
| POST | /api/extra/generate/check | Extra | Partial text of an in-progress generation identified by genkey (multi-user safe). | genkey | yes | untested |
| POST | /api/extra/abort | Extra | Stops the current generation (optionally only for a given genkey). | genkey | yes | untested |
| GET | /api/extra/version | Extra | KoboldCpp version and a feature/capability list (vision, audio, image gen, TTS, etc.). | yes | works F23 | |
| GET | /api/extra/true_max_context_length | Extra | The real --contextsize loaded at launch (not advertised to Horde). | yes | works F23 | |
| GET | /api/extra/perf | Extra | Timing and usage statistics of recent generations, queue state, uptime. | yes | works F23 | |
| GET | /api/extra/last_logprobs | Extra | Token log-probabilities of the latest request. | yes | untested | |
| POST | /api/extra/last_logprobs | Extra | Token log-probabilities for the request with a given genkey. | genkey | yes | untested |
| POST | /api/extra/tokencount | Extra | Tokenizes text and returns the token count and ids. | prompt | yes | works F23 |
| POST | /api/extra/detokenize | Extra | Turns a list of token ids back into text. | ids | yes | untested |
| POST | /api/extra/json_to_grammar | Extra | Converts a JSON schema into a GBNF grammar for constrained sampling. | schema | yes | untested |
| GET | /api/extra/preloadstory | Extra | Returns the story preloaded with --preloadstory. | yes | untested | |
| POST | /api/extra/websearch | Extra | Runs a DuckDuckGo web search through the server (needs --websearch) and returns top results. | q | yes | untested |
| POST | /api/extra/data/list | Extra | Lists save slots in the server-side save database (--savedatafile). | yes | untested | |
| POST | /api/extra/data/load | Extra | Loads a save slot from the server-side database. | slot | yes | untested |
| POST | /api/extra/data/save | Extra | Writes data to a server-side save slot. | slot format title data | yes | untested |
| POST | /api/extra/multiplayer/status | Extra | Multiplayer session turn info (--multiplayer). | senderbusy sender | yes | untested |
| POST | /api/extra/multiplayer/getstory | Extra | Fetches the shared multiplayer story (compressed). | yes | untested | |
| POST | /api/extra/multiplayer/setstory | Extra | Updates the shared multiplayer story and advances the turn. | full_update sender data_format data | yes | untested |
| POST | /api/extra/shutdown | Admin | Shuts the server down (only allowed in specific setups; password-protected). | yes | untested | |
| POST | /api/extra/embeddings | Extra | Native embeddings endpoint. | model input truncate | yes | untested |
| GET | /api/admin/list_options | Admin | Lists .kcpps/.kcppt/.gguf choices in --admindir. | yes | untested | |
| POST | /api/admin/reload_config | Admin | Switches to another config/model in --admindir (or unloads); restarts the backend. | filename baseconfig | yes | untested |
| POST | /api/admin/check_state | Admin | Size of existing KV save states and the prediction for a new one. | yes | untested | |
| POST | /api/admin/save_state | Admin | Saves the current KV cache to a memory slot. | slot | yes | untested |
| POST | /api/admin/load_state | Admin | Restores a saved KV cache slot. | slot | yes | untested |
| POST | /api/admin/clear_state | Admin | Frees all KV save states. | yes | untested | |
| GET | /.well-known/serviceinfo | Extra | Service identity document listing which APIs this server provides. | yes | untested | |
| GET | /ping | Extra | Health check for serverless hosts (added v1.97). | no | untested | |
| OPTIONS | * | Extra | CORS preflight / header-only responses for any path. | no | untested | |
| HEAD | * | Extra | CORS preflight / header-only responses for any path. | no | untested |
Generate text
POST /api/v1/generate (also /api/latest/generate). We sent a prompt and read the answer F85:
{
"prompt": "Hello",
"max_length": 8,
"temperature": 0,
"max_context_length": 2048
}{
"results": [{
"text": "\n\nI am trying to create a simple",
"tool_calls": [],
"finish_reason": "length",
"logprobs": null,
"prompt_tokens": 1,
"completion_tokens": 8
}]
}Generation parameters
The server publishes its own spec at /api?json=1. We saved it and built this table from it; the descriptions are ours. Sampler meanings are on the settings page. If a request leaves max_length out the server uses 2048 F05.
max_context_length | integer | not set | KoboldAI too | How many tokens of the prompt the server may use. Send the same number the server was started with. |
max_length | integer | not set | KoboldAI too | How many tokens to write. The server default is 2048 when this is left out. |
prompt | string | not set | KoboldAI too | The text to continue. Everything the model should see goes here. |
rep_pen | number | not set | KoboldAI too | Repetition penalty. 1.0 means none. |
rep_pen_range | integer | not set | KoboldAI too | How many of the latest tokens the repetition penalty looks at. |
sampler_order | array | not set | KoboldAI too | The order the samplers run in. Leave it alone unless a guide for your model says otherwise. |
sampler_seed | integer | not set | KoboldAI too | A number that makes sampling repeatable on one machine. |
stop_sequence | array | not set | KoboldAI too | Strings that end the reply when the model writes them. |
temperature | number | not set | KoboldAI too | How random the choice of the next word is. 0 always takes the likeliest. |
tfs | number | not set | KoboldAI too | Tail free sampling, a way to cut unlikely words. 1 turns it off. |
top_a | number | not set | KoboldAI too | Top-a sampling. 0 turns it off. |
top_k | integer | not set | KoboldAI too | Keep only this many likeliest words. 0 turns it off. |
top_p | number | not set | KoboldAI too | Keep the smallest group of words whose chances add up to this. 1 turns it off. |
min_p | number | not set | KoboldAI too | Drop words whose chance is below this share of the likeliest word. |
typical | number | not set | KoboldAI too | Typical sampling. 1 turns it off. |
use_default_badwordsids | boolean | false | KoboldAI too | When true, the end-of-text token cannot be written. |
dynatemp_range | number | 0 | KoboldAI too | A range around the temperature that varies with the model certainty. 0 turns it off. |
smoothing_factor | number | 0 | KoboldAI too | Reshapes the chances around the top word. 0 turns it off. |
dynatemp_exponent | number | 1 | KoboldAI too | Exponent used by dynamic temperature. |
mirostat | number | not set | KoboldCpp only | Mirostat mode: 0 off, 1 or 2 on. |
mirostat_tau | number | not set | KoboldCpp only | Mirostat target surprise. |
mirostat_eta | number | not set | KoboldCpp only | Mirostat learning rate. |
genkey | string | not set | KoboldCpp only | A key you choose, so check and abort calls reach your own request on a shared server. |
grammar | string | not set | KoboldCpp only | A GBNF grammar the reply must follow. |
grammar_retain_state | boolean | false | KoboldCpp only | Keep the grammar state from the previous request. |
memory | string | not set | KoboldCpp only | Text that is always put at the very start of the prompt. |
images | array | not set | KoboldCpp only | Base64 images for a vision model. |
trim_stop | boolean | true | KoboldCpp only | Remove a matched stop sequence from the returned text. |
render_special | boolean | false | KoboldCpp only | Show special tokens in the returned text. |
bypass_eos | boolean | false | KoboldCpp only | Allow the end-of-text token to be written. |
banned_tokens | array | not set | KoboldAI too | Strings that must not appear in the reply. |
logit_bias | object | [object Object] | KoboldCpp only | Raise or lower the chance of chosen token ids. |
dry_multiplier | number | not set | KoboldCpp only | DRY strength. 0 turns it off. |
dry_base | number | not set | KoboldCpp only | DRY base: how fast the penalty grows with repeat length. |
dry_allowed_length | number | not set | KoboldCpp only | Repeats up to this length are not penalised. |
dry_penalty_last_n | number | not set | KoboldCpp only | How many latest tokens DRY looks at. |
dry_sequence_breakers | array | not set | KoboldAI too | Strings that stop DRY from counting a repeat. |
xtc_threshold | number | not set | KoboldCpp only | XTC: words above this chance can be removed. |
xtc_probability | number | not set | KoboldCpp only | XTC: how often the removal happens. 0 turns it off. |
nsigma | number | not set | KoboldCpp only | Top-n-sigma sampling. 0 turns it off. |
logprobs | boolean | false | KoboldAI too | Return the top token chances for each generated token. |
replace_instruct_placeholders | boolean | false | KoboldAI too | Swap the instruct placeholders in the prompt for the tags of the loaded template. |
Streaming with SSE
POST /api/extra/generate/stream takes the same body and answers with server-sent events. For 12 requested tokens we received 6 events, the first with several tokens, and the last with an empty token and a finish reason F85:
event: messagedata: {"token": " 4, 5,", "finish_reason": null}1…event: messagedata: {"token": "", "finish_reason": "length"}2- data: {"token": " 4, 5,", "finish_reason": null}: A chunk can hold more than one token.
- data: {"token": "", "finish_reason": "length"}: The last event: the reason the reply ended.
Check progress and abort
While a request runs, POST /api/extra/generate/check with its genkey returns the text so far (732 characters after 5 seconds in our test). POST /api/extra/abort with the same genkey stops it: it answered {"success":"true","done":"true"} and the waiting generate call ended with 705 characters of partial text and status 200 F85.
The genkey is a string you choose and send with the generate call. It keeps your check and abort calls separate from other people’s on a shared server.
Server info
/api/v1/model | koboldcpp/<model file name> |
/api/v1/config/max_length | {"value": 2048} |
/api/v1/config/max_context_length | the context size the server started with |
/api/extra/true_max_context_length | the same value on our run |
/api/v1/info/version | {"result": "1.2.5"} (the API version) |
/api/extra/version | KoboldCpp, 1.124.2 and flags such as llm, jinja, savedata, admin |
/api/extra/perf | last speeds, queue, uptime (34.6 tokens per second for our 8-token request) |
Tokens and logprobs
- Count:
POST /api/extra/tokencountwith{"prompt": "Hello world"}returnedvalue: 3and the token ids;/api/extra/tokenizeis an alias. Note that the first id was the end-of-text token (151643) on this model. - Decode:
POST /api/extra/detokenizewith{"ids": [...]}returnedresultandsuccess. - Logprobs: send
"logprobs": trueand the answer carrieslogprobs.contentwithtop_logprobsper token./api/extra/last_logprobs(GET, or POST with agenkey) returns the latest. At temperature 0 every value we saw was 0.0. - Grammar:
POST /api/extra/json_to_grammarturns a JSON schema into GBNF text you can pass asgrammar.
All captured on the 0.5B test model F85.
Saves, preloaded stories and multiplayer
/api/extra/data/* needs Server-side save database (.jsondb) so users can save/load stories to the server.Default Launcher Loaded Files tab: SaveData File + "Enable Server Side SaveData File"Since v1.85.1All details (1.85), /api/extra/preloadstory needs Serves a saved story JSON at /api/extra/preloadstory so Kobold Lite opens with it.Default Launcher Loaded Files tab: Preload StorySince v1.49All details, and /api/extra/multiplayer/* needs Hosts a shared Kobold Lite session that several users can join and edit together.Default falseLauncher Network tab: Shared MultiplayerSince v1.79All details (1.79). We ran them only without their flags, where preloadstory answered {}. See multiplayer.
Admin endpoints
/api/admin/* (list options, reload config, save and load KV states) needs Enables admin mode: models/configs can be unloaded and swapped at runtime from the UI or admin API.Default falseLauncher Admin tab: Enable Model AdministrationSince v1.83All details with Folder of .kcpps/.kcppt/.gguf files that admin mode may switch between.Default Launcher Admin tab: Config Directory (Required)Since v1.83All details; protect it with Password protecting admin functions (strongly advised on public instances). Also via KCPP_ADMINPASSWORD.Default noneLauncher Admin tab: Admin PasswordSince v1.83All details. Without them list_options answered an empty list in our run F85.
Authentication
With API key that clients must send to use text endpoints (image endpoints are not protected). Also settable via KCPP_PASSWORD.Default noneLauncher Network tab: PasswordSince v1.61All details clients send Authorization: Bearer <key>. It protects generation, not discovery F25. Details: the API page.
Frequently asked questions
Is the KoboldAI API free?
Yes. It is part of the KoboldCpp program on your own computer. There is no account and no charge.
What is the KoboldAI API URL?
http://localhost:5001 for most apps, or http://localhost:5001/api/v1 where an app asks for the full path. From another computer, use the address of the PC running KoboldCpp.
Where do I get a KoboldAI API key?
There is none by default. A key exists only if you start KoboldCpp with --password, and then clients send it as a Bearer header.
How do I stream tokens?
POST the same body as generate to /api/extra/generate/stream. The reply is a stream of events, each with a data line holding token and finish_reason; the last has finish_reason set.
Is this the same API as the old KoboldAI?
It is the same shape: KoboldCpp reports API version 1.2.5 at /api/v1/info/version, as the original did. KoboldCpp adds parameters and the /api/extra routes.
How do I stop a generation?
POST /api/extra/abort. On a shared server include the genkey you sent with the request. In our test the waiting generate call ended with the partial text.